Docx writer: Fixed a couple bugs in Figure numbering.

This commit is contained in:
John MacFarlane 2021-06-29 11:15:13 -07:00
parent a3d745e485
commit a01ba4463f

View file

@ -856,7 +856,7 @@ blockToOpenXML' opts (Plain lst) = do
blockToOpenXML' opts (Para [Image attr alt (src,T.stripPrefix "fig:" -> Just tit)]) = do blockToOpenXML' opts (Para [Image attr alt (src,T.stripPrefix "fig:" -> Just tit)]) = do
setFirstPara setFirstPara
fignum <- gets stNextFigureNum fignum <- gets stNextFigureNum
modify $ \st -> st{ stNextFigureNum = fignum + 1 } unless (null alt) $ modify $ \st -> st{ stNextFigureNum = fignum + 1 }
let figid = "fig" <> tshow fignum let figid = "fig" <> tshow fignum
figname <- translateTerm Term.Figure figname <- translateTerm Term.Figure
prop <- pStyleM $ prop <- pStyleM $
@ -870,10 +870,9 @@ blockToOpenXML' opts (Para [Image attr alt (src,T.stripPrefix "fig:" -> Just tit
else withParaPropM (pStyleM "Image Caption") else withParaPropM (pStyleM "Image Caption")
$ blockToOpenXML opts $ blockToOpenXML opts
(Para $ Span (figid,[],[]) (Para $ Span (figid,[],[])
[Str "Figure\160", [Str (figname <> "\160"),
RawInline (Format "openxml") RawInline (Format "openxml")
("<w:fldSimple w:instr=\"SEQ " ("<w:fldSimple w:instr=\"SEQ Figure"
<> figname
<> " \\* ARABIC \"><w:r><w:t>" <> " \\* ARABIC \"><w:r><w:t>"
<> tshow fignum <> tshow fignum
<> "</w:t></w:r></w:fldSimple>"), <> "</w:t></w:r></w:fldSimple>"),