textmate-bjolang: code highlighted as VS Code does, as Bjolang values

TextMateSharp runs VS Code's TextMate grammars and themes; this hands
the result over once, as Bjolang values, so nothing using it needs to
know TextMateSharp is there. `tokenize` gives each line's tokens and
their scopes, `highlight` each line's spans in the theme's colours, and
`highlight->node` and `code->node` give (text xml) nodes: a pre and a
code element around spans, coloured inline by the theme or by class
names taken from the scopes. `highlighter-css` writes the stylesheet
for the classes from a theme, choosing each class's rule the way
TextMateSharp's tokenizer chooses a token's.

Bjolang's own grammar is in grammars/bjolang, laid out as a VS Code
extension, and every highlighter reads it from beside the package's
src/. It follows what Bjolang's reader reads, including interpolated
strings with expressions in their holes.

There is no C# shim: everything goes through import/class and
import/extern. The package is kept within TextMateSharp 2.0, because
token colours are decoded with a class in its Internal namespace.

🤖 Generated with [ECA](https://eca.dev) (anthropic/claude-opus-4-7)

Co-Authored-By: eca-agent <git@eca.dev>
This commit is contained in:
Linus Björnstam 2026-09-30 15:51:24 +02:00
commit 0ecc65e134
10 changed files with 2012 additions and 0 deletions

29
packages.lock.json Normal file
View file

@ -0,0 +1,29 @@
{
"version": 1,
"dependencies": {
"net10.0": {
"TextMateSharp.Grammars": {
"type": "Direct",
"requested": "[2.0.4, 2.1.0)",
"resolved": "2.0.4",
"contentHash": "jzOY00q5u5Vs4L9n2m2PnRZDGwWt2uwkOLh7qlVdCx1kkGSn5eaW5XgnYCyTzEbsCwLV2xlEolnNkr/wuIMAbA==",
"dependencies": {
"TextMateSharp": "2.0.4"
}
},
"Onigwrap": {
"type": "Transitive",
"resolved": "1.0.11",
"contentHash": "5/WAxSYWfiiPzp1X13qqdqjFmYLKDD/U7Vh3WCkKxWG9BjqdrXnQE5fCKCFJX+xWvuYLTxwZIVWBwBWObViE8g=="
},
"TextMateSharp": {
"type": "Transitive",
"resolved": "2.0.4",
"contentHash": "5Pvn+A4zb1IF+ACAVhgw1aGf9kTyx6j7v5hdup7nCS89Nzby8KQAlCfQ54VC/GAsEoQwh4zKa5MKlAaql8nkPg==",
"dependencies": {
"Onigwrap": "1.0.11"
}
}
}
}
}