Created
January 9, 2025 02:05
-
-
Save emisjerry/27220ed6f96d292d189971fc92e04be1 to your computer and use it in GitHub Desktop.
obsidian-callout.lua filter for Pandoc to convert Obsidian callout into pandoc fenced divs
This file contains 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
local stringify = (require "pandoc.utils").stringify | |
function BlockQuote (el) | |
start = el.content[1] | |
if (start.t == "Para" and start.content[1].t == "Str" and | |
start.content[1].text:match("^%[!%w+%][-+]?$")) then | |
_, _, ctype = start.content[1].text:find("%[!(%w+)%]") | |
el.content:remove(1) | |
start.content:remove(1) | |
div = pandoc.Div(el.content, {class = "callout"}) | |
div.attributes["data-callout"] = ctype:lower() | |
div.attributes["title"] = stringify(start.content):gsub("^ ", "") | |
return div | |
else | |
return el | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment