aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/LaTeX.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/Readers/LaTeX.hs')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 34eb53245..15148debb 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -1095,24 +1095,25 @@ figure = try $ do
addImageCaption :: PandocMonad m => Blocks -> LP m Blocks
addImageCaption = walkM go
- where go (Image attr@(_, cls, kvs) alt (src,tit))
+ where go p@(Para [Image attr@(_, cls, kvs) _ (src, tit)])
| not ("fig:" `T.isPrefixOf` tit) = do
st <- getState
- let (alt', tit') = case sCaption st of
- Just ils -> (toList ils, "fig:" <> tit)
- Nothing -> (alt, tit)
- attr' = case sLastLabel st of
- Just lab -> (lab, cls, kvs)
- Nothing -> attr
- case attr' of
- ("", _, _) -> return ()
- (ident, _, _) -> do
- num <- getNextNumber sLastFigureNum
- setState
- st{ sLastFigureNum = num
- , sLabels = M.insert ident
- [Str (renderDottedNum num)] (sLabels st) }
- return $ Image attr' alt' (src, tit')
+ case sCaption st of
+ Nothing -> return p
+ Just figureCaption -> do
+ let attr' = case sLastLabel st of
+ Just lab -> (lab, cls, kvs)
+ Nothing -> attr
+ case attr' of
+ ("", _, _) -> return ()
+ (ident, _, _) -> do
+ num <- getNextNumber sLastFigureNum
+ setState
+ st{ sLastFigureNum = num
+ , sLabels = M.insert ident
+ [Str (renderDottedNum num)] (sLabels st) }
+
+ return $ SimpleFigure attr' (B.toList figureCaption) (src, tit)
go x = return x
coloredBlock :: PandocMonad m => Text -> LP m Blocks