diff --git a/library/src/layout/grid.rs b/library/src/layout/grid.rs index 626cb82dc..d0df8794b 100644 --- a/library/src/layout/grid.rs +++ b/library/src/layout/grid.rs @@ -151,10 +151,7 @@ castable! { TrackSizings, sizing: Sizing => Self(vec![sizing]), count: NonZeroUsize => Self(vec![Sizing::Auto; count.get()]), - values: Array => Self(values - .into_iter() - .filter_map(|v| v.cast().ok()) - .collect()), + values: Array => Self(values.into_iter().map(Value::cast).collect::>()?), } castable! { diff --git a/library/src/meta/document.rs b/library/src/meta/document.rs index 32e944dc1..1d349b89e 100644 --- a/library/src/meta/document.rs +++ b/library/src/meta/document.rs @@ -25,9 +25,9 @@ impl DocumentNode { #[property(referenced)] pub const TITLE: Option = None; - /// The document's author. + /// The document's authors. #[property(referenced)] - pub const AUTHOR: Option = None; + pub const AUTHOR: Author = Author(vec![]); } impl LayoutRoot for DocumentNode { @@ -43,7 +43,7 @@ impl LayoutRoot for DocumentNode { Ok(Document { pages, title: styles.get(Self::TITLE).clone(), - author: styles.get(Self::AUTHOR).clone(), + author: styles.get(Self::AUTHOR).0.clone(), }) } } @@ -54,3 +54,13 @@ impl Debug for DocumentNode { self.0.fmt(f) } } + +/// A list of authors. +#[derive(Debug, Clone, Hash)] +pub struct Author(Vec); + +castable! { + Author, + v: EcoString => Self(vec![v]), + v: Array => Self(v.into_iter().map(Value::cast).collect::>()?), +} diff --git a/library/src/text/misc.rs b/library/src/text/misc.rs index 43aea021b..68d46d802 100644 --- a/library/src/text/misc.rs +++ b/library/src/text/misc.rs @@ -374,5 +374,5 @@ pub fn smallcaps(args: &mut Args) -> SourceResult { #[func] pub fn lorem(args: &mut Args) -> SourceResult { let words: usize = args.expect("number of words")?; - Ok(Value::Str(lipsum::lipsum(words).into())) + Ok(Value::Str(lipsum::lipsum(words).replace("--", "–").into())) } diff --git a/library/src/text/mod.rs b/library/src/text/mod.rs index 1ef32fa44..2c7cac04d 100644 --- a/library/src/text/mod.rs +++ b/library/src/text/mod.rs @@ -548,10 +548,7 @@ pub struct FallbackList(pub Vec); castable! { FallbackList, family: FontFamily => Self(vec![family]), - values: Array => Self(values - .into_iter() - .filter_map(|v| v.cast().ok()) - .collect()), + values: Array => Self(values.into_iter().map(|v| v.cast()).collect::>()?), } /// The size of text. diff --git a/src/doc.rs b/src/doc.rs index f4a4d9686..55e2f467a 100644 --- a/src/doc.rs +++ b/src/doc.rs @@ -25,7 +25,7 @@ pub struct Document { /// The document's title. pub title: Option, /// The document's author. - pub author: Option, + pub author: Vec, } /// A finished layout with elements at fixed positions. diff --git a/src/export/pdf/mod.rs b/src/export/pdf/mod.rs index 69fa805b4..3813bad50 100644 --- a/src/export/pdf/mod.rs +++ b/src/export/pdf/mod.rs @@ -122,9 +122,11 @@ fn write_catalog(ctx: &mut PdfContext) { info.title(TextStr(title)); xmp.title([(None, title.as_str())]); } - if let Some(author) = &ctx.document.author { - info.author(TextStr(author)); - xmp.creator([(author.as_str())]); + + let authors = &ctx.document.author; + if !authors.is_empty() { + info.author(TextStr(&authors.join(", "))); + xmp.creator(authors.iter().map(|s| s.as_str())); } info.creator(TextStr("Typst")); info.finish(); diff --git a/tests/typ/meta/document.typ b/tests/typ/meta/document.typ index e8d536505..f2c7a8bbc 100644 --- a/tests/typ/meta/document.typ +++ b/tests/typ/meta/document.typ @@ -5,6 +5,17 @@ #set document(title: "Hello") What's up? +--- +// This, too. +// Ref: false +#set document(author: ("A", "B")) + +--- +// This, too. +// Error: 23-29 expected string, found integer +#set document(author: (123,)) +What's up? + --- Hello