Skip to content

Commit c144c04

Browse files
Use tree-sitter-multilingual for syntax highlighting
1 parent 80f80e6 commit c144c04

12 files changed

Lines changed: 725 additions & 286 deletions

File tree

.github/workflows/example-executability.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v4
1919

20+
- name: Check out tree-sitter-multilingual
21+
uses: actions/checkout@v4
22+
with:
23+
repository: multilingualprogramming/tree-sitter-multilingual
24+
path: tree-sitter-multilingual
25+
2026
- name: Set up Python ${{ matrix.python-version }}
2127
uses: actions/setup-python@v5
2228
with:
@@ -30,6 +36,9 @@ jobs:
3036
- name: Validate release metadata
3137
run: python tools/check_release.py
3238

39+
- name: Verify Monarch tokenizer is in sync
40+
run: python tools/check_monarch_sync.py --tree-sitter-root tree-sitter-multilingual --show-diff
41+
3342
- name: Check local links
3443
run: python tools/check_links.py
3544

.github/workflows/monitor-multilingual.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ jobs:
2727
steps:
2828
- uses: actions/checkout@v4
2929

30+
- name: Check out tree-sitter-multilingual
31+
uses: actions/checkout@v4
32+
with:
33+
repository: multilingualprogramming/tree-sitter-multilingual
34+
path: tree-sitter-multilingual
35+
3036
- name: Set up Python
3137
uses: actions/setup-python@v5
3238
with:
@@ -67,6 +73,9 @@ jobs:
6773
- name: Validate release metadata
6874
run: python tools/check_release.py
6975

76+
- name: Verify Monarch tokenizer is in sync
77+
run: python tools/check_monarch_sync.py --tree-sitter-root tree-sitter-multilingual --show-diff
78+
7079
- name: Check local links
7180
run: python tools/check_links.py
7281

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ First tagged release of the browser playground.
3434
### Changed
3535

3636
- Updated the playground's complete-feature example links and visible source-extension copy from `.ml` to `.multi` to match the renamed upstream example files.
37+
- Migrated the browser editor from CodeMirror 5 to Monaco Editor while preserving the existing Pyodide runtime flow, share links, theme toggle, keyboard shortcuts, and split-pane behavior.
38+
- Pinned browser syntax highlighting to `tree-sitter-multilingual` by shipping a generated `assets/monarch.json` tokenizer artifact from the grammar repository.
39+
- Updated the existing CI workflows to check out `multilingualprogramming/tree-sitter-multilingual` and fail if the pinned Monaco tokenizer drifts from the generated upstream artifact.

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,22 @@ The playground runs entirely in the browser:
2828

2929
- **Pyodide** - CPython 3.12 compiled to WASM; runs the full interpreter
3030
- **wabt.js** - WABT on WASM; compiles generated WAT to binary WASM in the browser
31-
- **CodeMirror 5** - editor with syntax highlighting and dark/light theme toggle
31+
- **Monaco Editor** - browser editor with generated multilingual syntax highlighting and dark/light theme toggle
3232

3333
No server is required. The page prefers a local wheel from `assets/wheel_info.json` when present, then falls back to installing `multilingualprogramming` from PyPI via `micropip`.
3434

3535
The main document is a thin shell. Playground styles live in `assets/playground.css`, and the application logic is split across `assets/main.js`, `assets/editor.js`, `assets/runtime.js`, `assets/ui.js`, `assets/theme.js`, `assets/i18n.js`, and `assets/examples.js`.
3636

37+
The editor syntax layer is generated from the sibling `tree-sitter-multilingual` repository at `https://github.com/multilingualprogramming/tree-sitter-multilingual`. The playground ships a pinned `assets/monarch.json` derived from that grammar so browser highlighting stays aligned with upstream keyword and grammar updates.
38+
3739
## Release validation
3840

3941
The pinned CI baseline lives in `requirements-build.txt`.
4042

4143
This release line is checked in two ways:
4244

4345
- `python tools/check_examples.py` executes all bundled example programs in each supported source language.
46+
- `python tools/check_monarch_sync.py --tree-sitter-root ../tree-sitter-multilingual` verifies that the pinned Monaco tokenizer still matches the generated grammar artifact from `https://github.com/multilingualprogramming/tree-sitter-multilingual`.
4447
- GitHub Actions runs `.github/workflows/example-executability.yml` on pushes and pull requests.
4548
- A scheduled compatibility workflow also checks the pinned baseline, the latest published package, and upstream `main`.
4649

RELEASE.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,24 @@ Prepare a playground release when at least one of these changes:
2121
3. Update visible release copy in [`index.html`](index.html), especially the backend note in the WAT / WASM tab.
2222
4. Refresh examples and language metadata in [`assets/examples.js`](assets/examples.js), [`assets/editor.js`](assets/editor.js), and related runtime modules if language coverage changed.
2323
Also verify that visible source-extension copy and upstream example links still match the current example filename convention, currently `.multi`.
24+
If the grammar repo changed, refresh the pinned Monaco tokenizer asset in [`assets/monarch.json`](assets/monarch.json) from `../tree-sitter-multilingual/generated/monarch.json`.
25+
The upstream grammar repository is `https://github.com/multilingualprogramming/tree-sitter-multilingual`.
2426
5. Verify metadata files:
2527
[`sitemap.xml`](sitemap.xml),
2628
[`robots.txt`](robots.txt),
2729
[`site.webmanifest`](site.webmanifest).
2830
6. Run:
2931
`python tools/check_release.py --expected-date YYYY-MM-DD`
3032
7. Run:
33+
`python tools/check_monarch_sync.py --tree-sitter-root ../tree-sitter-multilingual`
34+
8. Run:
3135
`python tools/check_examples.py`
32-
8. Confirm GitHub Actions passes:
36+
9. Confirm GitHub Actions passes:
3337
[`.github/workflows/example-executability.yml`](.github/workflows/example-executability.yml)
34-
9. Open [`index.html`](index.html) in a browser and smoke-test:
38+
10. Open [`index.html`](index.html) in a browser and smoke-test:
3539
language switching, example switching, run/clear/share, output tabs, theme toggle, keyboard navigation, and narrow-screen layout.
36-
10. Update [`CHANGELOG.md`](CHANGELOG.md).
37-
11. Prepare outward-facing release notes using the template below.
40+
11. Update [`CHANGELOG.md`](CHANGELOG.md).
41+
12. Prepare outward-facing release notes using the template below.
3842

3943
## Release note template
4044

@@ -73,6 +77,7 @@ Highlights in the current release line:
7377
- `with`, `try/except`, `lambda`, `match/case`, and `async/await`
7478
- `@property` accessors and bytes literals
7579
- modular browser assets centered on [`assets/playground.css`](assets/playground.css), [`assets/main.js`](assets/main.js), and [`assets/runtime.js`](assets/runtime.js)
80+
- Monaco-based browser editing with grammar-generated syntax highlighting
7681
- improved accessibility and mobile behavior
7782
- added release validation with [`tools/check_release.py`](tools/check_release.py)
7883
- added example executability validation with [`tools/check_examples.py`](tools/check_examples.py) and [`.github/workflows/example-executability.yml`](.github/workflows/example-executability.yml)

0 commit comments

Comments
 (0)