mirror of
https://github.com/typst/typst
synced 2025-06-22 21:32:52 +08:00
feat: [no ci] write tags for more elements
This commit is contained in:
parent
e10050a23f
commit
e6a222647a
@ -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.
|
||||
|
@ -422,6 +422,7 @@ impl Show for Packed<OutlineEntry> {
|
||||
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)?;
|
||||
|
@ -47,7 +47,7 @@ cast! {
|
||||
}
|
||||
|
||||
impl Show for Packed<ArtifactElem> {
|
||||
#[typst_macros::time(name = "underline", span = self.span())]
|
||||
#[typst_macros::time(name = "pdf.artifact", span = self.span())]
|
||||
fn show(&self, _: &mut Engine, _: StyleChain) -> SourceResult<Content> {
|
||||
Ok(self.body.clone())
|
||||
}
|
||||
|
@ -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::<OutlineEntry>() {
|
||||
Tag::TOCI
|
||||
} else if let Some(_) = elem.to_packed::<FigureElem>() {
|
||||
let alt = None; // TODO
|
||||
Tag::Figure(alt)
|
||||
} else if let Some(image) = elem.to_packed::<ImageElem>() {
|
||||
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::<FigureCaption>() {
|
||||
Tag::Caption
|
||||
} else if let Some(link) = elem.to_packed::<LinkMarker>() {
|
||||
link_id = Some(gc.tags.next_link_id());
|
||||
if let Destination::Position(_) | Destination::Location(_) = link.dest {
|
||||
|
Loading…
x
Reference in New Issue
Block a user