mdbook-inline-highlighting

Crates.iomdbook-inline-highlighting
lib.rsmdbook-inline-highlighting
version0.1.0
sourcesrc
created_at2023-10-10 14:46:59.757919
updated_at2023-10-10 14:46:59.757919
descriptionmdBook preprocessor that enables support for inline highlighting
homepage
repositoryhttps://github.com/phoenixr-codes/mdbook-inline-highlighting
max_upload_size
id999169
size65,908
Jonas (phoenixr-codes)

documentation

README

mdbook-inline-highlighting

Installation

cargo install mdbook-inline-highlighting

Usage

[preprocessors.inline-highlighting]

default-language = "js"
# Enforce JavaScript syntax highlighting when no language is specified. When this
# value is absent no syntax highlighting is applied unless explictly specified.

In one of your chapters, you can write something like this:

This means you can use something like `[py] lambda x: x % 2 == 0` as an argument
for the `[none] accumulate` function. JavaScript has arrow functions which work
the same way. The equivalent would be `(x) => x % 2 == 0`.
  • [py] lambda x: x % 2 == 0 overrides the default js
  • [none] accumulate ignores the default js
  • (x) => x % 2 == 0 uses the default js implicitly

Note that each inline code must have the following syntax: [LANGUAGE] TEXT with the space beeing mendatory. Inline codes beginning with a backslash will remove it and keep the rest as is so \[py] if would result in [py] if.

This preprocessor always uses the same version of highlight.js that is used for code blocks.

Demo

After cloning this repository and installing the crate, navigate to the test_book directory and run mdbook serve to see the example above in action.

Commit count: 2

cargo fmt