aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/HTML.hs13
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs7
2 files changed, 15 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs
index b32264d61..2c1034d1f 100644
--- a/src/Text/Pandoc/Readers/HTML.hs
+++ b/src/Text/Pandoc/Readers/HTML.hs
@@ -347,9 +347,16 @@ pRawTag = do
pDiv :: TagParser Blocks
pDiv = try $ do
guardEnabled Ext_native_divs
- TagOpen _ attr <- lookAhead $ pSatisfy $ tagOpen (=="div") (const True)
- contents <- pInTags "div" block
- return $ B.divWith (mkAttr attr) contents
+ let isDivLike "div" = True
+ isDivLike "section" = True
+ isDivLike _ = False
+ TagOpen tag attr <- lookAhead $ pSatisfy $ tagOpen isDivLike (const True)
+ contents <- pInTags tag block
+ let (ident, classes, kvs) = mkAttr attr
+ let classes' = if tag == "section"
+ then "section":classes
+ else classes
+ return $ B.divWith (ident, classes', kvs) contents
pRawHtmlBlock :: TagParser Blocks
pRawHtmlBlock = do
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index a2778ea97..6218de324 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -448,12 +448,15 @@ blockToHtml opts (Para [Image txt (s,'f':'i':'g':':':tit)]) = do
blockToHtml opts (Para lst) = do
contents <- inlineListToHtml opts lst
return $ H.p contents
-blockToHtml opts (Div attr@(_,classes,_) bs) = do
+blockToHtml opts (Div attr@(ident, classes, kvs) bs) = do
let speakerNotes = "notes" `elem` classes
-- we don't want incremental output inside speaker notes, see #1394
let opts' = if speakerNotes then opts{ writerIncremental = False } else opts
contents <- blockListToHtml opts' bs
let contents' = nl opts >> contents >> nl opts
+ let (divtag, classes') = if writerHtml5 opts && "section" `elem` classes
+ then (H5.section, filter (/= "section") classes)
+ else (H.div, classes)
return $
if speakerNotes
then case writerSlideVariant opts of
@@ -462,7 +465,7 @@ blockToHtml opts (Div attr@(_,classes,_) bs) = do
! (H5.customAttribute "role" "note")
NoSlides -> addAttrs opts' attr $ H.div $ contents'
_ -> mempty
- else addAttrs opts attr $ H.div $ contents'
+ else addAttrs opts (ident, classes', kvs) $ divtag $ contents'
blockToHtml opts (RawBlock f str)
| f == Format "html" = return $ preEscapedString str
| f == Format "latex" =