Syntax Highlighting With Line Numbering And Classes In Rust
This page is a work in progress. This is an attempt to switch to classes via find/replace since using the classes out of syntect closes spans on differnet lines sometimes. That's fine in general, but I'm tyring to add line numbers and it messes with that.
UPDATE: okay, trying to use just the tokens didn't work either. The issue seems to be when a single type of text breaks across multiple lines. So, the original way farhter below works fine.
rust
```cargo
= "5.2.0"
```
use HighlightLines;
use ThemeSet;
use ;
use SyntaxSet;
syntect
<p> a b c </p>
NOTE: There may be an issue with with where sometimes it puts closing spans tags on trialign lines. I'm looking at going to a method of doing direct token highlighting and then converting them to classes from there. Based off what I'm reading in the docs that seems like it might be more consistent.
rust
```cargo
= "5.1.0"
```
use ;
use SyntaxSet;
use LinesWithEndings;
syntect
rust
```cargo
= "5.1.0"
```
use ;
use SyntaxSet;
use LinesWithEndings;
syntect
x <- 5
y <- 6
x + y
warning: unused `Result` that must be used
--> /Users/alan/.cargo/target/55/19854259915251/_active_nvim_run:20:5
|
20 | html_generator.parse_html_for_line_which_includes_newline(line);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this `Result` may be an `Err` variant, which should be handled
= note: `#[warn(unused_must_use)]` on by default
help: use `let _ = ...` to ignore the resulting value
|
20 | let _ = html_generator.parse_html_for_line_which_includes_newline(line);
| +++++++
css
.
.
. :before
This is how I'm doing syntax highlighting in Rust.
This is the main way I'm doing it where instead of adding the styles inline it adds classes.
References
- See this for how to output the styelsheet: