I made a smol client-side syntax highlighter that uses the CSS Custom Highlights API called MicroLighter. I’ll talk about why I made it in a bit but first I wanted to… ahem… highlight… some of the features.
OK now I see what expandEnd is trying to do – based on the capture of the begin pattern, it’s dynamically compiling a regex for an end pattern. (This is trying to match TextMate semantics, and TextMate also apparently does this dynamic compilation …)
Except that rewrite is unsound:
\1 versus \\1 – the latter is a backslash and then the digit 1, and gets messed up
[\1] – is in a character class, not a backreference
\10 is not a backreference – there are only 9 in JS, with a single digit
This is gross … I wanted to call it slop, but it’s actually inherited from TextMate. So there is pre-AI slop too, or Unix sludge …
OK now I see what
expandEndis trying to do – based on the capture of thebeginpattern, it’s dynamically compiling a regex for anendpattern. (This is trying to match TextMate semantics, and TextMate also apparently does this dynamic compilation …)Except that rewrite is unsound:
\1versus\\1– the latter is a backslash and then the digit 1, and gets messed up[\1]– is in a character class, not a backreference\10is not a backreference – there are only 9 in JS, with a single digitThis is gross … I wanted to call it slop, but it’s actually inherited from TextMate. So there is pre-AI slop too, or Unix sludge …
score 1 · canonical