Commit 0ab290d7 authored by Felix Hilsky's avatar Felix Hilsky
Browse files

pandoc filter for gitlab flavored md

necessary if you want to convert markdown written for gitlab to pdf with pandoc
pandoc is the only way I know that works programmatically and locally to convert markdown to pdf and some people might want to get pdfs instead of markdown files, especially those with a lot of math
The math with $`...`$ is the problem. gitlab needs it and LaTeX chokes on the
parent 5b91f364
-- For converting the markdown files to pdf, you can use
-- the Firefox Extension "Gitlab Markdown Viewer" and the "print to pdf"
-- function of Firefox
-- or
-- you can use pandoc with this filter and lualatex as the engine like so:
-- pandoc --pdf-engine lualatex --lua-filter .maindir/scripts/pandoc-gitlab-math.lua -o out.pdf
-- This is a small part of the complete gitlab-flavored markdown to pdf via pandoc scheme by
function Math(el)
if el.mathtype == "InlineMath" then
if el.text:sub(1,1) == '`' and el.text:sub(#el.text) == '`' then
local text = el.text:sub(2,#el.text-1)
return pandoc.Math(el.mathtype, text)
local cont =
return { pandoc.Str("$") } .. cont.blocks[1].content .. { pandoc.Str("$") }
function CodeBlock(el)
if el.classes[1] == "math" then
return pandoc.Para({ pandoc.Math("DisplayMath", el.text) })
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment