Highlight Code In Rust With syntect
TODO
☐
look at this and combine it: id: 2ujekgik
```cargo
= "5.2.0"
```
use ThemeSet;
use highlighted_html_for_string;
use SyntaxSet;
syntect
Output:
<pre style="background-color:#2b303b;">
<span style="color:#c0c5ce;"><</span><span style="color:#bf616a;">p</span><span style="color:#c0c5ce;">></span><span style="color:#bf616a;">a
</span><span style="color:#c0c5ce;"> </span><span style="color:#bf616a;">b
</span><span style="color:#c0c5ce;"> </span><span style="color:#bf616a;">c
</span><span style="color:#c0c5ce;"> </</span><span style="color:#bf616a;">p</span><span style="color:#c0c5ce;">></span></pre>
This is the version from the docs for testing newline stuff I'm trying to figure out.
---
syntect = "5.2.0"
---
use HighlightLines;
use SyntaxSet;
use ;
use ;
Output:
See note
See note
warning: unused variable: `escaped`
--> /Users/alan/.cargo/target/4b/0baba35be9214e/_active_nvim_run:21:9
|
21 | let escaped = as_24_bit_terminal_escaped(&ranges[..], true);
| ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_escaped`
|
= note: `#[warn(unused_variables)]` on by default
Output:
Notes
-
It took a while to figure out the
&ss.syntaxes()[1]
part based off the docs. - I don't understand what's going on there either. Something to investigate.
- TODO is to look at this for a possibly simpler way: https://docs.rs/syntect/latest/syntect/easy/struct.HighlightLines.html
-- end of line --