-- Translate div class .lead to custo LaTeX environment \ingress{} local function escape_latex(str) local replacements = { ["\\"] = "\\textbackslash{}", ["{"] = "\\{", ["}"] = "\\}", ["$"] = "\\$", ["&"] = "\\&", ["#"] = "\\#", ["_"] = "\\_", ["%"] = "\\%", ["^"] = "\\textasciicircum{}", ["~"] = "\\textasciitilde{}" } return (str:gsub(".", function(c) return replacements[c] or c end)) end function Div(el) if FORMAT:match 'latex' then if el.classes:includes('lead') then local content = pandoc.utils.stringify(el.content) local escaped_content = escape_latex(content) return pandoc.RawBlock('latex', '\\ingress{' .. escaped_content .. '}') end end end