diff --git a/crates/typst-library/src/meta/document.rs b/crates/typst-library/src/meta/document.rs index f6ff6812e..581be60c2 100644 --- a/crates/typst-library/src/meta/document.rs +++ b/crates/typst-library/src/meta/document.rs @@ -13,7 +13,7 @@ use crate::prelude::*; /// rule must appear before any of the document's contents. /// /// ```example -/// #set document(title: "Hello") +/// #set document(title: [Hello]) /// /// This has no visible output, but /// embeds metadata into the PDF! @@ -25,7 +25,10 @@ use crate::prelude::*; pub struct DocumentElem { /// The document's title. This is often rendered as the title of the /// PDF viewer window. - pub title: Option, + /// + /// While this can be arbitrary content, PDF viewers only support plain text + /// titles, so the conversion might be lossy. + pub title: Option, /// The document's authors. pub author: Author, @@ -90,7 +93,7 @@ impl LayoutRoot for DocumentElem { Ok(Document { pages, - title: self.title(styles), + title: self.title(styles).map(|content| content.plain_text()), author: self.author(styles).0, keywords: self.keywords(styles).0, date: self.date(styles), diff --git a/tests/typ/meta/document.typ b/tests/typ/meta/document.typ index 43e4ca399..33c15dbce 100644 --- a/tests/typ/meta/document.typ +++ b/tests/typ/meta/document.typ @@ -2,7 +2,7 @@ --- // This is okay. -#set document(title: "Hello") +#set document(title: [Hello]) What's up? --- @@ -24,7 +24,7 @@ What's up? Hello // Error: 2-30 document set rules must appear before any content -#set document(title: "Hello") +#set document(title: [Hello]) --- // Error: 10-12 can only be used in set rules @@ -33,7 +33,7 @@ Hello --- #box[ // Error: 4-32 document set rules are not allowed inside of containers - #set document(title: "Hello") + #set document(title: [Hello]) ] ---