Skip to content

Commit 51eb979

Browse files
claude: Add edge case tests for Typst margin layout
Add tests for various edge cases: - fullwidth-nested: nested figures inside full-width divs - fullwidth-page-left: .column-page-left extending into inner margin - fullwidth-screen-inset-sides: .column-screen-inset-left/right - fullwidth-screen-sides: .column-screen-left/right - geometry-a4: margin layout on A4 paper - geometry-body-width: user grid overrides (body-width, margin-width) - geometry-legal: margin layout on US Legal paper Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 78e1416 commit 51eb979

7 files changed

Lines changed: 284 additions & 0 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
title: "Nested Full Width Content Test"
3+
papersize: us-letter
4+
format:
5+
html: default
6+
typst:
7+
keep-typ: true
8+
_quarto:
9+
tests:
10+
typst:
11+
ensureTypstFileRegexMatches:
12+
- ['#wideblock\(']
13+
- []
14+
ensurePdfRegexMatches:
15+
- ['OUTER-CONTENT', 'INNER-CONTENT', 'Figure 1']
16+
- []
17+
noErrors: default
18+
---
19+
20+
## Nested Full Width Elements
21+
22+
This tests nesting scenarios with full-width content.
23+
24+
### Figure Inside Full-Width Div
25+
26+
::: {.column-page}
27+
OUTER-CONTENT: This is the outer full-width div.
28+
29+
![INNER-CONTENT: A figure nested inside the full-width div](test-image.png){#fig-nested width=80%}
30+
31+
Text after the nested figure, still inside the full-width div.
32+
:::
33+
34+
Reference to @fig-nested.
35+
36+
### List Inside Full-Width Div
37+
38+
::: {.column-page-right}
39+
A full-width div containing a list:
40+
41+
- First item in wide div
42+
- Second item in wide div
43+
- Third item in wide div
44+
45+
And a code block:
46+
47+
```python
48+
def nested_code():
49+
return "inside fullwidth"
50+
```
51+
:::
52+
53+
Regular text after.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: "Column Page Left Test"
3+
papersize: us-letter
4+
format:
5+
html: default
6+
typst:
7+
keep-typ: true
8+
_quarto:
9+
tests:
10+
typst:
11+
ensureTypstFileRegexMatches:
12+
# column-page-left should map to wideblock with inner side
13+
- ['#wideblock\(side: "inner"\)']
14+
- []
15+
ensurePdfRegexMatches:
16+
- ['PAGE-LEFT-CONTENT', 'extends into']
17+
- []
18+
noErrors: default
19+
---
20+
21+
## Column Page Left
22+
23+
This tests the `.column-page-left` class which extends content into the left (inner) margin.
24+
25+
::: {.column-page-left}
26+
PAGE-LEFT-CONTENT: This content extends into the left margin while keeping the right edge aligned with the text column. This is useful for content that benefits from extra space on the left side.
27+
:::
28+
29+
Regular text continues here in the normal column width.
30+
31+
[This aside stays in the right margin]{.aside}
32+
33+
More regular text to show the contrast between page-left and normal content.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: "Column Screen Inset Left/Right Test"
3+
papersize: us-letter
4+
format:
5+
html: default
6+
typst:
7+
keep-typ: true
8+
_quarto:
9+
tests:
10+
typst:
11+
ensureTypstFileRegexMatches:
12+
# column-screen-inset-left/right should use column-screen-inset with inner/outer
13+
- ['#column-screen-inset\(side: "inner"\)', '#column-screen-inset\(side: "outer"\)']
14+
- []
15+
ensurePdfRegexMatches:
16+
- ['INSET-LEFT-CONTENT', 'INSET-RIGHT-CONTENT']
17+
- []
18+
noErrors: default
19+
---
20+
21+
## Column Screen Inset Left
22+
23+
The `.column-screen-inset-left` class extends content toward the left with a small inset from the edge.
24+
25+
::: {.column-screen-inset-left}
26+
INSET-LEFT-CONTENT: This content extends toward the left edge but maintains a small inset. The right edge stays aligned with the text column.
27+
:::
28+
29+
Regular text here.
30+
31+
## Column Screen Inset Right
32+
33+
The `.column-screen-inset-right` class extends content toward the right with a small inset from the edge.
34+
35+
::: {.column-screen-inset-right}
36+
INSET-RIGHT-CONTENT: This content extends toward the right edge but maintains a small inset. The left edge stays aligned with the text column.
37+
:::
38+
39+
Regular text continues.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: "Column Screen Left/Right Test"
3+
papersize: us-letter
4+
format:
5+
html: default
6+
typst:
7+
keep-typ: true
8+
_quarto:
9+
tests:
10+
typst:
11+
ensureTypstFileRegexMatches:
12+
# column-screen-left maps to inner, column-screen-right maps to outer
13+
- ['#wideblock\(side: "inner"\)', '#wideblock\(side: "outer"\)']
14+
- []
15+
ensurePdfRegexMatches:
16+
- ['SCREEN-LEFT-CONTENT', 'SCREEN-RIGHT-CONTENT']
17+
- []
18+
noErrors: default
19+
---
20+
21+
## Column Screen Left
22+
23+
The `.column-screen-left` class extends content to the left edge of the screen/page.
24+
25+
::: {.column-screen-left}
26+
SCREEN-LEFT-CONTENT: This content extends all the way to the left edge of the page, leaving the right side aligned with the text column.
27+
:::
28+
29+
Regular text here.
30+
31+
## Column Screen Right
32+
33+
The `.column-screen-right` class extends content to the right edge of the screen/page.
34+
35+
::: {.column-screen-right}
36+
SCREEN-RIGHT-CONTENT: This content extends all the way to the right edge of the page, leaving the left side aligned with the text column.
37+
:::
38+
39+
Regular text continues.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: "A4 Paper Size Test"
3+
papersize: a4
4+
format:
5+
html: default
6+
typst:
7+
keep-typ: true
8+
_quarto:
9+
tests:
10+
typst:
11+
ensureTypstFileRegexMatches:
12+
# Should have marginalia setup with A4 geometry
13+
- ['marginalia.setup', 'paper: "a4"']
14+
- []
15+
ensurePdfRegexMatches:
16+
- ['A4-PAPER-TEST', 'MARGIN-A4']
17+
- []
18+
ensurePdfTextPositions:
19+
- - subject: "MARGIN-A4"
20+
relation: rightOf
21+
object: "A4-PAPER-TEST"
22+
- []
23+
noErrors: default
24+
---
25+
26+
## Testing A4 Paper Size
27+
28+
A4-PAPER-TEST: This tests margin layout on A4 paper (210mm × 297mm), which is narrower but taller than US Letter.
29+
30+
[MARGIN-A4: This note should appear in the margin with geometry computed for A4 dimensions.]{.column-margin}
31+
32+
A4 is the international standard paper size used in most countries outside North America. The margin calculations should adapt to the different page width.
33+
34+
More text to demonstrate the layout on A4 paper. The text column and margin widths should be proportionally adjusted for the narrower page.
35+
36+
[Another margin note to test stacking on A4.]{.column-margin}
37+
38+
Additional content in the main column.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
title: "Grid Body Width Test"
3+
papersize: us-letter
4+
grid:
5+
body-width: 5in
6+
margin-width: 2in
7+
gutter-width: 0.25in
8+
format:
9+
html: default
10+
typst:
11+
keep-typ: true
12+
_quarto:
13+
tests:
14+
typst:
15+
ensureTypstFileRegexMatches:
16+
# Should have marginalia setup with outer margin configuration
17+
- ['marginalia.setup', 'outer:']
18+
- []
19+
ensurePdfRegexMatches:
20+
- ['BODYTEST1', 'MARGINNOTE1']
21+
- []
22+
ensurePdfTextPositions:
23+
- - subject: "MARGINNOTE1"
24+
relation: rightOf
25+
object: "BODYTEST1"
26+
- []
27+
noErrors: default
28+
---
29+
30+
## Testing Grid Body Width
31+
32+
BODYTEST1: This tests the `grid.body-width` option which should control the width of the main text column.
33+
34+
[MARGINNOTE1: This note should appear in a 2-inch margin column.]{.column-margin}
35+
36+
With `body-width: 5in`, the text column should be narrower than default, leaving more room for margins.
37+
38+
The layout should respect:
39+
40+
- `body-width: 5in` - narrower text column
41+
- `margin-width: 2in` - wider margin for notes
42+
- `gutter-width: 0.25in` - gap between columns
43+
44+
More text to fill out the column and show the narrower width.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: "Legal Paper Size Test"
3+
papersize: us-legal
4+
format:
5+
html: default
6+
typst:
7+
keep-typ: true
8+
_quarto:
9+
tests:
10+
typst:
11+
ensureTypstFileRegexMatches:
12+
# Should have marginalia setup with legal geometry
13+
- ['marginalia.setup', 'paper: "us-legal"']
14+
- []
15+
ensurePdfRegexMatches:
16+
- ['LEGAL-PAPER-TEST', 'MARGIN-LEGAL']
17+
- []
18+
ensurePdfTextPositions:
19+
- - subject: "MARGIN-LEGAL"
20+
relation: rightOf
21+
object: "LEGAL-PAPER-TEST"
22+
- []
23+
noErrors: default
24+
---
25+
26+
## Testing Legal Paper Size
27+
28+
LEGAL-PAPER-TEST: This tests margin layout on US Legal paper (8.5" × 14"), which is the same width as Letter but taller.
29+
30+
[MARGIN-LEGAL: This note should appear in the margin with geometry computed for Legal dimensions.]{.column-margin}
31+
32+
Legal paper has the same width as Letter (8.5"), so the margin column widths should be identical. However, the taller page (14" vs 11") provides more vertical space.
33+
34+
More text to demonstrate the layout on Legal paper. Since the width matches Letter, the horizontal layout should be identical.
35+
36+
[Another margin note on Legal paper.]{.column-margin}
37+
38+
Additional content in the main column to show the layout.

0 commit comments

Comments
 (0)