mdbook preprocessor to add typst support
cargo install --git https://github.com/duskmoon314/mdbook-typst
# OR
git clone https://github.com/duskmoon314/mdbook-typst.git
cargo build --release
Add the following to your book.toml
:
[preprocessor.typst]
# If installed via cargo build
command = "/path/to/mdbook-typst"
Add css to control the style of the typst block:
/* css/typst.css as an example */
.typst-wrapper {
display: flex;
justify-content: center;
}
.typst-doc {
transform: scale(1.75);
}
Add the following to your book.toml
:
[output.html]
additional-css = ["css/typst.css"]
This preprocessor will convert all code blocks with the language typst
to a
<div>
with the class typst-wrapper
and a <svg>
with the class typst-doc
inside.
Say you have the following code block in your markdown:
hello
```typst
y = f(x)
```
world
This preprocessor will first change it to:
hello
```typst
+ #set page(width:auto, height:auto, margin:0.5em)
y = f(x)
```
world
Then preprocessor will convert it to:
hello
<div class="typst-wrapper">
<svg class="typst-doc" ...></svg>
</div>
world
- Integrate
typst
in code instead of usingstd::process::Commend
- Allow user to configure the preambles through
book.toml