diff --git a/_extensions/callout-exercise/_extension.yml b/_extensions/callout-exercise/_extension.yml new file mode 100644 index 0000000000000000000000000000000000000000..271461555d9dbf03071710a4a57a7cfdf90cdaa1 --- /dev/null +++ b/_extensions/callout-exercise/_extension.yml @@ -0,0 +1,7 @@ +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 diff --git a/_extensions/callout-exercise/callout-exercise.lua b/_extensions/callout-exercise/callout-exercise.lua new file mode 100644 index 0000000000000000000000000000000000000000..827ca3676809f3590335cbf40472555f38a5c8e9 --- /dev/null +++ b/_extensions/callout-exercise/callout-exercise.lua @@ -0,0 +1,19 @@ +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 diff --git a/_extensions/callout-exercise/exercise-icon.svg b/_extensions/callout-exercise/exercise-icon.svg new file mode 100644 index 0000000000000000000000000000000000000000..3db1adab5fbf2eb8ff6f67dd23985d48e390e45e --- /dev/null +++ b/_extensions/callout-exercise/exercise-icon.svg @@ -0,0 +1 @@ +<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