git.iko.soy/typeable/pandoc
on master help sign in
HTML reader: Preserve all header attributes.
commit14b64ed46c72adbaa4c1c6ed26b10df89756e178 authorJohn MacFarlane <fiddlosopher@gmail.com> dateSat 16 Feb 2013, 17:01 (14 years ago) parentcc410a7
1 file changed+4−2
src/Text/Pandoc/Readers/HTML.hs+4−2
src/Text/Pandoc/Readers/HTML.hs+4−2
@@ -199,10 +199,12 @@ pHeader = try $ do
199199 let bodyTitle = TagOpen tagtype attr ~== TagOpen "h1" [("class","title")]
200200 let level = read (drop 1 tagtype)
201201 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"]
202205 return $ if bodyTitle
203206 then [] -- skip a representation of the title in the body
204− else [Header level (fromAttrib "id" $
205− TagOpen tagtype attr, [], []) $
207+ else [Header level (ident, classes, keyvals) $
206208 normalizeSpaces contents]
207209
208210pHrule :: TagParser [Block]