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.
This commit is contained in:
Frerich Raabe 2015-09-23 19:31:25 +02:00
parent 3564cd82ca
commit f6538144f0

View file

@ -511,6 +511,7 @@ data DBState = DBState{ dbSectionLevel :: Int
, dbAcceptsMeta :: Bool
, dbBook :: Bool
, dbFigureTitle :: Inlines
, dbContent :: [Content]
} deriving Show
instance Default DBState where
@ -519,12 +520,13 @@ instance Default DBState where
, dbMeta = mempty
, dbAcceptsMeta = False
, dbBook = False
, dbFigureTitle = mempty }
, dbFigureTitle = mempty
, dbContent = [] }
readDocBook :: ReaderOptions -> String -> Either PandocError Pandoc
readDocBook _ inp = (\blocks -> Pandoc (dbMeta st') (toList . mconcat $ blocks)) <$> bs
where (bs , st') = flip runState def . runExceptT . mapM parseBlock $ tree
where (bs , st') = flip runState (def{ dbContent = tree }) . runExceptT . mapM parseBlock $ tree
tree = normalizeTree . parseXML . handleInstructions $ inp
-- We treat <?asciidoc-br?> specially (issue #1236), converting it