-
Notifications
You must be signed in to change notification settings - Fork 10
Common Extensions
Max Heller edited this page Nov 23, 2025
·
4 revisions
-
mdbook-bib-
Restrict
mdbook-bibto run only for the HTML backend (see Locking a preprocessor dependency to a renderer):[preprocessor.mdbook-bib] renderers = ["html"]
-
Transform
mdbook-bib's citations to PandocCiteAST nodes using a Pandoc Lua filter:Note that
mdbook-pandocdoes not pass markdown topandoc, but rather Pandoc's native AST format. This means that instead of translating{{#cite key}}and@@keyto[@key], we need to translate them to PandocCiteAST nodes, and we do this in the form of a Pandoc filter. Inbook.toml, we tell Pandoc to use this filter, and afterwards runciteprocto process the citations.mdbook-bib.luafunction Inlines (inlines) for i = 1, #inlines do e = inlines[i] -- Replace {{#cite key}} is_bracketed_citation = e.t == 'Str' and string.sub(e.text, 1, 8) == '{{#cite ' and string.sub(e.text, #e.text-1, -1) == '}}' if is_bracketed_citation then cite = string.sub(e.text, 9, #e.text-2) inlines[i] = pandoc.Cite({pandoc.Str(cite)}, {pandoc.Citation(cite, "AuthorInText")}) end -- Replace @@key is_citation = e.t == 'Str' and string.sub(e.text, 1, 2) == '@@' if is_citation then cite = string.sub(e.text, 3, -1) inlines[i] = pandoc.Cite({pandoc.Str(cite)}, {pandoc.Citation(cite, "AuthorInText")}) end end return inlines end
[output.pandoc.profile.example] filters = ["mdbook-bib.lua", "citeproc"] bibliography = "bib.bib" # replace with path to your bibliography
-
-
mdbook-mermaidUse
mermaid-filter:[output.pandoc.profile.example] filters = ["mermaid-filter"]