Lex-highlighter
100% stream-based
Warning
This is proof-of-concept implementation and WON't be colorful like existing syntax highlighter solutions.
Stream format
<stream> ::= (<span> <newline>)*
<span> ::= <number> <ws> <number> <ws> <colorprofile>
<number> ::= 0 | [1-9] [0-9]*
<colorprofile> ::= <color> | "!" <color> | <color> <ws> "!" <color> | "!" <color> <ws> <color>
<color> ::= "#" <hex>{6}
<hex> ::= [0-9a-fA-F]
<ws> = (" " | "\t")+
- Negative indexing is not supported.
- Currently only hex colors are supported.
- Hex colors should have exactly 6 digits.
- Use
!
(inverse) to represent background color. - You can use foreground and background colors at the same time, but you can't use more than one foreground / background colors.
- Styles(italic, bold, etc) are not supported yet.
- Empty lines are not allowed.
Example
Proof-of-concept example highlighter using swc.
$ git clone https://github.com/abiriadev/lex-highlighter && cd lex-highlighter
$ cargo run --example js-highlighter ./examples/sample.ts | cargo run ./examples/sample.ts