Languages
A small tokenizer for each language prose highlights. Each one turns source into coloured spans, and highlight.ts turns the spans into lines of HTML.
They colour code as shiki's CSS-variables theme did, in the same few colours, since prose used shiki until they replaced it. A script compared the two on this repository's files, and they agree on about 99% of characters. The rest is where only a full grammar can tell, like whether a name is a type or a value. tests/highlight.test.ts keeps cases from that comparison, with the colours shiki gave them, so the match holds without shiki.
- scan.ts has the colours, and a scanner that colours text by a list of regex rules.
- js.ts colours JS, TS and JSON from the tokens of lexer.ts, the lexer the parser uses.
- css.ts reads CSS a statement at a time, and markup.ts reads HTML and Svelte, with their scripts and styles.
- markdown.ts walks markz's own parse.
- config.ts has YAML, TOML and
.gitignore, shell.ts shell, and ebnf.ts the W3C's EBNF.
Code
- config.ts
The files that configure a project, each a list of keys and values with
#comments. A YAML key is coloured as a keyword and a plain value as a string, as shiki colours them. TOML's keys and tables stay plain, as they did with shiki, and its values take their own colours. - css.ts
The same word takes a different colour in a selector, a property and a value, so CSS is read one statement at a time. Inside a block, a statement that reaches
;or}before any{is a declaration, and anything else is a nested rule's selector. An@starts an at-rule. - ebnf.ts
The W3C's EBNF, the notation the XML spec uses for its grammar. With it, an
ebnffence in a doc is highlighted like the code around it. - js.ts
Colours the tokens lexer.ts finds. The parser trusts the same tokens for its comments, so a string or a regex is never coloured as code, nor code as a string.
- markdown.ts
Markdown as code, for a
mdfence in a doc. It's read with markz's own parser, the one that renders the docs, so what's coloured as a heading or a link is exactly what markz reads as one. There's no second, guessing reader of the same dialect. - markup.ts
A tag's name is coloured as a string and its attributes as functions, as shiki's HTML grammar colours them. The body of a
<script>is coloured as JS and a<style>as CSS, so a page's embedded code reads like a file of its own. - scan.ts
What every language here shares. It has the colours a piece of code can take, and a scanner that colours source by a list of rules.
- shell.ts
Scripts that sit beside a project's code. prose shows them as highlighted text, without reading their comments as prose (writing).