Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Hack Tree - Sitters HTML Debug Output To Dark Mode

I'm working on a Tree - Sitter ts parser for Neopolitan. I'm using the [TODO: Code shorthand span ] flag for command line tests to produce a [TODO: Code shorthand span ] file with a visual graph of the output. It's easier to figure out what's going on when things aren't going right.

The graph is produced by graphviz gv via an internal call STDIN call. The output is black text on a white background. As someone who like working in dark mode it's a bit of a flash - bang every time I switch to it.

To fix that, I pulled down the source code sc and made the following edits :

Add this to the style sheet section

body {
    background-color: darkslategray;
}


Change:
c
fprintf(self->dot_graph_file, "graph {\nlabel=\"");
c
fprintf(self->dot_graph_file, "graph {\nbgcolor=\"darkslategray\"\nlabel=\"");
c
fprintf(f, "digraph stack { \n");
c
fprintf(f, "digraph stack { \nbgcolor=\"darkslategray\"\n");
c
fprintf(f, "digraph tree {\n");
c
fprintf(f, "digraph tree {\nbgcolor=\"darkslategray\"\n");

Installing The Hack

Installing the modified version of Tree - Sitter is done by running :

cargo install --path cli
~/.cargo/bin/tree-sitter
/opt/homebrew/bin/tree-sitter
~/.cargo/bin/tree-sitter test

- The above changes the background color only. The text and lines stay black. It's possible to change them as well, but this is fine for me

- graphviz must be installed to generate the html. I got it using the homebrew command [TODO: Code shorthand span ]

Footnotes And References

  • gv
    Graphviz
  • sc
    Tree-Sitter Source Code
  • ts
    Tree-Sitter

    If all goes well, this is what I'll be using to do syntax highlighting for neopolitan in neovim