Skip to content

Commit 6e5e798

Browse files
committed
Add a test case for the valid callout ID prefix
1 parent 2a2e926 commit 6e5e798

File tree

2 files changed

+48
-8
lines changed

2 files changed

+48
-8
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: "Callout with valid ID prefix"
3+
format:
4+
typst:
5+
keep-typ: true
6+
_quarto:
7+
tests:
8+
typst:
9+
ensureTypstFileRegexMatches:
10+
-
11+
- '#figure\(\[(\r\n?|\n)#block\[(\r\n?|\n)#callout'
12+
- []
13+
printsMessage:
14+
level: INFO
15+
regex: 'WARNING(.*)Callout ID(.*)unknown reference type'
16+
negate: true
17+
noErrors: true
18+
---
19+
20+
## Test callout with valid crossref ID
21+
22+
This tests that callouts with valid ID prefixes (matching known crossref categories)
23+
are properly wrapped in figures for cross-reference support.
24+
25+
::: {#nte-valid .callout-note}
26+
27+
## Note with valid ID
28+
29+
This callout uses `#nte-valid` which has the valid prefix "nte" (for notes).
30+
This should be wrapped in a `figure` for cross-referencing support.
31+
32+
:::
33+
34+
As mentioned in @nte-valid, valid callout IDs should work correctly.
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
---
2-
title: "Callout with invalid ID prefix"
2+
title: "Callout with invalid ID prefix (#13589)"
33
format:
44
typst:
55
keep-typ: true
66
_quarto:
77
tests:
88
typst:
99
ensureTypstFileRegexMatches:
10-
- ['#callout\(']
11-
- []
10+
-
11+
# Should render as plain callout with body parameter
12+
- '#callout\(\s*body:'
13+
-
14+
# Should NOT be wrapped in figure+block structure
15+
- '#figure\(\[(\r\n?|\n)#block\[(\r\n?|\n)#callout'
1216
printsMessage:
1317
level: INFO
1418
regex: 'WARNING(.*)Callout ID ''random-id'' has unknown reference type ''random'''
@@ -17,16 +21,18 @@ _quarto:
1721

1822
## Test callout with invalid crossref ID
1923

20-
This tests that callouts with invalid ID prefixes (not matching any known crossref category)
21-
should render with a warning instead of crashing.
24+
This tests the fix for issue #13589: callouts with invalid ID prefixes
25+
(not matching any known crossref category) should render with a warning
26+
instead of crashing with "attempt to index a nil value".
2227

2328
::: {#random-id .callout-note}
2429

2530
## Note with invalid ID
2631

27-
This callout uses `#random-id` which has an unknown prefix "random".
28-
The valid prefixes are: fig, tbl, lst, nte, wrn, cau, tip, imp, prf, rem, sol.
32+
This callout uses `#random-id` with unknown prefix "random".
2933

30-
This should render successfully with a warning, not crash.
34+
Valid prefixes are: fig, tbl, lst, nte, wrn, cau, tip, imp, prf, rem, sol.
35+
36+
Expected behavior: renders as plain callout (no figure wrapping) with warning.
3137

3238
:::

0 commit comments

Comments
 (0)