git.iko.soy/typeable/pandoc
on master help sign in
DocBook reader: Support language attribute in programlisting.
79e8374John MacFarlane
src/Text/Pandoc/Readers/DocBook.hs+10−4
@@ -650,13 +650,19 @@ parseBlock (Elem e) =
650 "book" -> modify (\st -> st{ dbBook = True }) >> getTitle >> getBlocks e
650 "book" -> modify (\st -> st{ dbBook = True }) >> getTitle >> getBlocks e
651 "table" -> parseTable
651 "table" -> parseTable
652 "informaltable" -> parseTable
652 "informaltable" -> parseTable
653− "literallayout" -> return $ codeBlock $ trimNl . strContent $ e -- TODO attrs
653+ "literallayout" -> codeBlockWithLang ["literallayout"]
654− "computeroutput" -> return $ codeBlock $ trimNl . strContent $ e -- TODO attrs
654+ "computeroutput" -> codeBlockWithLang ["computeroutput"]
655− "screen" -> return $ codeBlock $ trimNl . strContent $ e -- TODO attrs
655+ "screen" -> codeBlockWithLang ["screen"]
656− "programlisting" -> return $ codeBlock $ trimNl . strContent $ e -- TODO attrs
656+ "programlisting" -> codeBlockWithLang []
657 "?xml" -> return mempty
657 "?xml" -> return mempty
658 _ -> getBlocks e
658 _ -> getBlocks e
659 where getBlocks e' = mconcat <$> (mapM parseBlock $ elContent e')
659 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
660 skipWhite (Text (CData _ s _):xs) | all isSpace s = skipWhite xs
666 skipWhite (Text (CData _ s _):xs) | all isSpace s = skipWhite xs
661 | otherwise = xs
667 | otherwise = xs
662 skipWhite xs = xs
668 skipWhite xs = xs