Syntax Highlighting With Line Numbering And Classes In Rust

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.


fn main() {
  println!("Hello, World");
}

CSS

.numberedLines {
  counter-reset: lineNumber;
}

.numberedLine {
  counter-increment: lineNumber;
}

.numberedLine:before {
    display: inline-block;
    color: goldenrod;
    content: counter(lineNumber);
    padding-right: 0.7rem;
    text-align: right;
    width: 2rem;
}

References