From 38df055ea4819a56772e6c8cc90167da302695c8 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 21 Sep 2026 05:39:24 +0000 Subject: [PATCH] Fix ensureValidXmlIdentifiers for Figure and table sub-elements. walkAttr only rewrote attributes on Header, CodeBlock, Table, and Div, while fixLinks rewrote every internal link starting with a non-letter. As a result, ids on Figure, TableHead, TableBody, TableFoot, Row, and Cell were left unchanged while links to them were renamed, producing broken internal links in the HTML4/XHTML, EPUB, DocBook, TEI, ICML, FB2, and ODT writers. Co-Authored-By: Claude --- src/Text/Pandoc/Writers/Shared.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Text/Pandoc/Writers/Shared.hs b/src/Text/Pandoc/Writers/Shared.hs index ba2fe6984..824ec4fdd 100644 --- a/src/Text/Pandoc/Writers/Shared.hs +++ b/src/Text/Pandoc/Writers/Shared.hs @@ -852,10 +852,20 @@ walkAttr f = walk goInline . walk goBlock goBlock (Header lev attr ils) = Header lev (f attr) ils goBlock (CodeBlock attr txt) = CodeBlock (f attr) txt goBlock (Table attr cap colspecs thead tbodies tfoot) = - Table (f attr) cap colspecs thead tbodies tfoot + Table (f attr) cap colspecs + (goTableHead thead) (map goTableBody tbodies) (goTableFoot tfoot) goBlock (Div attr bs) = Div (f attr) bs + goBlock (Figure attr cap bs) = Figure (f attr) cap bs goBlock x = x + goTableHead (TableHead attr rows) = TableHead (f attr) (map goRow rows) + goTableBody (TableBody attr rhc hd bd) = + TableBody (f attr) rhc (map goRow hd) (map goRow bd) + goTableFoot (TableFoot attr rows) = TableFoot (f attr) (map goRow rows) + goRow (Row attr cells) = Row (f attr) (map goCell cells) + goCell (Cell attr align rowspan colspan bs) = + Cell (f attr) align rowspan colspan bs + -- | Convert links to spans; most useful when writing elements that must not -- contain links, e.g. to avoid nested links. removeLinks :: [Inline] -> [Inline]