diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-10-11 15:25:49 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-10-11 15:25:49 -0700 |
commit | 0e78eba791233b616f2435f2353586f9d3859480 (patch) | |
tree | bcf096faea5bf7b70a1e5ae45dd42d355ff27cfe /src/Text/Pandoc/Readers | |
parent | 60dcaa37d5cbaa9e9109b0a2a448ce663752b90d (diff) | |
download | pandoc-0e78eba791233b616f2435f2353586f9d3859480.tar.gz |
HTML reader/writer: better handling of "section" elements.
Previously `<section>` tags were just parsed as raw HTML
blocks. With this change, section elements are parsed as
Div elements with the class "section". The HTML writer will
use `<section>` tags to render these Divs in HTML5; otherwise
they will be rendered as `<div class="section">`.
Closes #2438.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/HTML.hs | 13 |
1 files changed, 10 insertions, 3 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 |