diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-02-24 14:09:38 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-02-24 14:09:38 +0100 |
| commit | 448844d66cef5f4980d0575e783757264c962bb5 (patch) | |
| tree | f280aaef927da2a30c18f13cc124c8eb77ad3abf /library | |
| parent | 6547c2d6d5b25f44e52ac56698ed08ff6a5dbb3a (diff) | |
Allow multiple authors
Diffstat (limited to 'library')
| -rw-r--r-- | library/src/layout/grid.rs | 5 | ||||
| -rw-r--r-- | library/src/meta/document.rs | 16 | ||||
| -rw-r--r-- | library/src/text/misc.rs | 2 | ||||
| -rw-r--r-- | library/src/text/mod.rs | 5 |
4 files changed, 16 insertions, 12 deletions
diff --git a/library/src/layout/grid.rs b/library/src/layout/grid.rs index 626cb82d..d0df8794 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::<StrResult<_>>()?), } castable! { diff --git a/library/src/meta/document.rs b/library/src/meta/document.rs index 32e944dc..1d349b89 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<EcoString> = None; - /// The document's author. + /// The document's authors. #[property(referenced)] - pub const AUTHOR: Option<EcoString> = 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<EcoString>); + +castable! { + Author, + v: EcoString => Self(vec![v]), + v: Array => Self(v.into_iter().map(Value::cast).collect::<StrResult<_>>()?), +} diff --git a/library/src/text/misc.rs b/library/src/text/misc.rs index 43aea021..68d46d80 100644 --- a/library/src/text/misc.rs +++ b/library/src/text/misc.rs @@ -374,5 +374,5 @@ pub fn smallcaps(args: &mut Args) -> SourceResult<Value> { #[func] pub fn lorem(args: &mut Args) -> SourceResult<Value> { 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 1ef32fa4..2c7cac04 100644 --- a/library/src/text/mod.rs +++ b/library/src/text/mod.rs @@ -548,10 +548,7 @@ pub struct FallbackList(pub Vec<FontFamily>); 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::<StrResult<_>>()?), } /// The size of text. |
