aboutsummaryrefslogtreecommitdiff
path: root/test/writer.typst
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2024-05-30 12:00:48 -0600
committerJohn MacFarlane <[email protected]>2024-05-30 12:00:48 -0600
commit0e92d9483ce55ca2dc3a7a2d12897ac0e25f4dbd (patch)
treeaef2737cdec4a00e4df84edad6ce42b9d1a1d2b9 /test/writer.typst
parent441ef31b9e69d49ec9aad80d3ce29d3150cbad40 (diff)
Typst template: use content rather than string...
...for title, author, date, email. Fixes #9823 (escaped `\@` in rendered email). Allows formatting in title, author, date, and email fields. Since the PDF metadata requires a string, and typst only converts the title to a string (not the authors), we use a small function content-to-string to do this conversion. Background: https://github.com/typst/typst/issues/2196
Diffstat (limited to 'test/writer.typst')
-rw-r--r--test/writer.typst19
1 files changed, 15 insertions, 4 deletions
diff --git a/test/writer.typst b/test/writer.typst
index 3e21fb7a8..a2ac4025e 100644
--- a/test/writer.typst
+++ b/test/writer.typst
@@ -20,6 +20,17 @@
stroke: none
)
+#let content-to-string(content) = {
+ if content.has("text") {
+ content.text
+ } else if content.has("children") {
+ content.children.map(to-string).join("")
+ } else if content.has("body") {
+ content-to-string(content.body)
+ } else if content == [ ] {
+ " "
+ }
+}
#let conf(
title: none,
subtitle: none,
@@ -39,7 +50,7 @@
) = {
set document(
title: title,
- author: authors.map(author => author.name),
+ author: authors.map(author => content-to-string(author.name)),
keywords: keywords,
)
set page(
@@ -101,14 +112,14 @@
#show: doc => conf(
title: [Pandoc Test Suite],
authors: (
- ( name: "John MacFarlane",
+ ( name: [John MacFarlane],
affiliation: "",
email: "" ),
- ( name: "Anonymous",
+ ( name: [Anonymous],
affiliation: "",
email: "" ),
),
- date: "July 17, 2006",
+ date: [July 17, 2006],
cols: 1,
doc,
)