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 <noreply@anthropic.com>
This commit is contained in:
John MacFarlane
2026-09-21 05:39:24 +00:00
co-authored by Claude
parent 8967b75e8e
commit 38df055ea4
+11 -1
View File
@@ -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]