aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-06-08 14:17:52 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2019-06-08 14:17:52 -0700
commit05ae9f265f19a6ae4cbba77c5466c7f7eff4cde8 (patch)
tree0817519322ee4f19083467da06cbec12a8c41224
parentd1df2b2783a6fdbe0315cf69d2306271254960f3 (diff)
downloadpandoc-05ae9f265f19a6ae4cbba77c5466c7f7eff4cde8.tar.gz
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.
-rw-r--r--src/Text/Pandoc/Writers/OpenDocument.hs13
-rw-r--r--test/tables.opendocument12
-rw-r--r--test/writer.opendocument2
3 files changed, 18 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs
index e2c8abd2e..f00ae12bf 100644
--- a/src/Text/Pandoc/Writers/OpenDocument.hs
+++ b/src/Text/Pandoc/Writers/OpenDocument.hs
@@ -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
diff --git a/test/tables.opendocument b/test/tables.opendocument
index 5c68476b8..250bce1b9 100644
--- a/test/tables.opendocument
+++ b/test/tables.opendocument
@@ -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>: Here’s
-the caption. It may span multiple lines.</text:p>
+<text:p text:style-name="TableCaption">Here’s 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">
diff --git a/test/writer.opendocument b/test/writer.opendocument
index 2d9068d07..95e909029 100644
--- a/test/writer.opendocument
+++ b/test/writer.opendocument
@@ -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>