bytecodealliance / bytecodealliance/component-docs

Add syntax highlighting to WIT documentation

Open
#238 7 comments 0 reactions 1 assignee Claimed by @mkatychev View on GitHub
Dominant language
Rust
Stars
137
Forks
88
Avg merge
5d 12h
Merged PRs (30d)
4

Description

WIT code is currently unhighlighted as [highlight.js](https://highlightjs.org/) does not support WIT currently. Using the [`mdbook-treesitter`](https://github.com/Corpauration/mdbook-treesitter) preprocessor is a good avenue to add syntax highlighting for all WIT codeblocks in the documentation, working example of it in action:
https://mkatychev.github.io/component-docs/design/wit.html#worlds

Caveat:
Current `mdbook-treesitter` outputs grammar logic used for highlighting as [dylib file](https://github.com/Corpauration/mdbook-treesitter) (`wit.so`) and work is needed adding emscripten support to output a `wit.wasm` grammar file.

Create issues in https://github.com/bytecodealliance/vscode-wit and https://github.com/liamwh/tree-sitter-wit to support newer component model syntaxes:
- [x] Sized lists: [`list`](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md#:~:text=list%3Cu8%2C%204%3E;)
- [x] [feature gates](https://github.com/mkatychev/tree-sitter-wit/commit/9edb9528bc69fcb4552aa0cfd9d3c50b78946807)
- [x] [`stream` and `future` types](https://github.com/liamwh/tree-sitter-wit/pull/15)
- [x] [nested comments](https://github.com/mkatychev/tree-sitter-wit/commit/129157bfad15f9c3c142c60625ef3cd88b33e453)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.