From 0e92d9483ce55ca2dc3a7a2d12897ac0e25f4dbd Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 30 May 2024 12:00:48 -0600 Subject: 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 --- data/templates/default.typst | 10 +++++----- data/templates/template.typst | 13 ++++++++++++- 2 files changed, 17 insertions(+), 6 deletions(-) (limited to 'data') 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( -- cgit v1.2.3