mirror of
https://github.com/typst/typst
synced 2025-07-27 22:37:54 +08:00
feat: generate tags for terms
This commit is contained in:
parent
4b57373653
commit
0df9da7ce6
@ -179,9 +179,9 @@ const TERMS_RULE: ShowFn<TermsElem> = |elem, _, styles| {
|
|||||||
for child in elem.children.iter() {
|
for child in elem.children.iter() {
|
||||||
let mut seq = vec![];
|
let mut seq = vec![];
|
||||||
seq.extend(unpad.clone());
|
seq.extend(unpad.clone());
|
||||||
seq.push(child.term.clone().strong());
|
seq.push(PdfMarkerTag::ListItemLabel(child.term.clone().strong()));
|
||||||
seq.push(separator.clone());
|
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.
|
// Text in wide term lists shall always turn into paragraphs.
|
||||||
if !tight {
|
if !tight {
|
||||||
|
@ -18,7 +18,7 @@ use typst_library::introspection::Location;
|
|||||||
use typst_library::layout::RepeatElem;
|
use typst_library::layout::RepeatElem;
|
||||||
use typst_library::model::{
|
use typst_library::model::{
|
||||||
Destination, EnumElem, FigureCaption, FigureElem, HeadingElem, ListElem, Outlinable,
|
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::pdf::{ArtifactElem, ArtifactKind, PdfMarkerTag, PdfMarkerTagKind};
|
||||||
use typst_library::visualize::ImageElem;
|
use typst_library::visualize::ImageElem;
|
||||||
@ -81,6 +81,10 @@ pub(crate) fn handle_start(
|
|||||||
let numbering = ListNumbering::Decimal; // TODO: infer numbering from `enum.numbering`
|
let numbering = ListNumbering::Decimal; // TODO: infer numbering from `enum.numbering`
|
||||||
push_stack(gc, loc, StackEntryKind::List(ListCtx::new(numbering)))?;
|
push_stack(gc, loc, StackEntryKind::List(ListCtx::new(numbering)))?;
|
||||||
return Ok(());
|
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>() {
|
} else if let Some(_) = elem.to_packed::<FigureElem>() {
|
||||||
// Wrap the figure tag and the sibling caption in a container, if the
|
// Wrap the figure tag and the sibling caption in a container, if the
|
||||||
// caption is contained within the figure like recommended for tables
|
// caption is contained within the figure like recommended for tables
|
||||||
|
Loading…
x
Reference in New Issue
Block a user