diff --git a/_quarto.yml b/_quarto.yml index d774272..ae0fc90 100644 --- a/_quarto.yml +++ b/_quarto.yml @@ -32,3 +32,4 @@ format: filters: - filters/ltr-spans.lua - filters/typst-linebreaks.lua + - filters/summary-box.lua diff --git a/filters/summary-box.lua b/filters/summary-box.lua new file mode 100644 index 0000000..8eebfda --- /dev/null +++ b/filters/summary-box.lua @@ -0,0 +1,24 @@ +-- Render ::: {.summary-box} as a Typst block matching HTML table chrome. +function Div(el) + if not el.classes:includes("summary-box") then + return nil + end + if not quarto.doc.is_format("typst") then + return nil + end + + local inner = pandoc.write(pandoc.Pandoc(el.content), "typst") + inner = inner:gsub("^%s+", ""):gsub("%s+$", "") + local typst = string.format([[ +#block( + width: 100%%, + inset: 12pt, + radius: 8pt, + stroke: 0.5pt + rgb("#d0d7de"), + fill: rgb("#f6f8fa"), +)[ +%s +] +]], inner) + return pandoc.RawBlock("typst", typst) +end diff --git a/styles/report.css b/styles/report.css index 50416d7..786256c 100644 --- a/styles/report.css +++ b/styles/report.css @@ -114,6 +114,31 @@ table .ltr { display: inline-block; } +/* Summary / callout box — same chrome as tables */ +.summary-box { + border: 1px solid var(--stroke); + border-radius: 8px; + background: var(--fill); + padding: 0.85rem 1.1rem; + margin: 1rem 0; + color: var(--text); +} + +.summary-box > :first-child { + margin-top: 0; +} + +.summary-box > :last-child { + margin-bottom: 0; +} + +.summary-box [dir="ltr"], +.summary-box .ltr { + direction: ltr; + unicode-bidi: isolate; + display: inline-block; +} + code { direction: ltr; unicode-bidi: embed;