The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Hack Tree-Sitters HTML Debug Output To Dark Mode

TODO: Pull subtitle into page object
Code
body {
    background-color: darkslategray;
}


Change:
code_start_default_section code_end_default_section

Notes

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Hack Tree-Sitters HTML Debug Output To Dark Mode

I'm working on a Tree-Sitter^ts^^ parser for Neopolitan. 
I'm using the `-D`` flag for command line tests
to produce a `log.html`` 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

-- code
-- name: cli/src/util.rs

body {
    background-color: darkslategray;
}


Change:

-- code/
-- c
-- name: cli/lib/src/parser.c

fprintf(self->dot_graph_file, "graph {\nlabel=\"");

-- /code

To:

-- code/
-- c
-- name: cli/lib/src/parser.c

fprintf(self->dot_graph_file, "graph {\nbgcolor=\"darkslategray\"\nlabel=\"");

-- /code


Change:

-- code/
-- c
-- name: cli/lib/src/stack.c

fprintf(f, "digraph stack { \n");

-- /code

To:

-- code/
-- c
-- name: cli/lib/src/stack.c

fprintf(f, "digraph stack { \nbgcolor=\"darkslategray\"\n");

-- /code


Change:

-- code/
-- c
-- name: cli/lib/src/subtree.c

fprintf(f, "digraph tree {\n");

-- /code

To:

-- code/
-- c
-- name: cli/lib/src/subtree.c

fprintf(f, "digraph tree {\nbgcolor=\"darkslategray\"\n");

-- /code


-- h3

Installing The Hack

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

-- code/

cargo install --path cli

-- /code

That drops the binary under:

~/.cargo/bin/tree-sitter 

-- /code

My main tree-sitter is under:

-- code/

/opt/homebrew/bin/tree-sitter

-- /code

I could switch things around to use
the new one 100% of the time, but 
I just call the `~/.cargo/bin`` version
directly when testing like:

-- code/

~/.cargo/bin/tree-sitter test

-- /code




-- notes

- 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 `brew install graphviz``


-- ref
-- id: gv
-- title: Graphviz
-- subtitle: - open source graph visualization software

-- ref
-- id: sc
-- title: Tree-Sitter Source Code

-- ref
-- id: ts
-- title: Tree-Sitter
-- subtitle: - a parser generator tool and an incremental parsing library

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



-- categories
-- Tree-Sitter 

-- metadata
-- date: 2023-10-14 14:00:43
-- id: 2wlu1skf
-- site: aws
-- type: post
-- status: draft