summaryrefslogtreecommitdiff
path: root/tests/typ
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-05-26 15:59:11 +0200
committerLaurenz <laurmaedje@gmail.com>2022-05-27 14:23:05 +0200
commit22214a1e0a79666caefd486e41828f015878ecb0 (patch)
treed8be41ca9fcf92be623a02ba580fcc6c7ddcd58d /tests/typ
parent3e052e6e017eaf51b101fa87629e392c16c32ac2 (diff)
Test groups
Diffstat (limited to 'tests/typ')
-rw-r--r--tests/typ/layout/locate-group.typ43
1 files changed, 43 insertions, 0 deletions
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") ...