diff options
| author | John MacFarlane <[email protected]> | 2025-08-02 10:49:01 -0700 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2025-08-02 10:50:41 -0700 |
| commit | bb46c277cab2035fe6fe0bccf8a18f8b2f24ff0b (patch) | |
| tree | 3b4a49841d31b7a7ae2b70152c0424fd3d666782 /src | |
| parent | 52e28c31edd785d86212644da67808e2acc8fb0c (diff) | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/Writers/HTML.hs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index bb54f0f82..d48a29c5b 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -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 |
