summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIan Wrzesinski <133046678+wrzian@users.noreply.github.com>2024-10-22 09:25:52 -0400
committerGitHub <noreply@github.com>2024-10-22 13:25:52 +0000
commitb8034a343831e8609aec2ec81eb7eeda57aa5d81 (patch)
tree88653a330c7d08e5e5eb302e9c5628b885c1723e /tests
parent33b9d1c7db460e0ecb24762c08a8d3a085ba4e63 (diff)
Syntax set macro (#5138)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/suite/model/heading.typ36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/suite/model/heading.typ b/tests/suite/model/heading.typ
index 3be9e52b..884f203d 100644
--- a/tests/suite/model/heading.typ
+++ b/tests/suite/model/heading.typ
@@ -35,6 +35,42 @@ multiline.
= This
is not.
+--- heading-trailing-whitespace ---
+// Whether headings contain trailing whitespace with or without comments/labels.
+// Labels are special cased to immediately end headings in the parser, but also
+// have unique whitespace behavior.
+
+#let join(..xs) = xs.pos().join()
+#let head(h) = heading(depth: 1, h)
+
+// No whitespace.
+#test(head[h], [= h])
+#test(head[h], [= h/**/])
+#test(head[h], [= h<a>])
+#test(head[h], [= h/**/<b>])
+
+// Label behaves differently than normal trailing space and comment.
+#test(head(join[h][ ]), [= h ])
+#test(head(join[h][ ]), [= h /**/])
+#test(join(head[h])[ ], [= h <c>])
+
+// Combinations.
+#test(head(join[h][ ][ ]), [= h /**/ ])
+#test(join(head[h])[ ][ ], [= h <d> ])
+#test(head(join[h][ ]), [= h /**/<e>])
+#test(join(head[h])[ ], [= h/**/ <f>])
+
+// The first space attaches, but not the second
+#test(join(head(join[h][ ]))[ ], [= h /**/ <g>])
+
+--- heading-leading-whitespace ---
+// Test that leading whitespace and comments don't matter.
+#test[= h][= h]
+#test[= h][= /**/ /**/ h]
+#test[= h][= /*
+comment spans lines
+*/ h]
+
--- heading-show-where ---
// Test styling.
#show heading.where(level: 5): it => block(