aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/HTML.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-02-16 17:01:44 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-02-16 17:01:44 -0800
commit14b64ed46c72adbaa4c1c6ed26b10df89756e178 (patch)
tree779504fc7432f6d038d806fe8402142cbeec6814 /src/Text/Pandoc/Readers/HTML.hs
parentcc410a71b58de1fa0e508a092b7c1d8ba6d3d3ab (diff)
downloadpandoc-14b64ed46c72adbaa4c1c6ed26b10df89756e178.tar.gz
HTML reader: Preserve all header attributes.
Diffstat (limited to 'src/Text/Pandoc/Readers/HTML.hs')
-rw-r--r--src/Text/Pandoc/Readers/HTML.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs
index c06faff1b..6dbba8c35 100644
--- a/src/Text/Pandoc/Readers/HTML.hs
+++ b/src/Text/Pandoc/Readers/HTML.hs
@@ -199,10 +199,12 @@ pHeader = try $ do
let bodyTitle = TagOpen tagtype attr ~== TagOpen "h1" [("class","title")]
let level = read (drop 1 tagtype)
contents <- liftM concat $ manyTill inline (pCloses tagtype <|> eof)
+ let ident = maybe "" id $ lookup "id" attr
+ let classes = maybe [] words $ lookup "class" attr
+ let keyvals = [(k,v) | (k,v) <- attr, k /= "class", k /= "id"]
return $ if bodyTitle
then [] -- skip a representation of the title in the body
- else [Header level (fromAttrib "id" $
- TagOpen tagtype attr, [], []) $
+ else [Header level (ident, classes, keyvals) $
normalizeSpaces contents]
pHrule :: TagParser [Block]