aboutsummaryrefslogtreecommitdiff
path: root/data
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 /data
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 'data')
-rw-r--r--data/templates/default.typst10
-rw-r--r--data/templates/template.typst13
2 files changed, 17 insertions, 6 deletions
diff --git a/data/templates/default.typst b/data/templates/default.typst
index 37e8a6247..c5e602e4a 100644
--- a/data/templates/default.typst
+++ b/data/templates/default.typst
@@ -31,11 +31,11 @@ $if(author)$
authors: (
$for(author)$
$if(author.name)$
- ( name: "$author.name$",
- affiliation: "$author.affiliation$",
- email: "$author.email$" ),
+ ( name: [$author.name$],
+ affiliation: [$author.affiliation$],
+ email: [$author.email$] ),
$else$
- ( name: "$author$",
+ ( name: [$author$],
affiliation: "",
email: "" ),
$endif$
@@ -46,7 +46,7 @@ $if(keywords)$
keywords: ($for(keywords)$$keyword$$sep$,$endfor$),
$endif$
$if(date)$
- date: "$date$",
+ date: [$date$],
$endif$
$if(lang)$
lang: "$lang$",
diff --git a/data/templates/template.typst b/data/templates/template.typst
index 8672647be..02f15cbfc 100644
--- a/data/templates/template.typst
+++ b/data/templates/template.typst
@@ -1,3 +1,14 @@
+#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,
@@ -17,7 +28,7 @@
) = {
set document(
title: title,
- author: authors.map(author => author.name),
+ author: authors.map(author => content-to-string(author.name)),
keywords: keywords,
)
set page(