docs(presets): rewrite math rendering section for --katex default
This commit is contained in:
parent
8049730803
commit
6f53159d7b
1 changed files with 24 additions and 28 deletions
|
|
@ -183,8 +183,8 @@ override individual fields by passing a table instead: >lua
|
||||||
`latex` latexmk -pdf → PDF (with clean support)
|
`latex` latexmk -pdf → PDF (with clean support)
|
||||||
`pdflatex` pdflatex → PDF (single pass, no latexmk)
|
`pdflatex` pdflatex → PDF (single pass, no latexmk)
|
||||||
`tectonic` tectonic → PDF (Rust-based LaTeX engine)
|
`tectonic` tectonic → PDF (Rust-based LaTeX engine)
|
||||||
`markdown` pandoc → HTML (standalone, embedded)
|
`markdown` pandoc → HTML (standalone, KaTeX math)
|
||||||
`github` pandoc → HTML (GitHub-styled, `-f gfm` input)
|
`github` pandoc → HTML (GitHub-styled, `-f gfm`, KaTeX math)
|
||||||
`asciidoctor` asciidoctor → HTML (AsciiDoc with SSE reload)
|
`asciidoctor` asciidoctor → HTML (AsciiDoc with SSE reload)
|
||||||
`plantuml` plantuml → SVG (UML diagrams, `.puml`)
|
`plantuml` plantuml → SVG (UML diagrams, `.puml`)
|
||||||
`mermaid` mmdc → SVG (Mermaid diagrams, `.mmd`)
|
`mermaid` mmdc → SVG (Mermaid diagrams, `.mmd`)
|
||||||
|
|
@ -193,40 +193,36 @@ override individual fields by passing a table instead: >lua
|
||||||
Math rendering (pandoc presets): ~
|
Math rendering (pandoc presets): ~
|
||||||
*preview-math*
|
*preview-math*
|
||||||
|
|
||||||
The `markdown` and `github` presets use `--mathml` by default, which converts
|
The `markdown` and `github` presets use `--katex` by default, which inserts a
|
||||||
TeX math to native MathML markup rendered by the browser. This is the only
|
`<script>` tag that loads KaTeX from a CDN at view time. The browser fetches
|
||||||
math option compatible with `--embed-resources` (self-contained HTML).
|
the assets once and caches them, so math renders instantly on subsequent loads.
|
||||||
|
Requires internet on first view.
|
||||||
|
|
||||||
`--katex` and `--mathjax` load fonts and JavaScript from a CDN. With
|
For offline use, swap in `--mathml` via `extra_args`. MathML is rendered
|
||||||
`--embed-resources`, pandoc inlines these dependencies — KaTeX adds ~15s of
|
natively by the browser with no external dependencies: >lua
|
||||||
compile time and ~1.7MB to the output; MathJax fails entirely because it
|
|
||||||
loads modules dynamically at runtime (pandoc/pandoc#682).
|
|
||||||
|
|
||||||
KaTeX via `extra_args` (simple, slow — self-contained output): >lua
|
|
||||||
|
|
||||||
vim.g.preview = {
|
vim.g.preview = {
|
||||||
github = { extra_args = { '--katex' } },
|
github = { extra_args = { '--mathml' } },
|
||||||
}
|
}
|
||||||
<
|
<
|
||||||
|
|
||||||
KaTeX via `args` override (fast — requires internet): >lua
|
Note: pandoc's math flags (`--katex`, `--mathml`, `--mathjax`) are mutually
|
||||||
|
exclusive — last flag wins. Adding `--mathml` via `extra_args` (which is
|
||||||
|
appended after `args`) overrides `--katex`.
|
||||||
|
|
||||||
|
Self-contained output with `--embed-resources`: >lua
|
||||||
|
|
||||||
vim.g.preview = {
|
vim.g.preview = {
|
||||||
github = {
|
github = { extra_args = { '--embed-resources' } },
|
||||||
args = function(ctx)
|
}
|
||||||
return {
|
<
|
||||||
'-f',
|
|
||||||
'gfm',
|
This inlines all external resources into the HTML. With `--katex` this adds
|
||||||
ctx.file,
|
~15s of compile time per save (pandoc fetches KaTeX from the CDN during
|
||||||
'-s',
|
compilation). Pair with `--mathml` to avoid the penalty: >lua
|
||||||
'--katex',
|
|
||||||
'--css',
|
vim.g.preview = {
|
||||||
'https://cdn.jsdelivr.net/gh/pixelbrackets/gfm-stylesheet@master/dist/gfm.css',
|
github = { extra_args = { '--embed-resources', '--mathml' } },
|
||||||
'-o',
|
|
||||||
ctx.output,
|
|
||||||
}
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
<
|
<
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue