diff options
| author | Laurenz <laurmaedje@gmail.com> | 2025-07-08 10:52:43 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-08 08:52:43 +0000 |
| commit | 0a3c6939dd274f40672484695d909c2cc0d0d755 (patch) | |
| tree | 465c10338230b895fdd06c8b3491f1734e8a2932 /crates/typst-library/src/model/enum.rs | |
| parent | 36ecbb2c8dccc1a31c43fee1466f1425844d8607 (diff) | |
Rewrite foundations of native elements (#6547)
Diffstat (limited to 'crates/typst-library/src/model/enum.rs')
| -rw-r--r-- | crates/typst-library/src/model/enum.rs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/crates/typst-library/src/model/enum.rs b/crates/typst-library/src/model/enum.rs index f1f93702..8c191658 100644 --- a/crates/typst-library/src/model/enum.rs +++ b/crates/typst-library/src/model/enum.rs @@ -117,7 +117,6 @@ pub struct EnumElem { /// + Numbering! /// ``` #[default(Numbering::Pattern(NumberingPattern::from_str("1.").unwrap()))] - #[borrowed] pub numbering: Numbering, /// Which number to start the enumeration with. @@ -157,11 +156,9 @@ pub struct EnumElem { pub reversed: bool, /// The indentation of each item. - #[resolve] pub indent: Length, /// The space between the numbering and the body of each item. - #[resolve] #[default(Em::new(0.5).into())] pub body_indent: Length, @@ -228,19 +225,19 @@ impl EnumElem { impl Show for Packed<EnumElem> { fn show(&self, engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> { - let tight = self.tight(styles); + let tight = self.tight.get(styles); - if TargetElem::target_in(styles).is_html() { + if styles.get(TargetElem::target).is_html() { let mut elem = HtmlElem::new(tag::ol); - if self.reversed(styles) { + if self.reversed.get(styles) { elem = elem.with_attr(attr::reversed, "reversed"); } - if let Some(n) = self.start(styles).custom() { + if let Some(n) = self.start.get(styles).custom() { elem = elem.with_attr(attr::start, eco_format!("{n}")); } let body = Content::sequence(self.children.iter().map(|item| { let mut li = HtmlElem::new(tag::li); - if let Some(nr) = item.number(styles) { + if let Some(nr) = item.number.get(styles) { li = li.with_attr(attr::value, eco_format!("{nr}")); } // Text in wide enums shall always turn into paragraphs. @@ -260,8 +257,9 @@ impl Show for Packed<EnumElem> { if tight { let spacing = self - .spacing(styles) - .unwrap_or_else(|| ParElem::leading_in(styles).into()); + .spacing + .get(styles) + .unwrap_or_else(|| styles.get(ParElem::leading)); let v = VElem::new(spacing.into()).with_weak(true).with_attach(true).pack(); realized = v + realized; } |
