git.iko.soy/typeable/pandoc
on master help sign in
HTML reader: Preserve all header attributes.
14b64edJohn MacFarlane
src/Text/Pandoc/Readers/HTML.hs+4−2
@@ -199,10 +199,12 @@ pHeader = try $ do
199 let bodyTitle = TagOpen tagtype attr ~== TagOpen "h1" [("class","title")]
199 let bodyTitle = TagOpen tagtype attr ~== TagOpen "h1" [("class","title")]
200 let level = read (drop 1 tagtype)
200 let level = read (drop 1 tagtype)
201 contents <- liftM concat $ manyTill inline (pCloses tagtype <|> eof)
201 contents <- liftM concat $ manyTill inline (pCloses tagtype <|> eof)
202+ let ident = maybe "" id $ lookup "id" attr
203+ let classes = maybe [] words $ lookup "class" attr
204+ let keyvals = [(k,v) | (k,v) <- attr, k /= "class", k /= "id"]
202 return $ if bodyTitle
205 return $ if bodyTitle
203 then [] -- skip a representation of the title in the body
206 then [] -- skip a representation of the title in the body
204− else [Header level (fromAttrib "id" $
207+ else [Header level (ident, classes, keyvals) $
205− TagOpen tagtype attr, [], []) $
206 normalizeSpaces contents]
208 normalizeSpaces contents]
207
209
208pHrule :: TagParser [Block]
210pHrule :: TagParser [Block]