aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc')
-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 b13c4bf2c..8eba3b2cf 100644
--- a/src/Text/Pandoc/Readers/DocBook.hs
+++ b/src/Text/Pandoc/Readers/DocBook.hs
@@ -9,7 +9,7 @@ import Data.Generics
import Data.Monoid
import Data.Char (isSpace)
import Control.Monad.State
-import Control.Applicative ((<$>), (<$))
+import Control.Applicative ((<$>))
import Data.List (intersperse)
{-
@@ -504,7 +504,7 @@ data DBState = DBState{ dbSectionLevel :: Int
} deriving Show
readDocBook :: ParserState -> String -> Pandoc
-readDocBook st inp = setTitle (dbDocTitle st')
+readDocBook _ inp = setTitle (dbDocTitle st')
$ setAuthors (dbDocAuthors st')
$ setDate (dbDocDate st')
$ doc $ mconcat bs
@@ -547,6 +547,12 @@ attrValue attr elt =
named :: String -> Element -> Bool
named s e = qName (elName e) == s
+-- Trim leading and trailing newline characters
+trimNl :: String -> String
+trimNl = reverse . go . reverse . go
+ where go ('\n':xs) = xs
+ go xs = xs
+
-- meld text into beginning of first paragraph of Blocks.
-- assumes Blocks start with a Para; if not, does nothing.
addToStart :: Inlines -> Blocks -> Blocks
@@ -626,8 +632,8 @@ parseBlock (Elem e) =
"book" -> modify (\st -> st{ dbBook = True }) >> getTitle >> getBlocks e
"table" -> parseTable
"informaltable" -> parseTable
- "screen" -> return $ codeBlock $ strContent e -- TODO attrs
- "programlisting" -> return $ codeBlock $ strContent e -- TODO attrs
+ "screen" -> return $ codeBlock $ trimNl . strContent $ e -- TODO attrs
+ "programlisting" -> return $ codeBlock $ trimNl . strContent $ e -- TODO attrs
"?xml" -> return mempty
_ -> getBlocks e
where getBlocks e' = mconcat <$> (mapM parseBlock $ elContent e')