Skip to content

Commit f3e5079

Browse files
committed
Fix GFM callout rendering crash with empty content (#13603)
The GFM callout renderer would crash with internal_error() when rendering callouts that had a title but no body content, because it didn't handle the case where callout.content is nil. This fix applies the same nil-safe pattern used by other format renderers (EPUB, RevealJS): default to empty Blocks when content is nil.
1 parent be6bcd2 commit f3e5079

File tree

3 files changed

+48
-3
lines changed

3 files changed

+48
-3
lines changed

news/changelog-1.9.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ All changes included in 1.9:
1717
### `gfm`
1818

1919
- ([#13421](https://github.com/quarto-dev/quarto-cli/issues/13421)): Do not word-wrap titles in header.
20+
- ([#13603](https://github.com/quarto-dev/quarto-cli/issues/13603)): Fix callouts with title but no body content causing fatal error when rendering to GitHub Flavored Markdown.
2021

2122
### `html`
2223

src/resources/filters/customnodes/callout.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,12 @@ function _callout_main()
207207
if tt ~= "nil" then
208208
result:insert(pandoc.Header(3, quarto.utils.as_inlines(callout.title)))
209209
end
210-
local ct = pandoc.utils.type(callout.content)
210+
local content = callout.content or pandoc.Blocks({})
211+
local ct = pandoc.utils.type(content)
211212
if ct == "Block" then
212-
result:insert(callout.content)
213+
result:insert(content)
213214
elseif ct == "Blocks" then
214-
result:extend(callout.content)
215+
result:extend(content)
215216
else
216217
internal_error()
217218
end
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: "Callout with title but no body (#13603)"
3+
format: gfm
4+
_quarto:
5+
tests:
6+
gfm:
7+
ensureFileRegexMatches:
8+
-
9+
# Should render both callouts with proper GFM structure
10+
- '\[!TIP\]'
11+
- '\[!NOTE\]'
12+
# Both should be in blockquotes with titles
13+
- '>\s*###\s*Title Only'
14+
- '>\s*###\s*With Body'
15+
# The second callout should have content
16+
- '>\s*Content here'
17+
- []
18+
noErrors: true
19+
---
20+
21+
## Test callout with title but no body
22+
23+
This tests the fix for issue #13603: callouts with a title but no body content
24+
should render to GitHub Flavored Markdown without crashing.
25+
26+
The issue occurred because the GFM renderer didn't handle the case where
27+
`callout.content` is nil/empty.
28+
29+
::: {.callout-tip}
30+
31+
## Title Only
32+
33+
:::
34+
35+
## Callout with title and body (for comparison)
36+
37+
::: {.callout-note}
38+
39+
## With Body
40+
41+
Content here.
42+
43+
:::

0 commit comments

Comments
 (0)