So I now have this: function RawBlock(el) if el.text:match("%<%!%-%- foo %-%-%>") then content = "foo" return pandoc.Header(2, content) end end There are actually about a dozen such known Markdown comments (e.g. 'foo', 'bar'). Instead of creating multiple files I'd like to have just one that uses a regex and capture group: if el.text:match("%<%!%-%- (%a+) %-%-%>") then I'm just unsure how to refer to the capture in a conditional statement (i.e. "if 'foo' is captured then 'content' = "foo", elsif 'bar' is captured then 'content' = "bar"). On Thu, 14 Jan 2021 at 15:57, Peter Matulis wrote: > Gratitude. This got me going. > > On Thu, 14 Jan 2021 at 13:52, John MacFarlane wrote: > >> >> What you want to do is match on a RawBlock element. >> Something like >> >> function RawBlock(el) >> if el.text:match(" >> > >> > I simply want to convert this into an actual (second-level) MD header: >> > >> > ## blah >> > >> > From what I've read, I would ideally specify an "element" that will be >> > acted upon, but what is a comment considered? Anyway, I think I can >> specify >> > `Pandoc` to mean "check the entire document", and that's what I've done >> > here (I will eventually be iterating through multiple MD files so I >> should >> > really not be doing it like this; please advise!): >> > >> > function Pandoc (value) >> > comment = "" >> > comment = comment:gsub("%<%!%-%- blah %-%-%>", "## blah") >> > return value >> > end >> > >> > I've run the main logic through Lua on the terminal and it works: >> > >> > $ lua >> > Lua 5.3.3 Copyright (C) 1994-2016 Lua.org, PUC-Rio >> >> comment = "" >> >> comment = comment:gsub("%<%!%-%- blah %-%-%>", "## blah") >> >> print (comment) >> > ## blah >> > >> > But I'm failing to integrate it with Pandoc (no change is registered in >> > file.html). It's probably due to my misunderstanding of functions (not a >> > programmer!). >> > >> > TIA. >> > >> > /pm >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups "pandoc-discuss" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> > To view this discussion on the web visit >> https://groups.google.com/d/msgid/pandoc-discuss/CAMxYqzEvRHcFQ1BYsFODC-Bd36%3DLfO-UKcVYPNzR8i8rDZorXw%40mail.gmail.com >> . >> > -- You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CAMxYqzHK6BvhbzE__4__Po%2Bwizq_4b3CZT9q%3D9ZQ1iF9JR-VSg%40mail.gmail.com.