git.iko.soy/typeable/pandoc
on master help sign in
Implemented quoted in docbook reader.
commite5c4d7002eb5b9c73211186f5f15a82c2731fe31 authorJohn MacFarlane <fiddlosopher@gmail.com> dateSat 14 Apr 2012, 21:50 (15 years ago) parentf0a1760
1 file changed+11
src/Text/Pandoc/Readers/DocBook.hs+11
src/Text/Pandoc/Readers/DocBook.hs+11
@@ -12,6 +12,7 @@ import Control.Applicative ((<$>))
1212type DB = State DBState
1313
1414data DBState = DBState{ dbSectionLevel :: Int
15+ , dbQuoteType :: QuoteType
1516 , dbDocTitle :: Inlines
1617 , dbDocAuthors :: [Inlines]
1718 , dbDocDate :: Inlines
@@ -24,6 +25,7 @@ readDocBook st inp = setTitle (dbDocTitle st')
2425 $ doc $ mconcat bs
2526 where (bs, st') = runState (mapM parseBlock $ parseXML inp)
2627 DBState{ dbSectionLevel = 0
28+ , dbQuoteType = DoubleQuote
2729 , dbDocTitle = mempty
2830 , dbDocAuthors = []
2931 , dbDocDate = mempty
@@ -95,6 +97,15 @@ parseInline (Elem e) =
9597 case qName (elName e) of
9698 "subscript" -> subscript <$> innerInlines
9799 "superscript" -> superscript <$> innerInlines
100+ "quote" -> do
101+ qt <- gets dbQuoteType
102+ let qt' = if qt == SingleQuote then DoubleQuote else SingleQuote
103+ modify $ \st -> st{ dbQuoteType = qt' }
104+ contents <- innerInlines
105+ modify $ \st -> st{ dbQuoteType = qt }
106+ return $ if qt == SingleQuote
107+ then singleQuoted contents
108+ else doubleQuoted contents
98109 "ulink" -> link
99110 (fromMaybe "" (lookupAttrBy (\attr -> qName attr == "url")
100111 (elAttribs e))) "" <$> innerInlines