I want to extend R Markdown with the following syntactic sugar for acronyms:
The (WHO:: World Health Organization) is an agency of the (UN:: United Nations)
which should be translated to the following raw LaTeX with \nomenclature
The WHO\nomenclature{WHO}{World Health Organization} is an agency of the UN\nomenclature{UN}{United Nations}
and after compilation I would see a glossary page and this text:
The WHO is an agency of the UN
I figured out, that Pandoc has Lua filters, but I'm not a Lua (or Haskel) programmer and It's hard for me to understand where I'm wrong:
– get an entire paragraph from AST
function Para(s)
-- match new syntax: (ACRONYM:: definition)
before, acronym, definition, after = tostring(s):match("(.*)%((.*)::(.-)%)(.*)")
-- if matched
if acronym then
-- interpolate new paragrath string
new = string.format('%s%s\\nomenclature{%s}{%s}%s', before, acronym, acronym, definition, after)
-- return new AST element
return pandoc.read(new)
else
return s
end
end
Unfortunately, I see raw Para
structure in an output PDF.