From 6b783d38eaf356213cd6015e6d9d50eb57dcad10 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 8 May 2012 21:02:17 -0700 Subject: DocBook reader: Fixed some compiler warnings. --- src/Text/Pandoc/Readers/DocBook.hs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/Text') 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') -- cgit v1.2.3