@@ -133,7 +133,7 @@ List of all DocBook tags, with [x] indicating implemented,
133[ ] exceptionname - The name of an exception
133[ ] exceptionname - The name of an exception
134[ ] fax - A fax number
134[ ] fax - A fax number
135[ ] fieldsynopsis - The name of a field in a class definition
135[ ] 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
137[x] filename - The name of a file
137[x] filename - The name of a file
138[ ] firstname - The first name of a person
138[ ] firstname - The first name of a person
139[ ] firstterm - The first occurrence of a term
139[ ] firstterm - The first occurrence of a term
@@ -501,6 +501,7 @@ data DBState = DBState{ dbSectionLevel :: Int
501 , dbDocAuthors :: [Inlines]
501 , dbDocAuthors :: [Inlines]
502 , dbDocDate :: Inlines
502 , dbDocDate :: Inlines
503 , dbBook :: Bool
503 , dbBook :: Bool
504+ , dbFigureTitle :: Inlines
504 } deriving Show
505 } deriving Show
506readDocBook :: ReaderOptions -> String -> Pandoc
507readDocBook :: ReaderOptions -> String -> Pandoc
@@ -515,8 +516,19 @@ readDocBook _ inp = setTitle (dbDocTitle st')
515 , dbDocAuthors = []
516 , dbDocAuthors = []
516 , dbDocDate = mempty
517 , dbDocDate = mempty
517 , dbBook = False
518 , dbBook = False
519+ , dbFigureTitle = mempty
522+getFigure :: Element -> DB Blocks
524+ tit <- case filterChild (named "title") e of
525+ Just t -> getInlines t
526+ Nothing -> return mempty
527+ modify $ \st -> st{ dbFigureTitle = tit }
529+ modify $ \st -> st{ dbFigureTitle = mempty }
520-- normalize input, consolidating adjacent Text and CRef elements
532-- normalize input, consolidating adjacent Text and CRef elements
521normalizeTree :: [Content] -> [Content]
533normalizeTree :: [Content] -> [Content]
522normalizeTree = everywhere (mkT go)
534normalizeTree = everywhere (mkT go)
@@ -585,10 +597,13 @@ getImage e = do
585 Just i -> return $ attrValue "fileref" i
597 Just i -> return $ attrValue "fileref" i
586 caption <- case filterChild
598 caption <- case filterChild
587 (\x -> named "caption" x || named "textobject" x) e of
599 (\x -> named "caption" x || named "textobject" x) e of
588− Nothing -> return mempty
600+ Nothing -> gets dbFigureTitle
589 Just z -> mconcat <$> (mapM parseInline $ elContent z)
601 Just z -> mconcat <$> (mapM parseInline $ elContent z)
590 return $ image imageUrl "" caption
602 return $ image imageUrl "" caption
604+getBlocks :: Element -> DB Blocks
605+getBlocks e = mconcat <$> (mapM parseBlock $ elContent e)
592parseBlock :: Content -> DB Blocks
607parseBlock :: Content -> DB Blocks
593parseBlock (Text (CData CDataRaw _ _)) = return mempty -- DOCTYPE
608parseBlock (Text (CData CDataRaw _ _)) = return mempty -- DOCTYPE
594parseBlock (Text (CData _ s _)) = if all isSpace s
609parseBlock (Text (CData _ s _)) = if all isSpace s
@@ -613,7 +628,7 @@ parseBlock (Elem e) =
613 "attribution" -> return mempty
628 "attribution" -> return mempty
614 "titleabbrev" -> return mempty
629 "titleabbrev" -> return mempty
615 "authorinitials" -> return mempty
630 "authorinitials" -> return mempty
616− "title" -> return mempty -- handled by getTitle or sect
631+ "title" -> return mempty -- handled by getTitle or sect or figure
617 "bibliography" -> sect 0
632 "bibliography" -> sect 0
618 "bibliodiv" -> sect 1
633 "bibliodiv" -> sect 1
619 "biblioentry" -> parseMixed para (elContent e)
634 "biblioentry" -> parseMixed para (elContent e)
@@ -674,7 +689,8 @@ parseBlock (Elem e) =
674 orderedListWith (start,listStyle,DefaultDelim)
689 orderedListWith (start,listStyle,DefaultDelim)
675 <$> listitems
690 <$> listitems
676 "variablelist" -> definitionList <$> deflistitems
691 "variablelist" -> definitionList <$> deflistitems
692+ "figure" -> getFigure e
677− "mediaobject" -> para <$> (getImage e)
693+ "mediaobject" -> para <$> getImage e
678 "caption" -> return mempty
694 "caption" -> return mempty
679 "info" -> getTitle >> getAuthors >> getDate >> return mempty
695 "info" -> getTitle >> getAuthors >> getDate >> return mempty
680 "articleinfo" -> getTitle >> getAuthors >> getDate >> return mempty
696 "articleinfo" -> getTitle >> getAuthors >> getDate >> return mempty
@@ -702,8 +718,7 @@ parseBlock (Elem e) =
702 "programlisting" -> codeBlockWithLang
718 "programlisting" -> codeBlockWithLang
703 "?xml" -> return mempty
719 "?xml" -> return mempty
704 _ -> getBlocks e
720 _ -> getBlocks e
705− where getBlocks e' = mconcat <$> (mapM parseBlock $ elContent e')
706− parseMixed container conts = do
721+ where parseMixed container conts = do
707 let (ils,rest) = break isBlockElement conts
722 let (ils,rest) = break isBlockElement conts
708 ils' <- (trimInlines . mconcat) <$> mapM parseInline ils
723 ils' <- (trimInlines . mconcat) <$> mapM parseInline ils
709 let p = if ils' == mempty then mempty else container ils'
724 let p = if ils' == mempty then mempty else container ils'