HTML writer: Unwrap "wrapper" divs.

Some of the readers (e.g. djot) add "wrapper" divs to hold attributes
for elements that have no slot for attributes in the pandoc AST. With
this change, the HTML reader "unwraps" these wrappers so that the
attributes go on the intended elements.

Closes #11014.
This commit is contained in:
John MacFarlane
2025-08-02 10:50:41 -07:00
parent 52e28c31ed
commit bb46c277ca
2 changed files with 14 additions and 0 deletions
+5
View File
@@ -845,6 +845,11 @@ blockToHtmlInner opts (Div (ident, "section":dclasses, dkvs)
if null innerSecs
then mempty
else nl <> innerContents
blockToHtmlInner opts (Div (ident, classes, kvs) [b])
| Just "1" <- lookup "wrapper" kvs
-- unwrap "wrapper" div, putting attr on child
= blockToHtmlInner opts b >>=
addAttrs opts (ident, classes, [(k,v) | (k,v) <- kvs, k /= "wrapper"])
blockToHtmlInner opts (Div attr@(ident, classes, kvs') bs) = do
html5 <- gets stHtml5
slideVariant <- gets stSlideVariant
+9
View File
@@ -0,0 +1,9 @@
```
% pandoc -f djot -t html
{.foo}
- bar
^D
<ul class="foo">
<li>bar</li>
</ul>
```