From 05ae9f265f19a6ae4cbba77c5466c7f7eff4cde8 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 8 Jun 2019 14:17:52 -0700 Subject: [PATCH] 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. --- src/Text/Pandoc/Writers/OpenDocument.hs | 13 +++++++++++-- test/tables.opendocument | 12 ++++++------ test/writer.opendocument | 2 +- 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 1: Demonstration -of simple table syntax. +Demonstration of simple table +syntax. Simple table without caption: @@ -197,8 +197,8 @@ spaces: -Table 2: Demonstration -of simple table syntax. +Demonstration of simple table +syntax. Multiline table with caption: @@ -253,8 +253,8 @@ caption: -Table 3: Here’s -the caption. It may span multiple lines. +Here’s the caption. It may span +multiple lines. Multiline table without caption: 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. From “Voyage dans la Lune” by Georges Melies (1902): -Figure 1: lalune +lalune Here is a movie icon.