From 7d5b9a716f48df3f7e9ca35839defcc2ee131b33 Mon Sep 17 00:00:00 2001 From: Tobias Schmitz Date: Mon, 7 Jul 2025 12:30:56 +0200 Subject: [PATCH] feat: wrap table cell content in a paragraph --- crates/typst-pdf/src/tags/table.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/typst-pdf/src/tags/table.rs b/crates/typst-pdf/src/tags/table.rs index 21387ad5d..35c8e1b01 100644 --- a/crates/typst-pdf/src/tags/table.rs +++ b/crates/typst-pdf/src/tags/table.rs @@ -180,7 +180,10 @@ impl TableCtx { .into(), }; - Some(TagNode::Group(tag, cell.nodes)) + // Wrap content in a paragraph. + // TODO: maybe avoid nested paragraphs? + let par = TagNode::Group(TagKind::P.into(), cell.nodes); + Some(TagNode::Group(tag, vec![par])) }) .collect(); @@ -399,7 +402,7 @@ mod tests { TagNode::Group( TagKind::TH(TableHeaderCell::new(scope).with_headers(TagIdRefs { ids })) .with_id(Some(id)), - Vec::new(), + vec![TagNode::Group(TagKind::P.into(), Vec::new())], ) } @@ -410,7 +413,7 @@ mod tests { .collect(); TagNode::Group( TagKind::TD(TableDataCell::new().with_headers(TagIdRefs { ids })).into(), - Vec::new(), + vec![TagNode::Group(TagKind::P.into(), Vec::new())], ) }