git.iko.soy/typeable/pandoc
on master help sign in
Pass the parsed DocBook content along the state of readDocBook

Having access to the entire document will be needed when handling elements which refer to other elements. This is needed for e.g. <xref> or <link>, both of which reference other elements (by the 'id' attribute) for the label text. I suppose that in practice, the [Content] returned by parseXML always only contains one 'Elem' value -- the document element. However, I'm not totally sure about it, so let's just pass all the Content along.

commitf6538144f0763ae17b60c78810ed52ab96df308d authorFrerich Raabe <raabe@froglogic.com> dateWed 23 Sep 2015, 19:31 (11 years ago) parent3564cd8
1 file changed+4−2
src/Text/Pandoc/Readers/DocBook.hs+4−2
src/Text/Pandoc/Readers/DocBook.hs+4−2
@@ -511,6 +511,7 @@ data DBState = DBState{ dbSectionLevel :: Int
511511 , dbAcceptsMeta :: Bool
512512 , dbBook :: Bool
513513 , dbFigureTitle :: Inlines
514+ , dbContent :: [Content]
514515 } deriving Show
515516
516517instance Default DBState where
@@ -519,12 +520,13 @@ instance Default DBState where
519520 , dbMeta = mempty
520521 , dbAcceptsMeta = False
521522 , dbBook = False
522− , dbFigureTitle = mempty }
523+ , dbFigureTitle = mempty
524+ , dbContent = [] }
523525
524526
525527readDocBook :: ReaderOptions -> String -> Either PandocError Pandoc
526528readDocBook _ inp = (\blocks -> Pandoc (dbMeta st') (toList . mconcat $ blocks)) <$> bs
527− where (bs , st') = flip runState def . runExceptT . mapM parseBlock $ tree
529+ where (bs , st') = flip runState (def{ dbContent = tree }) . runExceptT . mapM parseBlock $ tree
528530 tree = normalizeTree . parseXML . handleInstructions $ inp
529531
530532-- We treat <?asciidoc-br?> specially (issue #1236), converting it