summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPgBiel <9021226+PgBiel@users.noreply.github.com>2024-12-08 13:25:47 -0300
committerGitHub <noreply@github.com>2024-12-08 16:25:47 +0000
commita1a521523451c693218274d2f88466a07bfff9ea (patch)
tree5716136e859d3800467df982662b75e46306b22f
parent50dcacea9a3d9284ef1eeb9c20682d9568c91e70 (diff)
Ensure par and align interrupt cite groups and lists (#5526)
-rw-r--r--crates/typst-realize/src/lib.rs6
-rw-r--r--tests/ref/issue-5503-cite-group-interrupted-by-par-align.pngbin0 -> 1487 bytes
-rw-r--r--tests/ref/issue-5503-cite-in-align.pngbin0 -> 393 bytes
-rw-r--r--tests/ref/issue-5503-enum-interrupted-by-par-align.pngbin0 -> 1004 bytes
-rw-r--r--tests/ref/issue-5503-list-interrupted-by-par-align.pngbin0 -> 415 bytes
-rw-r--r--tests/ref/issue-5503-terms-interrupted-by-par-align.pngbin0 -> 569 bytes
-rw-r--r--tests/suite/model/cite.typ22
-rw-r--r--tests/suite/model/enum.typ12
-rw-r--r--tests/suite/model/list.typ15
-rw-r--r--tests/suite/model/terms.typ15
10 files changed, 68 insertions, 2 deletions
diff --git a/crates/typst-realize/src/lib.rs b/crates/typst-realize/src/lib.rs
index c46a1535..fd43e830 100644
--- a/crates/typst-realize/src/lib.rs
+++ b/crates/typst-realize/src/lib.rs
@@ -836,7 +836,9 @@ static CITES: GroupingRule = GroupingRule {
tags: false,
trigger: |content, _| content.elem() == CiteElem::elem(),
inner: |content| content.elem() == SpaceElem::elem(),
- interrupt: |elem| elem == CiteGroup::elem(),
+ interrupt: |elem| {
+ elem == CiteGroup::elem() || elem == ParElem::elem() || elem == AlignElem::elem()
+ },
finish: finish_cites,
};
@@ -859,7 +861,7 @@ const fn list_like_grouping<T: ListLike>() -> GroupingRule {
let elem = content.elem();
elem == SpaceElem::elem() || elem == ParbreakElem::elem()
},
- interrupt: |elem| elem == T::elem(),
+ interrupt: |elem| elem == T::elem() || elem == AlignElem::elem(),
finish: finish_list_like::<T>,
}
}
diff --git a/tests/ref/issue-5503-cite-group-interrupted-by-par-align.png b/tests/ref/issue-5503-cite-group-interrupted-by-par-align.png
new file mode 100644
index 00000000..16633158
--- /dev/null
+++ b/tests/ref/issue-5503-cite-group-interrupted-by-par-align.png
Binary files differ
diff --git a/tests/ref/issue-5503-cite-in-align.png b/tests/ref/issue-5503-cite-in-align.png
new file mode 100644
index 00000000..aeb72aa0
--- /dev/null
+++ b/tests/ref/issue-5503-cite-in-align.png
Binary files differ
diff --git a/tests/ref/issue-5503-enum-interrupted-by-par-align.png b/tests/ref/issue-5503-enum-interrupted-by-par-align.png
new file mode 100644
index 00000000..9cc942b4
--- /dev/null
+++ b/tests/ref/issue-5503-enum-interrupted-by-par-align.png
Binary files differ
diff --git a/tests/ref/issue-5503-list-interrupted-by-par-align.png b/tests/ref/issue-5503-list-interrupted-by-par-align.png
new file mode 100644
index 00000000..2b785c4b
--- /dev/null
+++ b/tests/ref/issue-5503-list-interrupted-by-par-align.png
Binary files differ
diff --git a/tests/ref/issue-5503-terms-interrupted-by-par-align.png b/tests/ref/issue-5503-terms-interrupted-by-par-align.png
new file mode 100644
index 00000000..1bdacd94
--- /dev/null
+++ b/tests/ref/issue-5503-terms-interrupted-by-par-align.png
Binary files differ
diff --git a/tests/suite/model/cite.typ b/tests/suite/model/cite.typ
index 90280081..b328dda4 100644
--- a/tests/suite/model/cite.typ
+++ b/tests/suite/model/cite.typ
@@ -114,6 +114,28 @@ B #cite(<netwok>) #cite(<arrgh>).
#show bibliography: none
#bibliography("/assets/bib/works.bib", style: "chicago-author-date")
+--- issue-5503-cite-in-align ---
+// The two aligned elements should be displayed in separate lines.
+#align(right)[@netwok]
+#align(right)[b]
+
+#show bibliography: none
+#bibliography("/assets/bib/works.bib")
+
+--- issue-5503-cite-group-interrupted-by-par-align ---
+// `par` and `align` are block-level and should interrupt a cite group
+@netwok
+@arrgh
+#par(leading: 5em)[@netwok]
+#par[@arrgh]
+@netwok
+@arrgh
+#align(right)[@netwok]
+@arrgh
+
+#show bibliography: none
+#bibliography("/assets/bib/works.bib")
+
--- cite-type-error-hint ---
// Test hint for cast error from str to label
// Error: 7-15 expected label, found string
diff --git a/tests/suite/model/enum.typ b/tests/suite/model/enum.typ
index ed33157e..c5e56215 100644
--- a/tests/suite/model/enum.typ
+++ b/tests/suite/model/enum.typ
@@ -163,3 +163,15 @@ a + 0.
// 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`
++ a
++ b
+#par(leading: 5em)[+ par]
++ d
+#par[+ par]
++ f
+#align(right)[+ align]
++ h
diff --git a/tests/suite/model/list.typ b/tests/suite/model/list.typ
index aa117672..138abf70 100644
--- a/tests/suite/model/list.typ
+++ b/tests/suite/model/list.typ
@@ -218,3 +218,18 @@ World
part($ x $ + parbreak() + list[A])
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`
+#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/terms.typ b/tests/suite/model/terms.typ
index 07aa827d..61fe20b0 100644
--- a/tests/suite/model/terms.typ
+++ b/tests/suite/model/terms.typ
@@ -75,3 +75,18 @@ Not in list
--- issue-2530-term-item-panic ---
// 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`
+#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