Last active
March 17, 2023 11:44
-
-
Save vdavez/30be043550d0cd811284b94195f98c79 to your computer and use it in GitHub Desktop.
Shortcodes and Pandoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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