Last active
September 3, 2024 06:20
-
-
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
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 | |
-- 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
got this error
lua:24: <eof> expected near 'end'
which went away after removing the last two lines with the two extraend
s