Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion dev-docs/feature-format-matrix/qmd-files/callout/no-icon.qmd
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
---
title: Callout with no icon
format:
html:
html:
quality: 0
comment: Title is a offset a little too far down
typst:
quality: 1
---

::: {.callout-note icon="false"}
Expand Down
1 change: 1 addition & 0 deletions news/changelog-1.9.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ All changes included in 1.9:
- ([#13362](https://github.com/quarto-dev/quarto-cli/issues/13362)): Remove unused `blockquote` definitions from template.
- ([#13452](https://github.com/quarto-dev/quarto-cli/issues/13452)): Wraps subfigure captions generated by `quarto_super()` in `block` function to avoid emitting `par` elements. (author: @christopherkenny)
- ([#13474](https://github.com/quarto-dev/quarto-cli/issues/13474)): Heading font for title should default to `mainfont`.
- ([#13555](https://github.com/quarto-dev/quarto-cli/issues/13555)): Add support for `icon=false` in callouts when used in `format: typst`.

## Projects

Expand Down
8 changes: 4 additions & 4 deletions src/resources/filters/customnodes/callout.lua
Original file line number Diff line number Diff line change
Expand Up @@ -276,26 +276,26 @@ function _callout_main()
end
end
if callout.attr.identifier == "" then
return _quarto.format.typst.function_call("callout", {
return _quarto.format.typst.function_call("callout", {
{ "body", _quarto.format.typst.as_typst_content(callout.content) },
{ "title", _quarto.format.typst.as_typst_content(
(not quarto.utils.is_empty_node(callout.title) and callout.title) or
pandoc.Plain(_quarto.modules.callouts.displayName(callout.type))
)},
{ "background_color", pandoc.RawInline("typst", background_color) },
{ "icon_color", pandoc.RawInline("typst", icon_color) },
{ "icon", pandoc.RawInline("typst", "" .. icon .. "()")},
{ "icon", pandoc.RawInline("typst", callout.icon == false and "none" or ("" .. icon .. "()"))},
{ "body_background_color", pandoc.RawInline("typst", body_background_color)}
})
end

local typst_callout = _quarto.format.typst.function_call("callout", {
local typst_callout = _quarto.format.typst.function_call("callout", {
{ "body", _quarto.format.typst.as_typst_content(callout.content) },
{ "title", _quarto.format.typst.as_typst_content(callout.title, "inlines")
},
{ "background_color", pandoc.RawInline("typst", background_color) },
{ "icon_color", pandoc.RawInline("typst", icon_color) },
{ "icon", pandoc.RawInline("typst", "" .. icon .. "()")},
{ "icon", pandoc.RawInline("typst", callout.icon == false and "none" or ("" .. icon .. "()"))},
{ "body_background_color", pandoc.RawInline("typst", body_background_color)}
})

Expand Down
25 changes: 16 additions & 9 deletions src/resources/formats/typst/pandoc/quarto/definitions.typ
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,12 @@
// when we cleanup pandoc's emitted code to avoid spaces this will have to change
let old_callout = it.body.children.at(1).body.children.at(1)
let old_title_block = old_callout.body.children.at(0)
let old_title = old_title_block.body.body.children.at(2)
let children = old_title_block.body.body.children
let old_title = if children.len() == 1 {
children.at(0) // no icon: title at index 0
} else {
children.at(1) // with icon: title at index 1
}

// TODO use custom separator if available
let new_title = if empty(old_title) {
Expand All @@ -127,12 +132,14 @@
}

let new_title_block = block_with_new_content(
old_title_block,
old_title_block,
block_with_new_content(
old_title_block.body,
old_title_block.body.body.children.at(0) +
old_title_block.body.body.children.at(1) +
new_title))
old_title_block.body,
if children.len() == 1 {
new_title // no icon: just the title
} else {
children.at(0) + new_title // with icon: preserve icon block + new title
}))

block_with_new_content(old_callout,
block(below: 0pt, new_title_block) +
Expand All @@ -152,9 +159,9 @@
width: 100%,
below: 0pt,
block(
fill: background_color,
width: 100%,
inset: 8pt)[#text(icon_color, weight: 900)[#icon] #title]) +
fill: background_color,
width: 100%,
inset: 8pt)[#if icon != none [#text(icon_color, weight: 900)[#icon] ]#title]) +
if(body != []){
block(
inset: 1pt,
Expand Down
53 changes: 53 additions & 0 deletions tests/docs/smoke-all/typst/callout-no-icon.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
title: Callouts with icon=false
format: typst
keep-typ: true
_quarto:
tests:
typst:
ensureTypstFileRegexMatches:
-
# we do one big regex to be sure to match in order
- '<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-'
---

## Note Callouts with icon=false {#no-icon-notes}

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

## Note without icon

This is a note callout without an icon.

:::

## Warnings Callouts with icon=false {#no-icon-warnings}

::: {.callout-warning icon=false}

## Warning without icon

This is a warning callout without an icon.

:::

## Tip Callouts with icon=false {#no-icon-tip}


::: {#tip-example .callout-tip icon="false"}

A tip without a title and without an icon.

:::

See @tip-example

## Regular callout with icon {#with-icon-important}

::: {.callout-important}

## Important with icon

This callout should have an icon (default behavior).

:::
Loading