refactor(presets): use --katex instead of --embed-resources --mathml

Problem: `--embed-resources` with `--mathml` caused pandoc to inline all
assets at compile time, adding ~15s per save for KaTeX-heavy documents.

Solution: Default to `--katex`, which inserts a CDN `<script>` tag and
defers rendering to the browser. Users can opt into `--embed-resources`
or `--mathml` via `extra_args`.
This commit is contained in:
Barrett Ruth 2026-03-06 14:26:09 -05:00
parent e513fc57d1
commit 8049730803
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
2 changed files with 6 additions and 8 deletions

View file

@ -224,7 +224,7 @@ M.markdown = {
ft = 'markdown', ft = 'markdown',
cmd = { 'pandoc' }, cmd = { 'pandoc' },
args = function(ctx) args = function(ctx)
return { ctx.file, '-s', '--embed-resources', '--mathml', '-o', ctx.output } return { ctx.file, '-s', '--katex', '-o', ctx.output }
end, end,
output = function(ctx) output = function(ctx)
return (ctx.file:gsub('%.md$', '.html')) return (ctx.file:gsub('%.md$', '.html'))
@ -249,8 +249,7 @@ M.github = {
'gfm', 'gfm',
ctx.file, ctx.file,
'-s', '-s',
'--embed-resources', '--katex',
'--mathml',
'--css', '--css',
'https://cdn.jsdelivr.net/gh/pixelbrackets/gfm-stylesheet@master/dist/gfm.css', 'https://cdn.jsdelivr.net/gh/pixelbrackets/gfm-stylesheet@master/dist/gfm.css',
'-o', '-o',

View file

@ -294,11 +294,11 @@ describe('presets', function()
assert.are.same({ 'pandoc' }, presets.markdown.cmd) assert.are.same({ 'pandoc' }, presets.markdown.cmd)
end) end)
it('returns args with standalone, embed-resources, and mathml flags', function() it('returns args with standalone and katex flags', function()
local args = presets.markdown.args(md_ctx) local args = presets.markdown.args(md_ctx)
assert.is_table(args) assert.is_table(args)
assert.are.same( assert.are.same(
{ '/tmp/document.md', '-s', '--embed-resources', '--mathml', '-o', '/tmp/document.html' }, { '/tmp/document.md', '-s', '--katex', '-o', '/tmp/document.html' },
args args
) )
end) end)
@ -382,7 +382,7 @@ describe('presets', function()
assert.are.same({ 'pandoc' }, presets.github.cmd) assert.are.same({ 'pandoc' }, presets.github.cmd)
end) end)
it('returns args with standalone, embed-resources, mathml, and css flags', function() it('returns args with standalone, katex, and css flags', function()
local args = presets.github.args(md_ctx) local args = presets.github.args(md_ctx)
assert.is_table(args) assert.is_table(args)
assert.are.same({ assert.are.same({
@ -390,8 +390,7 @@ describe('presets', function()
'gfm', 'gfm',
'/tmp/document.md', '/tmp/document.md',
'-s', '-s',
'--embed-resources', '--katex',
'--mathml',
'--css', '--css',
'https://cdn.jsdelivr.net/gh/pixelbrackets/gfm-stylesheet@master/dist/gfm.css', 'https://cdn.jsdelivr.net/gh/pixelbrackets/gfm-stylesheet@master/dist/gfm.css',
'-o', '-o',