aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Pogodin <lunaticare@users.noreply.github.com>2019-11-03 18:17:05 +0300
committerJohn MacFarlane <jgm@berkeley.edu>2019-11-03 07:17:05 -0800
commit270ffe6ab548de83287b7647269b0c8a18b9e8bf (patch)
treee10af2961bb3749e53e58589ccdd5be0b479c416
parent8a2e87758e2f2b3fb74be177c2b28918dc35e27c (diff)
downloadpandoc-270ffe6ab548de83287b7647269b0c8a18b9e8bf.tar.gz
Place caption before table in OpenDocument format. (#5869)
Closes #5681.
-rw-r--r--src/Text/Pandoc/Writers/OpenDocument.hs8
-rw-r--r--test/command/5474-tables.md8
-rw-r--r--test/tables.opendocument12
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
+<text:p text:style-name="TableCaption">Table <text:sequence text:ref-name="refTable0" text:name="Table" text:formula="ooow:Table+1" style:num-format="1">1</text:sequence>: First
+table</text:p>
<table:table table:name="Table1" table:style-name="Table1">
<table:table-column table:style-name="Table1.A" />
<table:table-column table:style-name="Table1.B" />
@@ -34,8 +36,8 @@
</table:table-cell>
</table:table-row>
</table:table>
-<text:p text:style-name="TableCaption">Table <text:sequence text:ref-name="refTable0" text:name="Table" text:formula="ooow:Table+1" style:num-format="1">1</text:sequence>: First
-table</text:p>
+<text:p text:style-name="TableCaption">Table <text:sequence text:ref-name="refTable1" text:name="Table" text:formula="ooow:Table+1" style:num-format="1">2</text:sequence>: Second
+Table</text:p>
<table:table table:name="Table2" table:style-name="Table2">
<table:table-column table:style-name="Table2.A" />
<table:table-column table:style-name="Table2.B" />
@@ -58,6 +60,4 @@ table</text:p>
</table:table-cell>
</table:table-row>
</table:table>
-<text:p text:style-name="TableCaption">Table <text:sequence text:ref-name="refTable1" text:name="Table" text:formula="ooow:Table+1" style:num-format="1">2</text:sequence>: Second
-Table</text:p>
```
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 @@
<text:p text:style-name="Text_20_body">Simple table with caption:</text:p>
+<text:p text:style-name="TableCaption">Demonstration of simple table
+syntax.</text:p>
<table:table table:name="Table1" table:style-name="Table1">
<table:table-column table:style-name="Table1.A" />
<table:table-column table:style-name="Table1.B" />
@@ -63,8 +65,6 @@
</table:table-cell>
</table:table-row>
</table:table>
-<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">
@@ -133,6 +133,8 @@ caption:</text:p>
</table:table>
<text:p text:style-name="First_20_paragraph">Simple table indented two
spaces:</text:p>
+<text:p text:style-name="TableCaption">Demonstration of simple table
+syntax.</text:p>
<table:table table:name="Table3" table:style-name="Table3">
<table:table-column table:style-name="Table3.A" />
<table:table-column table:style-name="Table3.B" />
@@ -197,10 +199,10 @@ spaces:</text:p>
</table:table-cell>
</table:table-row>
</table:table>
-<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>
+<text:p text:style-name="TableCaption">Here’s the caption. It may span
+multiple lines.</text:p>
<table:table table:name="Table4" table:style-name="Table4">
<table:table-column table:style-name="Table4.A" />
<table:table-column table:style-name="Table4.B" />
@@ -253,8 +255,6 @@ caption:</text:p>
</table:table-cell>
</table:table-row>
</table:table>
-<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">