@@ -9,7 +9,7 @@ import Data.Generics
99import Data.Monoid
1010import Data.Char (isSpace)
1111import Control.Monad.State
12−import Control.Applicative ((<$>), (<$))
12+import Control.Applicative ((<$>))
1313import Data.List (intersperse)
1414
1515{-
@@ -504,7 +504,7 @@ data DBState = DBState{ dbSectionLevel :: Int
504504 } deriving Show
505505
506506readDocBook :: ParserState -> String -> Pandoc
507−readDocBook st inp = setTitle (dbDocTitle st')
507+readDocBook _ inp = setTitle (dbDocTitle st')
508508 $ setAuthors (dbDocAuthors st')
509509 $ setDate (dbDocDate st')
510510 $ doc $ mconcat bs
@@ -547,6 +547,12 @@ attrValue attr elt =
547547named :: String -> Element -> Bool
548548named s e = qName (elName e) == s
549549
550+-- Trim leading and trailing newline characters
551+trimNl :: String -> String
552+trimNl = reverse . go . reverse . go
553+ where go ('\n':xs) = xs
554+ go xs = xs
555+
550556-- meld text into beginning of first paragraph of Blocks.
551557-- assumes Blocks start with a Para; if not, does nothing.
552558addToStart :: Inlines -> Blocks -> Blocks
@@ -626,8 +632,8 @@ parseBlock (Elem e) =
626632 "book" -> modify (\st -> st{ dbBook = True }) >> getTitle >> getBlocks e
627633 "table" -> parseTable
628634 "informaltable" -> parseTable
629− "screen" -> return $ codeBlock $ strContent e -- TODO attrs
630− "programlisting" -> return $ codeBlock $ strContent e -- TODO attrs
635+ "screen" -> return $ codeBlock $ trimNl . strContent $ e -- TODO attrs
636+ "programlisting" -> return $ codeBlock $ trimNl . strContent $ e -- TODO attrs
631637 "?xml" -> return mempty
632638 _ -> getBlocks e
633639 where getBlocks e' = mconcat <$> (mapM parseBlock $ elContent e')