Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Languages

Each chapter in this section renders the same source twice, side by side: on the left as mdbook-tsitter highlights it with tree-sitter, on the right as mdBook highlights it with highlight.js. Macaulay2 has a single tree-sitter example, as highlight.js does not know the language.

Every language here comes from the built-in grammar list and is configured by name alone, Macaulay2 included: its grammar is not in nvim-treesitter’s list, so the built-in list adds it. This is the book’s complete configuration:

[book]
title = "mdbook-tsitter"
src = "src"

# `after = ["links"]` runs this after mdBook's built-in include preprocessor, so
# any configured-language block inside content pulled in via {{#include}} (the
# root README.md / CONTRIBUTING.md) is highlighted too.
[preprocessor.tsitter]
after = ["links"]
# This book documents the preprocessor in this repository, so it runs it from
# source; mdBook starts the command in the book's directory, without a shell.
# A book using the published crate needs no `command`.
command = "cargo run --quiet --manifest-path ../../Cargo.toml --"
# inject = true        # (default) highlight languages embedded via injections
# default-css = true   # (default) embed the bundled stylesheet

# Languages from the built-in list need no source: each grammar is fetched at
# its pinned revision and compiled on the first build, then cached.
[preprocessor.tsitter.languages]
rust = {}
python = {}
typescript = { aliases = ["typescript", "ts"] }
javascript = { aliases = ["javascript", "js"] }
go = {}
java = {}
c = {}
cpp = { aliases = ["cpp", "c++"] }
bash = { aliases = ["bash", "sh", "shell"] }
php = {}
lua = {}
haskell = {}
markdown = { aliases = ["markdown", "md"] }
toml = {}
macaulay2 = { aliases = ["macaulay2", "m2"] }

[rust]
edition = "2021"

[output.html]
site-url = "/mdbook-tsitter/"
# Layout for the side-by-side comparison chapters; highlighting colours come
# from the embedded stylesheet. Everforest is an extra mdBook theme, added to
# the theme picker by `theme/index.hbs` (see the Theming chapter).
additional-css = ["theme/comparison.css", "theme/everforest.css"]
additional-js = ["theme/everforest.js"]

# Playground features kept on highlighted blocks (see the Interactive chapter).
[output.html.playground]
editable = true

[output.html.code.hidelines]
python = "~~"