summaryrefslogtreecommitdiff
path: root/tests/suite/model
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2025-01-24 13:11:26 +0100
committerGitHub <noreply@github.com>2025-01-24 12:11:26 +0000
commit26e65bfef5b1da7f6c72e1409237cf03fb5d6069 (patch)
treedae6f71efead43736202dd6aea933b95b1bc7a14 /tests/suite/model
parent467968af0788a3059e1bed47f9daee846f5b3904 (diff)
Semantic paragraphs (#5746)
Diffstat (limited to 'tests/suite/model')
-rw-r--r--tests/suite/model/bibliography.typ18
-rw-r--r--tests/suite/model/enum.typ38
-rw-r--r--tests/suite/model/figure.typ11
-rw-r--r--tests/suite/model/heading.typ5
-rw-r--r--tests/suite/model/list.typ38
-rw-r--r--tests/suite/model/outline.typ9
-rw-r--r--tests/suite/model/par.typ141
-rw-r--r--tests/suite/model/quote.typ11
-rw-r--r--tests/suite/model/terms.typ40
9 files changed, 284 insertions, 27 deletions
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