summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2012-05-08 21:02:17 -0700
committerJohn MacFarlane <fiddlosopher@gmail.com>2012-05-08 21:02:17 -0700
commit6b783d38eaf356213cd6015e6d9d50eb57dcad10 (patch)
tree4f977683ecba42581908b140e400859824878331 /src/Text/Pandoc/Readers
parentc20c139255a83e1dcaf1d923375b3759614adaf3 (diff)
DocBook reader: Fixed some compiler warnings.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-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')