Skip to content

Commit e9f6d2d

Browse files
claude: Add comprehensive margin citation tests for Typst
Tests cover various citation features with margin placement: - Combined citations and sidenotes with vertical stacking - Bare/in-text citations, bibliography styles, link-citations - Citeproc mode (pre-rendered bibliography in margins) - Prefix/suffix handling (citeproc preserves prefixes, native drops them) - Author suppression, suppress-bibliography, complex syntax All tests updated to expect #note() + form: "full" pattern. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 3fb398e commit e9f6d2d

10 files changed

Lines changed: 376 additions & 0 deletions
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
title: "Combined Margin Citations and Sidenotes"
3+
papersize: us-letter
4+
citation-location: margin
5+
reference-location: margin
6+
bibliography: borges-refs.bib
7+
format:
8+
html: default
9+
typst:
10+
keep-typ: true
11+
_quarto:
12+
tests:
13+
typst:
14+
ensureTypstFileRegexMatches:
15+
# Should have both margin citations (note) and sidenotes (column-sidenote)
16+
- ['#note\(', 'column-sidenote', 'form: "full"']
17+
- []
18+
ensurePdfRegexMatches:
19+
- ['COMBINED-TEST', 'SIDENOTE-CONTENT', 'Borges', 'bifurcan']
20+
- []
21+
ensurePdfTextPositions:
22+
- # Both citation and sidenote should be in margin
23+
- subject: "bifurcan"
24+
relation: rightOf
25+
object: "COMBINED-TEST"
26+
- subject: "SIDENOTE-CONTENT"
27+
relation: rightOf
28+
object: "explains"
29+
# Vertical stacking: citations and sidenotes alternate
30+
- subject: "SIDENOTE-CONTENT"
31+
relation: below
32+
object: "bifurcan"
33+
- subject: "rosa"
34+
relation: below
35+
object: "SIDENOTE-CONTENT"
36+
- subject: "Another sidenote"
37+
relation: below
38+
object: "rosa"
39+
- subject: "Calvino"
40+
relation: below
41+
object: "Another sidenote"
42+
- []
43+
noErrors: default
44+
---
45+
46+
# Testing Combined Margin Citations and Sidenotes
47+
48+
COMBINED-TEST: This paragraph has a margin citation [@borges1941library] that should appear in the margin.
49+
50+
This paragraph explains^[SIDENOTE-CONTENT: This is a sidenote that should also appear in the margin] a concept with a footnote.
51+
52+
When both `citation-location: margin` and `reference-location: margin` are set, citations and footnotes should coexist in the margin without conflicts.
53+
54+
Here's another citation [@eco1980name] followed by another footnote^[Another sidenote in the margin].
55+
56+
The margin should handle the interleaving of citations and sidenotes gracefully, avoiding overlaps [@calvino1979winter].
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
title: "Margin Citation with Bare Citations"
3+
papersize: us-letter
4+
citation-location: margin
5+
bibliography: borges-refs.bib
6+
format:
7+
html: default
8+
typst:
9+
keep-typ: true
10+
_quarto:
11+
tests:
12+
typst:
13+
ensureTypstFileRegexMatches:
14+
# Margin citations emit note() with cite(form: "full") directly
15+
- ['#note\(', 'form: "full"']
16+
- []
17+
ensurePdfRegexMatches:
18+
# Bare citations should render author-date inline with full in margin
19+
- ['BARE-MARKER', 'Borges', '1941']
20+
- []
21+
ensurePdfTextPositions:
22+
- # Full citation in margin - "bifurcan" is unique to borges1941library booktitle
23+
- subject: "bifurcan"
24+
relation: rightOf
25+
object: "BARE-MARKER"
26+
- []
27+
noErrors: default
28+
---
29+
30+
# Testing Bare (In-Text) Citations in Margins
31+
32+
BARE-MARKER: According to @borges1941library, the Library is infinite.
33+
34+
The story was later collected by @borges1944ficciones in his famous anthology.
35+
36+
Both @eco1980name and @calvino1979winter were influenced by Borges.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
title: "Margin Citation with Bibliography Style"
3+
papersize: us-letter
4+
citation-location: margin
5+
bibliography: borges-refs.bib
6+
bibliographystyle: apa
7+
format:
8+
html: default
9+
typst:
10+
keep-typ: true
11+
_quarto:
12+
tests:
13+
typst:
14+
ensureTypstFileRegexMatches:
15+
# Margin citations emit note() with cite(form: "full") and bibliography style
16+
- ['#note\(', 'form: "full"', 'style:\s*"apa"']
17+
- []
18+
ensurePdfRegexMatches:
19+
- ['BIBSTYLE-TEST', 'Borges']
20+
- []
21+
ensurePdfTextPositions:
22+
- # "La biblioteca" is unique to borges1941library title
23+
- subject: "La biblioteca"
24+
relation: rightOf
25+
object: "BIBSTYLE-TEST"
26+
- []
27+
noErrors: default
28+
---
29+
30+
# Testing Bibliography Style with Margin Citations
31+
32+
BIBSTYLE-TEST: With `bibliographystyle: apa`, citations should follow APA format [@borges1941library].
33+
34+
The full citation in the margin should also use APA styling [@eco1980name].
35+
36+
Multiple citations should maintain consistent style [@calvino1979winter; @casares1940morel].
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
title: "Margin Citation with Citeproc Enabled"
3+
papersize: us-letter
4+
citation-location: margin
5+
bibliography: borges-refs.bib
6+
citeproc: true
7+
format:
8+
html: default
9+
typst:
10+
keep-typ: true
11+
_quarto:
12+
tests:
13+
typst:
14+
ensureTypstFileRegexMatches:
15+
# With citeproc, margin notes contain pre-rendered bibliography text (not #cite calls)
16+
- ['#note\(', 'Borges.*1941', 'Bifurcan']
17+
- ['#cite\(<[^>]+>, form: "full"\)'] # Should NOT have native Typst cite calls
18+
ensurePdfRegexMatches:
19+
- ['CITEPROC-MARKER', 'Borges', 'Babel']
20+
- []
21+
ensurePdfTextPositions:
22+
- # Citation in margin - "Bifurcan" is unique to borges1941library booktitle (citeproc uses title case)
23+
- subject: "Bifurcan"
24+
relation: rightOf
25+
object: "CITEPROC-MARKER"
26+
- []
27+
noErrors: default
28+
---
29+
30+
# Testing Citeproc Mode with Margin Citations
31+
32+
CITEPROC-MARKER: With `citeproc: true`, Pandoc handles citation processing instead of Typst's native system [@borges1941library].
33+
34+
This affects how citations are rendered [@borges1944ficciones].
35+
36+
Multiple works can be cited together [@eco1980name; @calvino1979winter].
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
title: "Margin Citation Complex Syntax"
3+
papersize: us-letter
4+
citation-location: margin
5+
bibliography: borges-refs.bib
6+
format:
7+
html: default
8+
typst:
9+
keep-typ: true
10+
_quarto:
11+
tests:
12+
typst:
13+
ensureTypstFileRegexMatches:
14+
# Margin citations emit note() with cite(form: "full") directly
15+
- ['#note\(', 'form: "full"']
16+
- []
17+
ensurePdfRegexMatches:
18+
# Check complex citation elements appear
19+
- ['COMPLEX-TEST', 'Borges', 'Eco', 'Calvino']
20+
- []
21+
noErrors: default
22+
---
23+
24+
# Testing Complex Citation Syntax in Margins
25+
26+
COMPLEX-TEST: The literary tradition spans multiple works [see @borges1941library, pp. 33-35; also @eco1980name, ch. 1; and @calvino1979winter for related themes].
27+
28+
Multiple locator types: The key passage [@borges1944ficciones, sec. 2, para. 3] explains the concept.
29+
30+
Combining prefix, multiple citations, and locators [for an overview, see @kurd1933hexagonal, p. 100; @quain1936labyrinth, ch. 5-7].
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
title: "Margin Citation with Link Citations"
3+
papersize: us-letter
4+
citation-location: margin
5+
bibliography: borges-refs.bib
6+
link-citations: true
7+
format:
8+
html: default
9+
typst:
10+
keep-typ: true
11+
_quarto:
12+
tests:
13+
typst:
14+
ensureTypstFileRegexMatches:
15+
# Margin citations emit note() with cite(form: "full") directly
16+
- ['#note\(', 'form: "full"']
17+
- []
18+
ensurePdfRegexMatches:
19+
- ['LINK-TEST', 'Borges']
20+
- []
21+
noErrors: default
22+
---
23+
24+
# Testing Link Citations with Margin Citations
25+
26+
LINK-TEST: With `link-citations: true`, inline citations should be hyperlinked to the bibliography [@borges1941library].
27+
28+
The margin note should also contain the full citation [@eco1980name].
29+
30+
This tests whether link-citations interacts correctly with margin citation placement [@calvino1979winter].
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
title: "Margin Citation with Prefix and Suffix (Citeproc)"
3+
papersize: us-letter
4+
citation-location: margin
5+
bibliography: borges-refs.bib
6+
citeproc: true
7+
format:
8+
html: default
9+
typst:
10+
keep-typ: true
11+
_quarto:
12+
tests:
13+
typst:
14+
ensureTypstFileRegexMatches:
15+
# With citeproc, margin notes contain pre-rendered bibliography text (not #cite calls)
16+
- ['#note\(', 'Borges']
17+
- ['#cite\(<[^>]+>, form: "full"\)'] # Should NOT have native Typst cite calls
18+
ensurePdfRegexMatches:
19+
# Citeproc preserves prefix/suffix inline (unlike native Typst which drops prefixes)
20+
- - 'PREFIX-MARKER'
21+
- 'SUFFIX-MARKER'
22+
- 'Borges'
23+
# Prefixes appear inline with author-date citation
24+
- 'see Borges 1941' # prefix "see" preserved
25+
- 'cf\. Eco' # prefix "cf." preserved
26+
- 'see also' # complex prefix preserved
27+
# Suffix appears inline (may be hyphenated across lines)
28+
- 'phasis added' # "em-phasis added" hyphenated
29+
- 'contrasting'
30+
- []
31+
ensurePdfTextPositions:
32+
- # Full citation in margin - "Bifurcan" is unique (citeproc uses title case)
33+
- subject: "Bifurcan"
34+
relation: rightOf
35+
object: "PREFIX-MARKER"
36+
- []
37+
noErrors: default
38+
---
39+
40+
# Testing Citation Prefix and Suffix in Margins
41+
42+
PREFIX-MARKER: As noted by several scholars [see @borges1941library], the Library concept is profound.
43+
44+
SUFFIX-MARKER: The story was revolutionary [@borges1944ficciones, emphasis added].
45+
46+
COMPLEX-MARKER: For background [cf. @eco1980name; but see also @calvino1979winter for a contrasting view].
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
title: "Margin Citation with Prefix and Suffix"
3+
papersize: us-letter
4+
citation-location: margin
5+
bibliography: borges-refs.bib
6+
format:
7+
html: default
8+
typst:
9+
keep-typ: true
10+
_quarto:
11+
tests:
12+
typst:
13+
ensureTypstFileRegexMatches:
14+
# Margin citations emit note() with cite(form: "full") directly
15+
- ['#note\(', 'form: "full"']
16+
- []
17+
ensurePdfRegexMatches:
18+
# Check that suffix text appears (prefix handled separately for margin citations)
19+
- ['PREFIX-MARKER', 'SUFFIX-MARKER', 'emphasis', 'Borges']
20+
- []
21+
ensurePdfTextPositions:
22+
- # Full citation in margin - "bifurcan" is unique to borges1941library booktitle
23+
- subject: "bifurcan"
24+
relation: rightOf
25+
object: "PREFIX-MARKER"
26+
- []
27+
noErrors: default
28+
---
29+
30+
# Testing Citation Prefix and Suffix in Margins
31+
32+
PREFIX-MARKER: As noted by several scholars [see @borges1941library], the Library concept is profound.
33+
34+
SUFFIX-MARKER: The story was revolutionary [@borges1944ficciones, emphasis added].
35+
36+
COMPLEX-MARKER: For background [cf. @eco1980name; but see also @calvino1979winter for a contrasting view].
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: "Margin Citation with Suppress Bibliography"
3+
papersize: us-letter
4+
citation-location: margin
5+
bibliography: borges-refs.bib
6+
suppress-bibliography: true
7+
format:
8+
html: default
9+
typst:
10+
keep-typ: true
11+
_quarto:
12+
tests:
13+
typst:
14+
ensureTypstFileRegexMatches:
15+
# Margin citations emit note() with cite(form: "full") directly
16+
- ['#note\(', 'form: "full"']
17+
- []
18+
ensurePdfRegexMatches:
19+
# Citations should appear but NO bibliography section at end
20+
- ['SUPPRESS-TEST', 'Borges']
21+
# Should NOT have a References/Bibliography heading
22+
- ['References\s*$', 'Bibliography\s*$']
23+
noErrors: default
24+
---
25+
26+
# Testing Suppress Bibliography with Margin Citations
27+
28+
SUPPRESS-TEST: When using margin citations, the full citation appears in the margin [@borges1941library].
29+
30+
Since `suppress-bibliography: true` is set, there should be no bibliography section at the end of the document [@eco1980name].
31+
32+
This is the expected behavior because full citations already appear in the margins [@calvino1979winter].
33+
34+
The document should end here with no bibliography listing.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
title: "Margin Citation with Author Suppression"
3+
papersize: us-letter
4+
citation-location: margin
5+
bibliography: borges-refs.bib
6+
format:
7+
html: default
8+
typst:
9+
keep-typ: true
10+
_quarto:
11+
tests:
12+
typst:
13+
ensureTypstFileRegexMatches:
14+
# Margin citations emit note() with cite(form: "full") directly
15+
- ['#note\(', 'form: "full"']
16+
- []
17+
ensurePdfRegexMatches:
18+
# Author-suppressed should show year only in text, full in margin
19+
- ['SUPPRESSED-MARKER', '1941', 'Borges']
20+
- []
21+
ensurePdfTextPositions:
22+
- # Full citation in margin - "bifurcan" is unique to borges1941library booktitle
23+
- subject: "bifurcan"
24+
relation: rightOf
25+
object: "SUPPRESSED-MARKER"
26+
- []
27+
noErrors: default
28+
---
29+
30+
# Testing Author-Suppressed Citations in Margins
31+
32+
SUPPRESSED-MARKER: Borges [-@borges1941library] first published the story in 1941.
33+
34+
As noted by Borges [-@borges1944ficciones], the collection brought together his finest work.
35+
36+
The technique differs from a regular citation [@eco1980name] which shows the author.

0 commit comments

Comments
 (0)