Skip to content

Instantly share code, notes, and snippets.

@vdavez
Last active March 17, 2023 11:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vdavez/30be043550d0cd811284b94195f98c79 to your computer and use it in GitHub Desktop.
Save vdavez/30be043550d0cd811284b94195f98c79 to your computer and use it in GitHub Desktop.
Shortcodes and Pandoc
-- Handles hugo-book's `hint` shortcode and converts into a blockquote
incomment = false
function Para(el)
if el.content[1].text == "{{<" and el.content[3].text == "hint" and el.content[7].text == ">}}"then
incomment = true
hint_type = el.content[5].text
return pandoc.Para(pandoc.Str())
elseif el.content[1].text == "{{<" and el.content[3].text == "/hint" and el.content[5].text == ">}}" then
incomment = false
return pandoc.Para(pandoc.Str())
end
if incomment then
div = pandoc.Div{pandoc.BlockQuote(pandoc.Para(el.content))}
div.classes = {"hint-" .. hint_type}
return div
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment