Skip to content

Commit 3902672

Browse files
committed
Prepare LaTex Reader for simpleFigureWith.
1 parent ee56a90 commit 3902672

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

src/Text/Pandoc/Readers/LaTeX.hs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,24 +1093,25 @@ figure = try $ do
10931093

10941094
addImageCaption :: PandocMonad m => Blocks -> LP m Blocks
10951095
addImageCaption = walkM go
1096-
where go (Image attr@(_, cls, kvs) alt (src,tit))
1096+
where go p@(Para [Image attr@(_, cls, kvs) _ (src,tit)])
10971097
| not ("fig:" `T.isPrefixOf` tit) = do
10981098
st <- getState
1099-
let (alt', tit') = case sCaption st of
1100-
Just ils -> (toList ils, "fig:" <> tit)
1101-
Nothing -> (alt, tit)
1102-
attr' = case sLastLabel st of
1103-
Just lab -> (lab, cls, kvs)
1104-
Nothing -> attr
1105-
case attr' of
1106-
("", _, _) -> return ()
1107-
(ident, _, _) -> do
1108-
num <- getNextNumber sLastFigureNum
1109-
setState
1110-
st{ sLastFigureNum = num
1111-
, sLabels = M.insert ident
1112-
[Str (renderDottedNum num)] (sLabels st) }
1113-
return $ Image attr' alt' (src, tit')
1099+
case sCaption st of
1100+
Nothing -> return p
1101+
Just figureCaption -> do
1102+
let attr' = case sLastLabel st of
1103+
Just lab -> (lab, cls, kvs)
1104+
Nothing -> attr
1105+
case attr' of
1106+
("", _, _) -> return ()
1107+
(ident, _, _) -> do
1108+
num <- getNextNumber sLastFigureNum
1109+
setState
1110+
st{ sLastFigureNum = num
1111+
, sLabels = M.insert ident
1112+
[Str (renderDottedNum num)] (sLabels st) }
1113+
1114+
return $ B.SimpleFigure attr' (B.toList figureCaption) src tit
11141115
go x = return x
11151116

11161117
coloredBlock :: PandocMonad m => Text -> LP m Blocks

0 commit comments

Comments
 (0)