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-pdf | |
| parent | 36ecbb2c8dccc1a31c43fee1466f1425844d8607 (diff) | |
Rewrite foundations of native elements (#6547)
Diffstat (limited to 'crates/typst-pdf')
| -rw-r--r-- | crates/typst-pdf/src/convert.rs | 2 | ||||
| -rw-r--r-- | crates/typst-pdf/src/embed.rs | 16 | ||||
| -rw-r--r-- | crates/typst-pdf/src/outline.rs | 7 |
3 files changed, 15 insertions, 10 deletions
diff --git a/crates/typst-pdf/src/convert.rs b/crates/typst-pdf/src/convert.rs index 645d56f1..9e2aa87b 100644 --- a/crates/typst-pdf/src/convert.rs +++ b/crates/typst-pdf/src/convert.rs @@ -597,7 +597,7 @@ fn collect_named_destinations( let mut seen = HashSet::new(); document .introspector - .query(&HeadingElem::elem().select()) + .query(&HeadingElem::ELEM.select()) .iter() .filter_map(|elem| elem.location().zip(elem.label())) .filter(|&(_, label)| seen.insert(label)) diff --git a/crates/typst-pdf/src/embed.rs b/crates/typst-pdf/src/embed.rs index 36330c44..c62178cf 100644 --- a/crates/typst-pdf/src/embed.rs +++ b/crates/typst-pdf/src/embed.rs @@ -11,20 +11,24 @@ pub(crate) fn embed_files( typst_doc: &PagedDocument, document: &mut Document, ) -> SourceResult<()> { - let elements = typst_doc.introspector.query(&EmbedElem::elem().select()); + let elements = typst_doc.introspector.query(&EmbedElem::ELEM.select()); for elem in &elements { let embed = elem.to_packed::<EmbedElem>().unwrap(); let span = embed.span(); let derived_path = &embed.path.derived; let path = derived_path.to_string(); - let mime_type = - embed.mime_type(StyleChain::default()).clone().map(|s| s.to_string()); + let mime_type = embed + .mime_type + .get_ref(StyleChain::default()) + .as_ref() + .map(|s| s.to_string()); let description = embed - .description(StyleChain::default()) - .clone() + .description + .get_ref(StyleChain::default()) + .as_ref() .map(|s| s.to_string()); - let association_kind = match embed.relationship(StyleChain::default()) { + let association_kind = match embed.relationship.get(StyleChain::default()) { None => AssociationKind::Unspecified, Some(e) => match e { EmbeddedFileRelationship::Source => AssociationKind::Source, diff --git a/crates/typst-pdf/src/outline.rs b/crates/typst-pdf/src/outline.rs index e6324309..f73822c4 100644 --- a/crates/typst-pdf/src/outline.rs +++ b/crates/typst-pdf/src/outline.rs @@ -18,7 +18,7 @@ pub(crate) fn build_outline(gc: &GlobalContext) -> Outline { // Therefore, its next descendant must be added at its level, which is // enforced in the manner shown below. let mut last_skipped_level = None; - let elements = &gc.document.introspector.query(&HeadingElem::elem().select()); + let elements = &gc.document.introspector.query(&HeadingElem::ELEM.select()); for elem in elements.iter() { if let Some(page_ranges) = &gc.options.page_ranges { @@ -115,8 +115,9 @@ impl<'a> HeadingNode<'a> { level: element.resolve_level(StyleChain::default()), // 'bookmarked' set to 'auto' falls back to the value of 'outlined'. bookmarked: element - .bookmarked(StyleChain::default()) - .unwrap_or_else(|| element.outlined(StyleChain::default())), + .bookmarked + .get(StyleChain::default()) + .unwrap_or_else(|| element.outlined.get(StyleChain::default())), element, children: Vec::new(), } |
