fix: mark table gutter and fill as artifacts

This commit is contained in:
Tobias Schmitz 2025-06-25 17:39:50 +02:00
parent 5bd9accb9c
commit 612aa8fc53
No known key found for this signature in database

View File

@ -12,7 +12,7 @@ use typst_library::foundations::{Content, LinkMarker, Packed, StyleChain};
use typst_library::introspection::Location; use typst_library::introspection::Location;
use typst_library::model::{ use typst_library::model::{
Destination, FigureCaption, FigureElem, HeadingElem, Outlinable, OutlineElem, Destination, FigureCaption, FigureElem, HeadingElem, Outlinable, OutlineElem,
OutlineEntry, TableCell, TableElem, TableHLine, TableVLine, OutlineEntry, TableCell, TableElem,
}; };
use typst_library::pdf::{ArtifactElem, ArtifactKind, PdfTagElem, PdfTagKind}; use typst_library::pdf::{ArtifactElem, ArtifactKind, PdfTagElem, PdfTagKind};
use typst_library::visualize::ImageElem; use typst_library::visualize::ImageElem;
@ -246,6 +246,10 @@ fn start_content<'a, 'b>(
let content = if let Some((_, kind)) = gc.tags.in_artifact { let content = if let Some((_, kind)) = gc.tags.in_artifact {
let ty = artifact_type(kind); let ty = artifact_type(kind);
ContentTag::Artifact(ty) ContentTag::Artifact(ty)
} else if let Some(StackEntryKind::Table(_)) = gc.tags.stack.last().map(|e| &e.kind) {
// Mark any direct child of a table as an aritfact. Any real content
// will be wrapped inside a `TableCell`.
ContentTag::Artifact(ArtifactType::Other)
} else { } else {
content content
}; };
@ -339,12 +343,6 @@ pub(crate) fn handle_start(gc: &mut GlobalContext, elem: &Content) {
} else if let Some(cell) = elem.to_packed::<TableCell>() { } else if let Some(cell) = elem.to_packed::<TableCell>() {
push_stack(gc, loc, StackEntryKind::TableCell(cell.clone())); push_stack(gc, loc, StackEntryKind::TableCell(cell.clone()));
return; return;
} else if let Some(_) = elem.to_packed::<TableHLine>() {
start_artifact(gc, loc, ArtifactKind::Other);
return;
} else if let Some(_) = elem.to_packed::<TableVLine>() {
start_artifact(gc, loc, ArtifactKind::Other);
return;
} else { } else {
return; return;
}; };