diff options
| author | Laurenz <laurmaedje@gmail.com> | 2025-01-24 13:11:26 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-24 12:11:26 +0000 |
| commit | 26e65bfef5b1da7f6c72e1409237cf03fb5d6069 (patch) | |
| tree | dae6f71efead43736202dd6aea933b95b1bc7a14 /tests | |
| parent | 467968af0788a3059e1bed47f9daee846f5b3904 (diff) | |
Semantic paragraphs (#5746)
Diffstat (limited to 'tests')
39 files changed, 433 insertions, 30 deletions
diff --git a/tests/ref/bibliography-grid-par.png b/tests/ref/bibliography-grid-par.png Binary files differnew file mode 100644 index 00000000..5befbcc5 --- /dev/null +++ b/tests/ref/bibliography-grid-par.png diff --git a/tests/ref/bibliography-indent-par.png b/tests/ref/bibliography-indent-par.png Binary files differnew file mode 100644 index 00000000..98a3c4d0 --- /dev/null +++ b/tests/ref/bibliography-indent-par.png diff --git a/tests/ref/enum-par.png b/tests/ref/enum-par.png Binary files differnew file mode 100644 index 00000000..ca923a52 --- /dev/null +++ b/tests/ref/enum-par.png diff --git a/tests/ref/figure-par.png b/tests/ref/figure-par.png Binary files differnew file mode 100644 index 00000000..d70bbcb1 --- /dev/null +++ b/tests/ref/figure-par.png diff --git a/tests/ref/heading-par.png b/tests/ref/heading-par.png Binary files differnew file mode 100644 index 00000000..affc0df4 --- /dev/null +++ b/tests/ref/heading-par.png diff --git a/tests/ref/html/enum-par.html b/tests/ref/html/enum-par.html new file mode 100644 index 00000000..60d4592b --- /dev/null +++ b/tests/ref/html/enum-par.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + </head> + <body> + <div> + <ol> + <li>Hello</li> + <li>World</li> + </ol> + </div> + <div> + <ol> + <li> + <p>Hello</p> + <p>From</p> + </li> + <li>World</li> + </ol> + </div> + <div> + <ol> + <li> + <p>Hello</p> + <p>From</p> + <p>The</p> + </li> + <li> + <p>World</p> + </li> + </ol> + </div> + </body> +</html> diff --git a/tests/ref/html/list-par.html b/tests/ref/html/list-par.html new file mode 100644 index 00000000..7c747ff4 --- /dev/null +++ b/tests/ref/html/list-par.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + </head> + <body> + <div> + <ul> + <li>Hello</li> + <li>World</li> + </ul> + </div> + <div> + <ul> + <li> + <p>Hello</p> + <p>From</p> + </li> + <li>World</li> + </ul> + </div> + <div> + <ul> + <li> + <p>Hello</p> + <p>From</p> + <p>The</p> + </li> + <li> + <p>World</p> + </li> + </ul> + </div> + </body> +</html> diff --git a/tests/ref/html/par-semantic-html.html b/tests/ref/html/par-semantic-html.html new file mode 100644 index 00000000..09c7d2fd --- /dev/null +++ b/tests/ref/html/par-semantic-html.html @@ -0,0 +1,16 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + </head> + <body> + <h2>Heading is no paragraph</h2> + <p>I'm a paragraph.</p> + <div>I'm not.</div> + <div> + <p>We are two.</p> + <p>So we are paragraphs.</p> + </div> + </body> +</html> diff --git a/tests/ref/html/quote-attribution-link.html b/tests/ref/html/quote-attribution-link.html index 753807db..c12d2ae2 100644 --- a/tests/ref/html/quote-attribution-link.html +++ b/tests/ref/html/quote-attribution-link.html @@ -5,7 +5,7 @@ <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> - <blockquote cite="https://typst.app/home"> Compose papers faster </blockquote> + <blockquote cite="https://typst.app/home">Compose papers faster</blockquote> <p>— <a href="https://typst.app/home">typst.com</a></p> </body> </html> diff --git a/tests/ref/html/quote-plato.html b/tests/ref/html/quote-plato.html index f516adc2..03983508 100644 --- a/tests/ref/html/quote-plato.html +++ b/tests/ref/html/quote-plato.html @@ -5,9 +5,9 @@ <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> - <blockquote> … ἔοικα γοῦν τούτου γε σμικρῷ τινι αὐτῷ τούτῳ σοφώτερος εἶναι, ὅτι ἃ μὴ οἶδα οὐδὲ οἴομαι εἰδέναι. </blockquote> + <blockquote>… ἔοικα γοῦν τούτου γε σμικρῷ τινι αὐτῷ τούτῳ σοφώτερος εἶναι, ὅτι ἃ μὴ οἶδα οὐδὲ οἴομαι εἰδέναι.</blockquote> <p>— Plato</p> - <blockquote> … I seem, then, in just this little thing to be wiser than this man at any rate, that what I do not know I do not think I know either. </blockquote> + <blockquote>… I seem, then, in just this little thing to be wiser than this man at any rate, that what I do not know I do not think I know either.</blockquote> <p>— from the Henry Cary literal translation of 1897</p> </body> </html> diff --git a/tests/ref/html/terms-par.html b/tests/ref/html/terms-par.html new file mode 100644 index 00000000..78bc5df1 --- /dev/null +++ b/tests/ref/html/terms-par.html @@ -0,0 +1,42 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + </head> + <body> + <div> + <dl> + <dt>Hello</dt> + <dd>A</dd> + <dt>World</dt> + <dd>B</dd> + </dl> + </div> + <div> + <dl> + <dt>Hello</dt> + <dd> + <p>A</p> + <p>From</p> + </dd> + <dt>World</dt> + <dd>B</dd> + </dl> + </div> + <div> + <dl> + <dt>Hello</dt> + <dd> + <p>A</p> + <p>From</p> + <p>The</p> + </dd> + <dt>World</dt> + <dd> + <p>B</p> + </dd> + </dl> + </div> + </body> +</html> diff --git a/tests/ref/issue-5503-enum-in-align.png b/tests/ref/issue-5503-enum-in-align.png Binary files differnew file mode 100644 index 00000000..4857e731 --- /dev/null +++ b/tests/ref/issue-5503-enum-in-align.png diff --git a/tests/ref/issue-5503-enum-interrupted-by-par-align.png b/tests/ref/issue-5503-enum-interrupted-by-par-align.png Binary files differdeleted file mode 100644 index 9cc942b4..00000000 --- a/tests/ref/issue-5503-enum-interrupted-by-par-align.png +++ /dev/null diff --git a/tests/ref/issue-5503-list-interrupted-by-par-align.png b/tests/ref/issue-5503-list-in-align.png Binary files differindex 2b785c4b..2b785c4b 100644 --- a/tests/ref/issue-5503-list-interrupted-by-par-align.png +++ b/tests/ref/issue-5503-list-in-align.png diff --git a/tests/ref/issue-5503-terms-interrupted-by-par-align.png b/tests/ref/issue-5503-terms-in-align.png Binary files differindex 1bdacd94..1bdacd94 100644 --- a/tests/ref/issue-5503-terms-interrupted-by-par-align.png +++ b/tests/ref/issue-5503-terms-in-align.png diff --git a/tests/ref/list-par.png b/tests/ref/list-par.png Binary files differnew file mode 100644 index 00000000..5f0003d1 --- /dev/null +++ b/tests/ref/list-par.png diff --git a/tests/ref/math-par.png b/tests/ref/math-par.png Binary files differnew file mode 100644 index 00000000..30d64794 --- /dev/null +++ b/tests/ref/math-par.png diff --git a/tests/ref/outline-par.png b/tests/ref/outline-par.png Binary files differnew file mode 100644 index 00000000..04c63f62 --- /dev/null +++ b/tests/ref/outline-par.png diff --git a/tests/ref/par-contains-block.png b/tests/ref/par-contains-block.png Binary files differnew file mode 100644 index 00000000..f4bd071f --- /dev/null +++ b/tests/ref/par-contains-block.png diff --git a/tests/ref/par-contains-parbreak.png b/tests/ref/par-contains-parbreak.png Binary files differnew file mode 100644 index 00000000..f4bd071f --- /dev/null +++ b/tests/ref/par-contains-parbreak.png diff --git a/tests/ref/par-hanging-indent-semantic.png b/tests/ref/par-hanging-indent-semantic.png Binary files differnew file mode 100644 index 00000000..e05795c7 --- /dev/null +++ b/tests/ref/par-hanging-indent-semantic.png diff --git a/tests/ref/par-semantic-align.png b/tests/ref/par-semantic-align.png Binary files differnew file mode 100644 index 00000000..eda49641 --- /dev/null +++ b/tests/ref/par-semantic-align.png diff --git a/tests/ref/par-semantic-tag.png b/tests/ref/par-semantic-tag.png Binary files differnew file mode 100644 index 00000000..2b26e5ae --- /dev/null +++ b/tests/ref/par-semantic-tag.png diff --git a/tests/ref/par-semantic.png b/tests/ref/par-semantic.png Binary files differnew file mode 100644 index 00000000..c2eca74d --- /dev/null +++ b/tests/ref/par-semantic.png diff --git a/tests/ref/par-show.png b/tests/ref/par-show.png Binary files differnew file mode 100644 index 00000000..1ceb26f7 --- /dev/null +++ b/tests/ref/par-show.png diff --git a/tests/ref/quote-par.png b/tests/ref/quote-par.png Binary files differnew file mode 100644 index 00000000..89d15ddf --- /dev/null +++ b/tests/ref/quote-par.png diff --git a/tests/ref/table-cell-par.png b/tests/ref/table-cell-par.png Binary files differnew file mode 100644 index 00000000..24a2a55f --- /dev/null +++ b/tests/ref/table-cell-par.png diff --git a/tests/ref/terms-par.png b/tests/ref/terms-par.png Binary files differnew file mode 100644 index 00000000..910b5e5d --- /dev/null +++ b/tests/ref/terms-par.png diff --git a/tests/suite/layout/table.typ b/tests/suite/layout/table.typ index f59d8b42..5c2b0749 100644 --- a/tests/suite/layout/table.typ +++ b/tests/suite/layout/table.typ @@ -310,6 +310,17 @@ ) } +--- table-cell-par --- +// Ensure that table cells aren't considered paragraphs by default. +#show par: highlight + +#table( + columns: 3, + [A], + block[B], + par[C], +) + --- grid-cell-in-table --- // Error: 8-19 cannot use `grid.cell` as a table cell // Hint: 8-19 use `table.cell` instead diff --git a/tests/suite/math/text.typ b/tests/suite/math/text.typ index 760910f4..8c761111 100644 --- a/tests/suite/math/text.typ +++ b/tests/suite/math/text.typ @@ -43,3 +43,8 @@ $sum_(k in NN)^prime 1/k^2$ // Test script-script in a fraction. $ 1/(x^A) $ #[#set text(size:18pt); $1/(x^A)$] vs. #[#set text(size:14pt); $x^A$] + +--- math-par --- +// Ensure that math does not produce paragraphs. +#show par: highlight +$ a + "bc" + #[c] + #box[d] + #block[e] $ diff --git a/tests/suite/model/bibliography.typ b/tests/suite/model/bibliography.typ index 20eb8acd..6de44e24 100644 --- a/tests/suite/model/bibliography.typ +++ b/tests/suite/model/bibliography.typ @@ -53,6 +53,24 @@ Now we have multiple bibliographies containing @glacier-melt @keshav2007read @Zee04 #bibliography("/assets/bib/works_too.bib", style: "mla") +--- bibliography-grid-par --- +// Ensure that a grid-based bibliography does not produce paragraphs. +#show par: highlight + +@Zee04 +@keshav2007read + +#bibliography("/assets/bib/works_too.bib") + +--- bibliography-indent-par --- +// Ensure that an indent-based bibliography does not produce paragraphs. +#show par: highlight + +@Zee04 +@keshav2007read + +#bibliography("/assets/bib/works_too.bib", style: "mla") + --- issue-4618-bibliography-set-heading-level --- // Test that the bibliography block's heading is set to 2 by the show rule, // and therefore should be rendered like a level-2 heading. Notably, this diff --git a/tests/suite/model/enum.typ b/tests/suite/model/enum.typ index 288392d4..7176b04e 100644 --- a/tests/suite/model/enum.typ +++ b/tests/suite/model/enum.typ @@ -183,22 +183,44 @@ a + 0. #set enum(number-align: horizon) #set enum(number-align: bottom) +--- enum-par render html --- +// Check whether the contents of enum items become paragraphs. +#show par: it => if target() != "html" { highlight(it) } else { it } + +// No paragraphs. +#block[ + + Hello + + World +] + +#block[ + + Hello // Paragraphs + + From + + World // No paragraph because it's a tight enum +] + +#block[ + + Hello // Paragraphs + + From + + The + + + World // Paragraph because it's a wide enum +] + --- issue-2530-enum-item-panic --- // Enum item (pre-emptive) #enum.item(none)[Hello] #enum.item(17)[Hello] ---- issue-5503-enum-interrupted-by-par-align --- -// `align` is block-level and should interrupt an enum -// but not a `par` +--- issue-5503-enum-in-align --- +// `align` is block-level and should interrupt an enum. + a + b -#par(leading: 5em)[+ par] +#align(right)[+ c] + d -#par[+ par] -+ f -#align(right)[+ align] -+ h --- issue-5719-enum-nested --- // Enums can be immediately nested. diff --git a/tests/suite/model/figure.typ b/tests/suite/model/figure.typ index 58ba2b2a..37fb4ecd 100644 --- a/tests/suite/model/figure.typ +++ b/tests/suite/model/figure.typ @@ -180,6 +180,17 @@ We can clearly see that @fig-cylinder and caption: [Underlined], ) +--- figure-par --- +// Ensure that a figure body is considered a paragraph. +#show par: highlight + +#figure[Text] + +#figure( + [Text], + caption: [A caption] +) + --- figure-and-caption-show --- // Test creating custom figure and custom caption diff --git a/tests/suite/model/heading.typ b/tests/suite/model/heading.typ index 4e529fdf..4e04e5c5 100644 --- a/tests/suite/model/heading.typ +++ b/tests/suite/model/heading.typ @@ -128,6 +128,11 @@ Not in heading // Hint: 1:19-1:25 you can enable heading numbering with `#set heading(numbering: "1.")` Cannot be used as @intro +--- heading-par --- +// Ensure that heading text isn't considered a paragraph. +#show par: highlight += Heading + --- heading-html-basic html --- // level 1 => h2 // ... diff --git a/tests/suite/model/list.typ b/tests/suite/model/list.typ index 96ddf3c1..9bed930b 100644 --- a/tests/suite/model/list.typ +++ b/tests/suite/model/list.typ @@ -238,6 +238,33 @@ World #text(red)[- World] #text(green)[- What up?] +--- list-par render html --- +// Check whether the contents of list items become paragraphs. +#show par: it => if target() != "html" { highlight(it) } else { it } + +#block[ + // No paragraphs. + - Hello + - World +] + +#block[ + - Hello // Paragraphs + + From + - World // No paragraph because it's a tight list. +] + +#block[ + - Hello // Paragraphs either way + + From + + The + + - World // Paragraph because it's a wide list. +] + --- issue-2530-list-item-panic --- // List item (pre-emptive) #list.item[Hello] @@ -262,18 +289,11 @@ World part($ x $ + parbreak() + parbreak() + list[A]) } ---- issue-5503-list-interrupted-by-par-align --- -// `align` is block-level and should interrupt a list -// but not a `par` +--- issue-5503-list-in-align --- +// `align` is block-level and should interrupt a list. #show list: [List] - a - b -#par(leading: 5em)[- c] -- d -- e -#par[- f] -- g -- h #align(right)[- i] - j diff --git a/tests/suite/model/outline.typ b/tests/suite/model/outline.typ index a755151d..49fd7d7c 100644 --- a/tests/suite/model/outline.typ +++ b/tests/suite/model/outline.typ @@ -242,6 +242,15 @@ A #outline(target: metadata) #metadata("hello") +--- outline-par --- +// Ensure that an outline does not produce paragraphs. +#show par: highlight + +#outline() + += A += B += C --- issue-2048-outline-multiline --- // Without the word joiner between the dots and the page number, diff --git a/tests/suite/model/par.typ b/tests/suite/model/par.typ index 0c2b5cb5..84f2ec15 100644 --- a/tests/suite/model/par.typ +++ b/tests/suite/model/par.typ @@ -19,6 +19,105 @@ heaven Would through the airy region stream so bright That birds would sing and think it were not night. See, how she leans her cheek upon her hand! O, that I were a glove upon that hand, That I might touch that cheek! +--- par-semantic --- +#show par: highlight + +I'm a paragraph. + +#align(center, table( + columns: 3, + + // No paragraphs. + [A], + block[B], + block[C *D*], + + // Paragraphs. + par[E], + [ + + F + ], + [ + G + + ], + + // Paragraphs. + parbreak() + [H], + [I] + parbreak(), + parbreak() + [J] + parbreak(), + + // Paragraphs. + [K #v(10pt)], + [#v(10pt) L], + [#place[] M], + + // Paragraphs. + [ + N + + O + ], + [#par[P]#par[Q]], + // No paragraphs. + [#block[R]#block[S]], +)) + +--- par-semantic-html html --- += Heading is no paragraph + +I'm a paragraph. + +#html.elem("div")[I'm not.] + +#html.elem("div")[ + We are two. + + So we are paragraphs. +] + +--- par-semantic-tag --- +#show par: highlight +#block[ + #metadata(none) <hi1> + A + #metadata(none) <hi2> +] + +#block(width: 100%, metadata(none) + align(center)[A]) +#block(width: 100%, align(center)[A] + metadata(none)) + +--- par-semantic-align --- +#show par: highlight +#show bibliography: none +#set block(width: 100%, stroke: 1pt, inset: 5pt) + +#bibliography("/assets/bib/works.bib") + +#block[ + #set align(right) + Hello +] + +#block[ + #set align(right) + Hello + @netwok +] + +#block[ + Hello + #align(right)[World] + You +] + +#block[ + Hello + #align(right)[@netwok] + You +] + --- par-leading-and-spacing --- // Test changing leading and spacing. #set par(spacing: 1em, leading: 2pt) @@ -69,6 +168,12 @@ Why would anybody ever ... #set par(hanging-indent: 15pt, justify: true) #lorem(10) +--- par-hanging-indent-semantic --- +#set par(hanging-indent: 15pt) += I am not affected + +I am affected by hanging indent. + --- par-hanging-indent-manual-linebreak --- #set par(hanging-indent: 1em) Welcome \ here. Does this work well? @@ -83,6 +188,22 @@ Welcome \ here. Does this work well? // Ensure that trailing whitespace layouts as intended. #box(fill: aqua, " ") +--- par-contains-parbreak --- +#par[ + Hello + // Warning: 4-14 parbreak may not occur inside of a paragraph and was ignored + #parbreak() + World +] + +--- par-contains-block --- +#par[ + Hello + // Warning: 4-11 block may not occur inside of a paragraph and was ignored + #block[] + World +] + --- par-empty-metadata --- // Check that metadata still works in a zero length paragraph. #block(height: 0pt)[#""#metadata(false)<hi>] @@ -94,6 +215,26 @@ Welcome \ here. Does this work well? #set text(hyphenate: false) Lorem ipsum dolor #metadata(none) nonumy eirmod tempor. +--- par-show --- +// This is only slightly cursed. +#let revoke = metadata("revoke") +#show par: it => { + if bibliography.title == revoke { return it } + set bibliography(title: revoke) + let p = counter("p") + par[#p.step() §#context p.display() #it.body] +} + += A + +B + +C #parbreak() D + +#block[E] + +#block[F #parbreak() G] + --- issue-4278-par-trim-before-equation --- #set par(justify: true) #lorem(6) aa $a = c + b$ diff --git a/tests/suite/model/quote.typ b/tests/suite/model/quote.typ index d0dcc55d..51c4bba5 100644 --- a/tests/suite/model/quote.typ +++ b/tests/suite/model/quote.typ @@ -107,3 +107,14 @@ When you said that #quote[he surely meant that #quote[she intended to say #quote )[ Compose papers faster ] + +--- quote-par --- +// Ensure that an inline quote is part of a paragraph, but a block quote +// does not result in paragraphs. +#show par: highlight + +An inline #quote[quote.] + +#quote(block: true, attribution: [The Test Author])[ + A block-level quote. +] diff --git a/tests/suite/model/terms.typ b/tests/suite/model/terms.typ index 23ac6e51..103a8033 100644 --- a/tests/suite/model/terms.typ +++ b/tests/suite/model/terms.typ @@ -59,6 +59,34 @@ Not in list // Error: 8 expected colon / Hello +--- terms-par render html --- +// Check whether the contents of term list items become paragraphs. +#show par: it => if target() != "html" { highlight(it) } else { it } + +// No paragraphs. +#block[ + / Hello: A + / World: B +] + +#block[ + / Hello: A // Paragraphs + + From + / World: B // No paragraphs because it's a tight term list. +] + +#block[ + / Hello: A // Paragraphs + + From + + The + + / World: B // Paragraph because it's a wide term list. +] + + --- issue-1050-terms-indent --- #set page(width: 110pt) #set par(first-line-indent: 0.5cm) @@ -76,18 +104,10 @@ Not in list // Term item (pre-emptive) #terms.item[Hello][World!] ---- issue-5503-terms-interrupted-by-par-align --- -// `align` is block-level and should interrupt a `terms` -// but not a `par` +--- issue-5503-terms-in-align --- +// `align` is block-level and should interrupt a `terms`. #show terms: [Terms] / a: a -/ b: b -#par(leading: 5em)[/ c: c] -/ d: d -/ e: e -#par[/ f: f] -/ g: g -/ h: h #align(right)[/ i: i] / j: j |
