Skip to content

Commit 8b6a9df

Browse files
committed
Add support for icon=false in typst callout
1 parent 091f575 commit 8b6a9df

File tree

4 files changed

+61
-8
lines changed

4 files changed

+61
-8
lines changed

dev-docs/feature-format-matrix/qmd-files/callout/no-icon.qmd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
---
22
title: Callout with no icon
33
format:
4-
html:
4+
html:
55
quality: 0
66
comment: Title is a offset a little too far down
7+
typst:
8+
quality: 1
79
---
810

911
::: {.callout-note icon="false"}

src/resources/filters/customnodes/callout.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,26 +276,26 @@ function _callout_main()
276276
end
277277
end
278278
if callout.attr.identifier == "" then
279-
return _quarto.format.typst.function_call("callout", {
279+
return _quarto.format.typst.function_call("callout", {
280280
{ "body", _quarto.format.typst.as_typst_content(callout.content) },
281281
{ "title", _quarto.format.typst.as_typst_content(
282282
(not quarto.utils.is_empty_node(callout.title) and callout.title) or
283283
pandoc.Plain(_quarto.modules.callouts.displayName(callout.type))
284284
)},
285285
{ "background_color", pandoc.RawInline("typst", background_color) },
286286
{ "icon_color", pandoc.RawInline("typst", icon_color) },
287-
{ "icon", pandoc.RawInline("typst", "" .. icon .. "()")},
287+
{ "icon", pandoc.RawInline("typst", callout.icon == false and "none" or ("" .. icon .. "()"))},
288288
{ "body_background_color", pandoc.RawInline("typst", body_background_color)}
289289
})
290290
end
291291

292-
local typst_callout = _quarto.format.typst.function_call("callout", {
292+
local typst_callout = _quarto.format.typst.function_call("callout", {
293293
{ "body", _quarto.format.typst.as_typst_content(callout.content) },
294294
{ "title", _quarto.format.typst.as_typst_content(callout.title, "inlines")
295295
},
296296
{ "background_color", pandoc.RawInline("typst", background_color) },
297297
{ "icon_color", pandoc.RawInline("typst", icon_color) },
298-
{ "icon", pandoc.RawInline("typst", "" .. icon .. "()")},
298+
{ "icon", pandoc.RawInline("typst", callout.icon == false and "none" or ("" .. icon .. "()"))},
299299
{ "body_background_color", pandoc.RawInline("typst", body_background_color)}
300300
})
301301

src/resources/formats/typst/pandoc/quarto/definitions.typ

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@
152152
width: 100%,
153153
below: 0pt,
154154
block(
155-
fill: background_color,
156-
width: 100%,
157-
inset: 8pt)[#text(icon_color, weight: 900)[#icon] #title]) +
155+
fill: background_color,
156+
width: 100%,
157+
inset: 8pt)[#if icon != none [#text(icon_color, weight: 900)[#icon] ]#title]) +
158158
if(body != []){
159159
block(
160160
inset: 1pt,
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
title: Callouts with icon=false
3+
format: typst
4+
keep-typ: true
5+
_quarto:
6+
tests:
7+
typst:
8+
ensureTypstFileRegexMatches:
9+
-
10+
# we do one big regex to be sure to match in order
11+
- '<no-icon-notes>[\s\S]+\#callout\([\s\S]+icon:\s*none[\s\S]+<no-icon-warnings>[\s\S]+\#callout\([\s\S]+icon:\s*none[\s\S]+<no-icon-tip>[\s\S]+\#callout\([\s\S]+icon:\s*none[\s\S]+<with-icon-important>[\s\S]+\#callout\([\s\S]+icon:\s*fa-'
12+
---
13+
14+
## Note Callouts with icon=false {#no-icon-notes}
15+
16+
::: {.callout-note icon="false"}
17+
18+
## Note without icon
19+
20+
This is a note callout without an icon.
21+
22+
:::
23+
24+
## Warnings Callouts with icon=false {#no-icon-warnings}
25+
26+
::: {.callout-warning icon=false}
27+
28+
## Warning without icon
29+
30+
This is a warning callout without an icon.
31+
32+
:::
33+
34+
## Tip Callouts with icon=false {#no-icon-tip}
35+
36+
37+
::: {.callout-tip icon="false"}
38+
39+
A tip without a title and without an icon.
40+
41+
:::
42+
43+
## Regular callout with icon {#with-icon-important}
44+
45+
::: {.callout-important}
46+
47+
## Important with icon
48+
49+
This callout should have an icon (default behavior).
50+
51+
:::

0 commit comments

Comments
 (0)