Skip to content
Snippets Groups Projects
Commit 847076ed authored by Gilquin's avatar Gilquin
Browse files

feat: define custom Quarto callout

Add lua filter to define custom Quarto callout, reference:
https://github.com/quarto-dev/quarto-cli/issues/844#issuecomment-1653419884
parent 9e84c706
No related branches found
No related tags found
1 merge request!9fix: correct code formatting and warnings
title: Callout exercise
author: Christophe Dervieux (https://github.com/quarto-dev/quarto-cli/issues/844#issuecomment-1653419884)
version: 1.0.0
quarto-required: ">=1.3.0"
contributes:
filters:
- callout-exercise.lua
function Div(div)
-- process exercise
if div.classes:includes("callout-exercise") then
-- default title
local title = "Exercise"
-- Use first element of div as title if this is a header
if div.content[1] ~= nil and div.content[1].t == "Header" then
title = pandoc.utils.stringify(div.content[1])
div.content:remove(1)
end
-- return a callout instead of the Div
return quarto.Callout({
type = "exercise",
content = div,
title = title,
collapse = nil
})
end
end
<svg width="15" height="15" xmlns="http://www.w3.org/2000/svg"><!--!Font Awesome Free 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="m14.587 4.16-1.35 1.35a.353.353 0 0 1-.5 0L9.485 2.258a.353.353 0 0 1 0-.496L10.838.41a1.41 1.41 0 0 1 1.99 0l1.759 1.76a1.404 1.404 0 0 1 0 1.99zM8.325 2.923.63 10.616l-.62 3.56a.705.705 0 0 0 .815.814l3.558-.626 7.696-7.692a.353.353 0 0 0 0-.498L8.828 2.922a.356.356 0 0 0-.501 0zM3.633 9.955a.408.408 0 0 1 0-.58l4.514-4.51a.408.408 0 0 1 .579 0 .408.408 0 0 1 0 .578l-4.51 4.512a.408.408 0 0 1-.581 0zM2.577 12.42h1.407v1.064l-1.89.33-.912-.91.331-1.89h1.065z" style="fill:#ac00e6;fill-opacity:1;stroke-width:.0293002"/></svg>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment