obsidian submodule, regenerated page
This commit is contained in:
46
pandoc-filter/obsidian-callouts.lua
Normal file
46
pandoc-filter/obsidian-callouts.lua
Normal file
@ -0,0 +1,46 @@
|
||||
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
|
||||
|
||||
local function has_value(tab, val)
|
||||
for index, value in ipairs(tab) do
|
||||
if value == val then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
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+%](.-)$")
|
||||
if ctype:lower() == "info" then
|
||||
ctype = "note"
|
||||
end
|
||||
if ctype:lower() == "question" then
|
||||
ctype = "warning"
|
||||
end
|
||||
if ctype:lower() == "success" then
|
||||
ctype = "tip"
|
||||
end
|
||||
|
||||
if not has_value({ "note", "warning", "important", "tip", "caution" }, ctype:lower()) then
|
||||
print(ctype + " is no valid quarto-callout. Change or add special case to lua-script.\nForced to 'note'")
|
||||
ctype = "note"
|
||||
end
|
||||
|
||||
el.content:remove(1)
|
||||
-- Create Quarto callout
|
||||
return quarto.Callout({
|
||||
type = ctype:lower(),
|
||||
title = titlevar,
|
||||
content = el.content,
|
||||
})
|
||||
else
|
||||
return el
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user