summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ref/layout/locate-group.pngbin0 -> 3881 bytes
-rw-r--r--tests/typ/layout/locate-group.typ43
2 files changed, 43 insertions, 0 deletions
diff --git a/tests/ref/layout/locate-group.png b/tests/ref/layout/locate-group.png
new file mode 100644
index 00000000..e38a4a32
--- /dev/null
+++ b/tests/ref/layout/locate-group.png
Binary files differ
diff --git a/tests/typ/layout/locate-group.typ b/tests/typ/layout/locate-group.typ
new file mode 100644
index 00000000..49d4e335
--- /dev/null
+++ b/tests/typ/layout/locate-group.typ
@@ -0,0 +1,43 @@
+// Test locatable groups.
+
+---
+// Test counting.
+#let letters = group("\u{1F494}")
+#let counter = letters.entry(
+ (me, all) => [{1 + me.index} / {all.len()}]
+)
+
+#counter \
+#box(counter) \
+#counter \
+
+---
+// Test minimal citation engine with references before the document.
+#let cited = group("citations")
+#let num(cited, key) = {
+ let index = 0
+ for item in cited {
+ if item.value == key {
+ index = item.index
+ break
+ }
+ }
+ [\[{index + 1}\]]
+}
+
+#let cite(key) = cited.entry(value: key, (_, all) => num(all, key))
+{cited.all(all => grid(
+ columns: (auto, 1fr),
+ gutter: 5pt,
+ ..{
+ let seen = ()
+ for item in all {
+ if item.value not in seen {
+ seen.push(item.value)
+ (num(all, item.value), item.value)
+ }
+ }
+ }
+))}
+
+As shown in #cite("abc") and #cite("def") and #cite("abc") ...