HTML reader: Preserve all header attributes.

This commit is contained in:
John MacFarlane 2013-02-16 17:01:44 -08:00
parent cc410a71b5
commit 14b64ed46c

View file

@ -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]