aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2012-05-10 10:10:24 -0700
committerJohn MacFarlane <fiddlosopher@gmail.com>2012-05-10 10:10:24 -0700
commit79e83749bf75770e7a53e9982dd2f9060e736f89 (patch)
treee7ae0c3c2756144d616801ee2016d2474ee6e16b /src/Text
parent4d9a1324aedaac2a73bcf611687655453b400748 (diff)
downloadpandoc-79e83749bf75770e7a53e9982dd2f9060e736f89.tar.gz
DocBook reader: Support language attribute in programlisting.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/DocBook.hs14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Readers/DocBook.hs b/src/Text/Pandoc/Readers/DocBook.hs
index 0d0adf649..aed7b5977 100644
--- a/src/Text/Pandoc/Readers/DocBook.hs
+++ b/src/Text/Pandoc/Readers/DocBook.hs
@@ -650,13 +650,19 @@ parseBlock (Elem e) =
"book" -> modify (\st -> st{ dbBook = True }) >> getTitle >> getBlocks e
"table" -> parseTable
"informaltable" -> parseTable
- "literallayout" -> return $ codeBlock $ trimNl . strContent $ e -- TODO attrs
- "computeroutput" -> return $ codeBlock $ trimNl . strContent $ e -- TODO attrs
- "screen" -> return $ codeBlock $ trimNl . strContent $ e -- TODO attrs
- "programlisting" -> return $ codeBlock $ trimNl . strContent $ e -- TODO attrs
+ "literallayout" -> codeBlockWithLang ["literallayout"]
+ "computeroutput" -> codeBlockWithLang ["computeroutput"]
+ "screen" -> codeBlockWithLang ["screen"]
+ "programlisting" -> codeBlockWithLang []
"?xml" -> return mempty
_ -> getBlocks e
where getBlocks e' = mconcat <$> (mapM parseBlock $ elContent e')
+ codeBlockWithLang classes = do
+ let classes' = case attrValue "language" e of
+ "" -> classes
+ x -> x:classes
+ return $ codeBlockWith (attrValue "id" e, classes', [])
+ $ trimNl $ strContent e
skipWhite (Text (CData _ s _):xs) | all isSpace s = skipWhite xs
| otherwise = xs
skipWhite xs = xs