Skip to content

Instantly share code, notes, and snippets.

@emisjerry
Created January 9, 2025 02:05
Show Gist options
  • Save emisjerry/27220ed6f96d292d189971fc92e04be1 to your computer and use it in GitHub Desktop.
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
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