diff --git a/crates/typst-library/src/layout/repeat.rs b/crates/typst-library/src/layout/repeat.rs index ab042ceb1..ffc149bb2 100644 --- a/crates/typst-library/src/layout/repeat.rs +++ b/crates/typst-library/src/layout/repeat.rs @@ -25,6 +25,7 @@ use crate::layout::{BlockElem, Length}; /// Berlin, the 22nd of December, 2022 /// ] /// ``` +// TODO: should this be a PDF artifact by deafult? #[elem(Locatable, Show)] pub struct RepeatElem { /// The content to repeat. diff --git a/crates/typst-library/src/model/outline.rs b/crates/typst-library/src/model/outline.rs index f88cee342..b98d983d1 100644 --- a/crates/typst-library/src/model/outline.rs +++ b/crates/typst-library/src/model/outline.rs @@ -422,6 +422,7 @@ impl Show for Packed { let context = Context::new(None, Some(styles)); let context = context.track(); + // TODO: prefix should be wrapped in a `Lbl` structure element let prefix = self.prefix(engine, context, span)?; let body = self.body().at(span)?; let page = self.page(engine, context, span)?; diff --git a/crates/typst-library/src/pdf/accessibility.rs b/crates/typst-library/src/pdf/accessibility.rs index 586e2cbb1..a0a0bb950 100644 --- a/crates/typst-library/src/pdf/accessibility.rs +++ b/crates/typst-library/src/pdf/accessibility.rs @@ -47,7 +47,7 @@ cast! { } impl Show for Packed { - #[typst_macros::time(name = "underline", span = self.span())] + #[typst_macros::time(name = "pdf.artifact", span = self.span())] fn show(&self, _: &mut Engine, _: StyleChain) -> SourceResult { Ok(self.body.clone()) } diff --git a/crates/typst-pdf/src/tags.rs b/crates/typst-pdf/src/tags.rs index 92d3bfe78..28dc9ddec 100644 --- a/crates/typst-pdf/src/tags.rs +++ b/crates/typst-pdf/src/tags.rs @@ -9,9 +9,11 @@ use krilla::tagging::{ use typst_library::foundations::{Content, LinkMarker, StyleChain}; use typst_library::introspection::Location; use typst_library::model::{ - Destination, HeadingElem, Outlinable, OutlineElem, OutlineEntry, + Destination, FigureCaption, FigureElem, HeadingElem, Outlinable, OutlineElem, + OutlineEntry, }; use typst_library::pdf::{ArtifactElem, ArtifactKind}; +use typst_library::visualize::ImageElem; use crate::convert::GlobalContext; use crate::link::LinkAnnotation; @@ -210,6 +212,30 @@ pub(crate) fn handle_start( Tag::TOC } else if let Some(_) = elem.to_packed::() { Tag::TOCI + } else if let Some(_) = elem.to_packed::() { + let alt = None; // TODO + Tag::Figure(alt) + } else if let Some(image) = elem.to_packed::() { + let alt = image.alt(StyleChain::default()).map(|s| s.to_string()); + + end_open(gc, surface); + let id = surface.start_tagged(ContentTag::Other); + let mut node = TagNode::Leaf(id); + + if let Some(Tag::Figure(alt_text)) = gc.tags.parent().0 { + // HACK: set alt text of outer figure tag, if the contained image + // has alt text specified + if alt_text.is_none() { + *alt_text = alt; + } + } else { + node = TagNode::Group(Tag::Figure(alt), vec![node]); + } + gc.tags.push(node); + + return; + } else if let Some(_) = elem.to_packed::() { + Tag::Caption } else if let Some(link) = elem.to_packed::() { link_id = Some(gc.tags.next_link_id()); if let Destination::Position(_) | Destination::Location(_) = link.dest {