From 270ffe6ab548de83287b7647269b0c8a18b9e8bf Mon Sep 17 00:00:00 2001 From: Dmitry Pogodin Date: Sun, 3 Nov 2019 18:17:05 +0300 Subject: [PATCH] Place caption before table in OpenDocument format. (#5869) Closes #5681. --- src/Text/Pandoc/Writers/OpenDocument.hs | 8 +++++--- test/command/5474-tables.md | 8 ++++---- test/tables.opendocument | 12 ++++++------ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs index 7a3aa4973..9c6867797 100644 --- a/src/Text/Pandoc/Writers/OpenDocument.hs +++ b/src/Text/Pandoc/Writers/OpenDocument.hs @@ -404,9 +404,11 @@ blockToOpenDocument o bs then return empty else colHeadsToOpenDocument o (map fst paraHStyles) h tr <- mapM (tableRowToOpenDocument o (map fst paraStyles)) r - return $ inTags True "table:table" [ ("table:name" , name) - , ("table:style-name", name) - ] (vcat columns $$ th $$ vcat tr) $$ captionDoc + let tableDoc = inTags True "table:table" [ + ("table:name" , name) + , ("table:style-name", name) + ] (vcat columns $$ th $$ vcat tr) + return $ captionDoc $$ tableDoc figure attr caption source title | null caption = withParagraphStyle o "Figure" [Para [Image attr caption (source,title)]] | otherwise = do diff --git a/test/command/5474-tables.md b/test/command/5474-tables.md index 3bd4f81e9..f09b0a441 100644 --- a/test/command/5474-tables.md +++ b/test/command/5474-tables.md @@ -12,6 +12,8 @@ : Second Table ^D +Table 1: First +table @@ -34,8 +36,8 @@ -Table 1: First -table +Table 2: Second +Table @@ -58,6 +60,4 @@ table -Table 2: Second -Table ``` diff --git a/test/tables.opendocument b/test/tables.opendocument index 250bce1b9..cda121dd4 100644 --- a/test/tables.opendocument +++ b/test/tables.opendocument @@ -1,4 +1,6 @@ Simple table with caption: +Demonstration of simple table +syntax. @@ -63,8 +65,6 @@ -Demonstration of simple table -syntax. Simple table without caption: @@ -133,6 +133,8 @@ caption: Simple table indented two spaces: +Demonstration of simple table +syntax. @@ -197,10 +199,10 @@ spaces: -Demonstration of simple table -syntax. Multiline table with caption: +Here’s the caption. It may span +multiple lines. @@ -253,8 +255,6 @@ caption: -Here’s the caption. It may span -multiple lines. Multiline table without caption: