From e5c4d7002eb5b9c73211186f5f15a82c2731fe31 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 14 Apr 2012 21:50:06 -0700 Subject: Implemented quoted in docbook reader. --- src/Text/Pandoc/Readers/DocBook.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Text/Pandoc/Readers/DocBook.hs b/src/Text/Pandoc/Readers/DocBook.hs index 53260e279..a4f0ee9c4 100644 --- a/src/Text/Pandoc/Readers/DocBook.hs +++ b/src/Text/Pandoc/Readers/DocBook.hs @@ -12,6 +12,7 @@ import Control.Applicative ((<$>)) type DB = State DBState data DBState = DBState{ dbSectionLevel :: Int + , dbQuoteType :: QuoteType , dbDocTitle :: Inlines , dbDocAuthors :: [Inlines] , dbDocDate :: Inlines @@ -24,6 +25,7 @@ readDocBook st inp = setTitle (dbDocTitle st') $ doc $ mconcat bs where (bs, st') = runState (mapM parseBlock $ parseXML inp) DBState{ dbSectionLevel = 0 + , dbQuoteType = DoubleQuote , dbDocTitle = mempty , dbDocAuthors = [] , dbDocDate = mempty @@ -95,6 +97,15 @@ parseInline (Elem e) = case qName (elName e) of "subscript" -> subscript <$> innerInlines "superscript" -> superscript <$> innerInlines + "quote" -> do + qt <- gets dbQuoteType + let qt' = if qt == SingleQuote then DoubleQuote else SingleQuote + modify $ \st -> st{ dbQuoteType = qt' } + contents <- innerInlines + modify $ \st -> st{ dbQuoteType = qt } + return $ if qt == SingleQuote + then singleQuoted contents + else doubleQuoted contents "ulink" -> link (fromMaybe "" (lookupAttrBy (\attr -> qName attr == "url") (elAttribs e))) "" <$> innerInlines -- cgit v1.2.3