Roll back automatic figure/table numbering in ODT/OpenDocument.

This was added in pandoc 2.7.2, but it makes it impossible
to use pandoc-crossref. So this has been rolled back for now,
until we find a good solution to make this behavior optional
(or a creative way to let pandoc-crossref and this feature
to coexist).

See #5474.
This commit is contained in:
John MacFarlane 2019-06-08 14:17:52 -07:00
parent d1df2b2783
commit 05ae9f265f
3 changed files with 18 additions and 9 deletions

View file

@ -393,7 +393,10 @@ blockToOpenDocument o bs
mapM_ addParaStyle . newPara $ paraHStyles ++ paraStyles
captionDoc <- if null c
then return empty
else inlinesToOpenDocument o c >>= numberedTableCaption
else inlinesToOpenDocument o c >>=
if True -- temporary: see #5474
then unNumberedCaption "TableCaption"
else numberedTableCaption
th <- if all null h
then return empty
else colHeadsToOpenDocument o (map fst paraHStyles) h
@ -405,7 +408,10 @@ blockToOpenDocument o bs
withParagraphStyle o "Figure" [Para [Image attr caption (source,title)]]
| otherwise = do
imageDoc <- withParagraphStyle o "FigureWithCaption" [Para [Image attr caption (source,title)]]
captionDoc <- inlinesToOpenDocument o caption >>= numberedFigureCaption
captionDoc <- inlinesToOpenDocument o caption >>=
if True -- temporary: see #5474
then unNumberedCaption "FigureCaption"
else numberedFigureCaption
return $ imageDoc $$ captionDoc
@ -434,6 +440,9 @@ numberedCaption style term name num caption =
c = text ": "
in inParagraphTagsWithStyle style $ hcat [ t, text " ", s, c, caption ]
unNumberedCaption :: Monad m => String -> Doc -> OD m Doc
unNumberedCaption style caption = return $ inParagraphTagsWithStyle style caption
colHeadsToOpenDocument :: PandocMonad m
=> WriterOptions -> [String] -> [[Block]]
-> OD m Doc

View file

@ -63,8 +63,8 @@
</table:table-cell>
</table:table-row>
</table:table>
<text:p text:style-name="Table">Table <text:sequence text:ref-name="refTable0" text:name="Table" text:formula="ooow:Table+1" style:num-format="1">1</text:sequence>: Demonstration
of simple table syntax.</text:p>
<text:p text:style-name="TableCaption">Demonstration of simple table
syntax.</text:p>
<text:p text:style-name="First_20_paragraph">Simple table without
caption:</text:p>
<table:table table:name="Table2" table:style-name="Table2">
@ -197,8 +197,8 @@ spaces:</text:p>
</table:table-cell>
</table:table-row>
</table:table>
<text:p text:style-name="Table">Table <text:sequence text:ref-name="refTable1" text:name="Table" text:formula="ooow:Table+1" style:num-format="1">2</text:sequence>: Demonstration
of simple table syntax.</text:p>
<text:p text:style-name="TableCaption">Demonstration of simple table
syntax.</text:p>
<text:p text:style-name="First_20_paragraph">Multiline table with
caption:</text:p>
<table:table table:name="Table4" table:style-name="Table4">
@ -253,8 +253,8 @@ caption:</text:p>
</table:table-cell>
</table:table-row>
</table:table>
<text:p text:style-name="Table">Table <text:sequence text:ref-name="refTable2" text:name="Table" text:formula="ooow:Table+1" style:num-format="1">3</text:sequence>: Heres
the caption. It may span multiple lines.</text:p>
<text:p text:style-name="TableCaption">Heres the caption. It may span
multiple lines.</text:p>
<text:p text:style-name="First_20_paragraph">Multiline table without
caption:</text:p>
<table:table table:name="Table5" table:style-name="Table5">

View file

@ -1879,7 +1879,7 @@ link in pointy braces</text:span></text:a>.</text:p>
<text:p text:style-name="First_20_paragraph">From “Voyage dans la Lune” by
Georges Melies (1902):</text:p>
<text:p text:style-name="FigureWithCaption"><draw:frame draw:name="img1"><draw:image xlink:href="lalune.jpg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" /></draw:frame></text:p>
<text:p text:style-name="FigureCaption">Figure <text:sequence text:ref-name="refIllustration0" text:name="Illustration" text:formula="ooow:Illustration+1" style:num-format="1">1</text:sequence>: lalune</text:p>
<text:p text:style-name="FigureCaption">lalune</text:p>
<text:p text:style-name="Text_20_body">Here is a movie
<draw:frame draw:name="img2"><draw:image xlink:href="movie.jpg" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" /></draw:frame>
icon.</text:p>