Skip to content

Instantly share code, notes, and snippets.

@danieltomasz
Last active September 3, 2024 06:20
Show Gist options
  • Save danieltomasz/31d298aca2969adaf60d8841b68005e2 to your computer and use it in GitHub Desktop.
Save danieltomasz/31d298aca2969adaf60d8841b68005e2 to your computer and use it in GitHub Desktop.
Lua filter that allows passing obsidian/github callouts as quarto native in quarto >1.3
local stringify = (require "pandoc.utils").stringify
-- idea aken from https://forum.obsidian.md/t/rendering-callouts-similarly-in-pandoc/40020/6 and modified to work with Quarto 1.3
function BlockQuote(el)
local start = el.content[1]
if (start.t == "Para" and start.content[1].t == "Str" and
start.content[1].text:match("^%[!%w+%][-+]?$")) then
local firstline = stringify(start.content[1])
local _, _, ctype = firstline:find("%[!(%w+)%]")
local titlevar =stringify(start.content):match("^%[!%w+%](.-)$")
el.content:remove(1)
-- Create Quarto callout
return quarto.Callout({
type = ctype:lower(),
title = titlevar,
content = el.content
})
else
return el
end
end
end
end
@vanAmsterdam
Copy link

got this error lua:24: <eof> expected near 'end' which went away after removing the last two lines with the two extra ends

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment