@@ -133,7 +133,7 @@ List of all DocBook tags, with [x] indicating implemented,
133133[ ] exceptionname - The name of an exception
134134[ ] fax - A fax number
135135[ ] fieldsynopsis - The name of a field in a class definition
136−[ ] figure - A formal figure, generally an illustration, with a title
136+[x] figure - A formal figure, generally an illustration, with a title
137137[x] filename - The name of a file
138138[ ] firstname - The first name of a person
139139[ ] firstterm - The first occurrence of a term
@@ -501,6 +501,7 @@ data DBState = DBState{ dbSectionLevel :: Int
501501 , dbDocAuthors :: [Inlines]
502502 , dbDocDate :: Inlines
503503 , dbBook :: Bool
504+ , dbFigureTitle :: Inlines
504505 } deriving Show
505506
506507readDocBook :: ReaderOptions -> String -> Pandoc
@@ -515,8 +516,19 @@ readDocBook _ inp = setTitle (dbDocTitle st')
515516 , dbDocAuthors = []
516517 , dbDocDate = mempty
517518 , dbBook = False
519+ , dbFigureTitle = mempty
518520 }
519521
522+getFigure :: Element -> DB Blocks
523+getFigure e = do
524+ tit <- case filterChild (named "title") e of
525+ Just t -> getInlines t
526+ Nothing -> return mempty
527+ modify $ \st -> st{ dbFigureTitle = tit }
528+ res <- getBlocks e
529+ modify $ \st -> st{ dbFigureTitle = mempty }
530+ return res
531+
520532-- normalize input, consolidating adjacent Text and CRef elements
521533normalizeTree :: [Content] -> [Content]
522534normalizeTree = everywhere (mkT go)
@@ -585,10 +597,13 @@ getImage e = do
585597 Just i -> return $ attrValue "fileref" i
586598 caption <- case filterChild
587599 (\x -> named "caption" x || named "textobject" x) e of
588− Nothing -> return mempty
600+ Nothing -> gets dbFigureTitle
589601 Just z -> mconcat <$> (mapM parseInline $ elContent z)
590602 return $ image imageUrl "" caption
591603
604+getBlocks :: Element -> DB Blocks
605+getBlocks e = mconcat <$> (mapM parseBlock $ elContent e)
606+
592607parseBlock :: Content -> DB Blocks
593608parseBlock (Text (CData CDataRaw _ _)) = return mempty -- DOCTYPE
594609parseBlock (Text (CData _ s _)) = if all isSpace s
@@ -613,7 +628,7 @@ parseBlock (Elem e) =
613628 "attribution" -> return mempty
614629 "titleabbrev" -> return mempty
615630 "authorinitials" -> return mempty
616− "title" -> return mempty -- handled by getTitle or sect
631+ "title" -> return mempty -- handled by getTitle or sect or figure
617632 "bibliography" -> sect 0
618633 "bibliodiv" -> sect 1
619634 "biblioentry" -> parseMixed para (elContent e)
@@ -674,7 +689,8 @@ parseBlock (Elem e) =
674689 orderedListWith (start,listStyle,DefaultDelim)
675690 <$> listitems
676691 "variablelist" -> definitionList <$> deflistitems
677− "mediaobject" -> para <$> (getImage e)
692+ "figure" -> getFigure e
693+ "mediaobject" -> para <$> getImage e
678694 "caption" -> return mempty
679695 "info" -> getTitle >> getAuthors >> getDate >> return mempty
680696 "articleinfo" -> getTitle >> getAuthors >> getDate >> return mempty
@@ -702,8 +718,7 @@ parseBlock (Elem e) =
702718 "programlisting" -> codeBlockWithLang
703719 "?xml" -> return mempty
704720 _ -> getBlocks e
705− where getBlocks e' = mconcat <$> (mapM parseBlock $ elContent e')
706− parseMixed container conts = do
721+ where parseMixed container conts = do
707722 let (ils,rest) = break isBlockElement conts
708723 ils' <- (trimInlines . mconcat) <$> mapM parseInline ils
709724 let p = if ils' == mempty then mempty else container ils'