feat: generate tags for terms

This commit is contained in:
Tobias Schmitz 2025-07-14 16:35:13 +02:00
parent 4b57373653
commit 0df9da7ce6
No known key found for this signature in database
2 changed files with 7 additions and 3 deletions

View File

@ -179,9 +179,9 @@ const TERMS_RULE: ShowFn<TermsElem> = |elem, _, styles| {
for child in elem.children.iter() {
let mut seq = vec![];
seq.extend(unpad.clone());
seq.push(child.term.clone().strong());
seq.push(PdfMarkerTag::ListItemLabel(child.term.clone().strong()));
seq.push(separator.clone());
seq.push(child.description.clone());
seq.push(PdfMarkerTag::ListItemBody(child.description.clone()));
// Text in wide term lists shall always turn into paragraphs.
if !tight {

View File

@ -18,7 +18,7 @@ use typst_library::introspection::Location;
use typst_library::layout::RepeatElem;
use typst_library::model::{
Destination, EnumElem, FigureCaption, FigureElem, HeadingElem, ListElem, Outlinable,
OutlineEntry, TableCell, TableElem,
OutlineEntry, TableCell, TableElem, TermsElem,
};
use typst_library::pdf::{ArtifactElem, ArtifactKind, PdfMarkerTag, PdfMarkerTagKind};
use typst_library::visualize::ImageElem;
@ -81,6 +81,10 @@ pub(crate) fn handle_start(
let numbering = ListNumbering::Decimal; // TODO: infer numbering from `enum.numbering`
push_stack(gc, loc, StackEntryKind::List(ListCtx::new(numbering)))?;
return Ok(());
} else if let Some(_enumeration) = elem.to_packed::<TermsElem>() {
let numbering = ListNumbering::None;
push_stack(gc, loc, StackEntryKind::List(ListCtx::new(numbering)))?;
return Ok(());
} else if let Some(_) = elem.to_packed::<FigureElem>() {
// Wrap the figure tag and the sibling caption in a container, if the
// caption is contained within the figure like recommended for tables