git.iko.soy/typeable/pandoc
on master help sign in
DocBook reader: Support language attribute in programlisting.
commit79e83749bf75770e7a53e9982dd2f9060e736f89 authorJohn MacFarlane <fiddlosopher@gmail.com> dateThu 10 May 2012, 10:10 (14 years ago) parent4d9a132
1 file changed+10−4
src/Text/Pandoc/Readers/DocBook.hs+10−4
src/Text/Pandoc/Readers/DocBook.hs+10−4
@@ -650,13 +650,19 @@ parseBlock (Elem e) =
650650 "book" -> modify (\st -> st{ dbBook = True }) >> getTitle >> getBlocks e
651651 "table" -> parseTable
652652 "informaltable" -> parseTable
653− "literallayout" -> return $ codeBlock $ trimNl . strContent $ e -- TODO attrs
654− "computeroutput" -> return $ codeBlock $ trimNl . strContent $ e -- TODO attrs
655− "screen" -> return $ codeBlock $ trimNl . strContent $ e -- TODO attrs
656− "programlisting" -> return $ codeBlock $ trimNl . strContent $ e -- TODO attrs
653+ "literallayout" -> codeBlockWithLang ["literallayout"]
654+ "computeroutput" -> codeBlockWithLang ["computeroutput"]
655+ "screen" -> codeBlockWithLang ["screen"]
656+ "programlisting" -> codeBlockWithLang []
657657 "?xml" -> return mempty
658658 _ -> getBlocks e
659659 where getBlocks e' = mconcat <$> (mapM parseBlock $ elContent e')
660+ codeBlockWithLang classes = do
661+ let classes' = case attrValue "language" e of
662+ "" -> classes
663+ x -> x:classes
664+ return $ codeBlockWith (attrValue "id" e, classes', [])
665+ $ trimNl $ strContent e
660666 skipWhite (Text (CData _ s _):xs) | all isSpace s = skipWhite xs
661667 | otherwise = xs
662668 skipWhite xs = xs