aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlbert Krewinkel <[email protected]>2022-07-30 17:56:44 +0200
committerGitHub <[email protected]>2022-07-30 08:56:44 -0700
commitc015c35a8a7026dd7ee3207053319e886fa637c2 (patch)
tree0f24979fd42d380650c949e2b33bda76d8cbb8df /test
parentde5620b04df540d11efdf96fb142b63b5ec4d3c5 (diff)
Support rowspans and colspans in grid tables (#8202)
* Add tests for zero-width and fullwidth chars in grid tables * T.P.Parsing: simplify `gridTableWith'`, `gridTableWith` [API Change] The functions `gridTableWith` and `gridTableWith'` no longer takes a boolean argument that toggles whether a table head should be parsed: both, tables with heads and without heads, are always accepted now. * Support colspans, rowspans, and multirow headers in grid tables. Grid tables in Markdown, reStructuredText, and Org can now contain cells spanning over multiple columns and/or multiple rows; table headers containing multiple rows are supported as well. Note: the markdown writer does not yet support these more complex grid table features.
Diffstat (limited to 'test')
-rw-r--r--test/markdown-reader-more.native239
-rw-r--r--test/markdown-reader-more.txt26
-rw-r--r--test/rst-reader.native228
-rw-r--r--test/rst-reader.rst25
4 files changed, 515 insertions, 3 deletions
diff --git a/test/markdown-reader-more.native b/test/markdown-reader-more.native
index 82b3577be..f200d0705 100644
--- a/test/markdown-reader-more.native
+++ b/test/markdown-reader-more.native
@@ -1022,7 +1022,7 @@ Pandoc
1
( "col-1" , [] , [] )
[ Str "col" , Space , Str "1" ]
- , Plain [ Str "col" , Space , Str "1" ]
+ , Para [ Str "col" , Space , Str "1" ]
]
, Cell
( "" , [] , [] )
@@ -1033,7 +1033,7 @@ Pandoc
1
( "col-2" , [] , [] )
[ Str "col" , Space , Str "2" ]
- , Plain [ Str "col" , Space , Str "2" ]
+ , Para [ Str "col" , Space , Str "2" ]
]
, Cell
( "" , [] , [] )
@@ -1044,7 +1044,7 @@ Pandoc
1
( "col-3" , [] , [] )
[ Str "col" , Space , Str "3" ]
- , Plain [ Str "col" , Space , Str "3" ]
+ , Para [ Str "col" , Space , Str "3" ]
]
]
, Row
@@ -1261,6 +1261,239 @@ Pandoc
]
]
(TableFoot ( "" , [] , [] ) [])
+ , Para
+ [ Str "Table"
+ , Space
+ , Str "with"
+ , Space
+ , Str "cells"
+ , Space
+ , Str "spanning"
+ , Space
+ , Str "multiple"
+ , Space
+ , Str "rows"
+ , Space
+ , Str "or"
+ , Space
+ , Str "columns:"
+ ]
+ , Table
+ ( "" , [] , [] )
+ (Caption Nothing [])
+ [ ( AlignDefault , ColWidth 0.19444444444444445 )
+ , ( AlignDefault , ColWidth 0.1111111111111111 )
+ , ( AlignDefault , ColWidth 0.1527777777777778 )
+ ]
+ (TableHead
+ ( "" , [] , [] )
+ [ Row
+ ( "" , [] , [] )
+ [ Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 2)
+ [ Plain [ Str "Property" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "Earth" ] ]
+ ]
+ ])
+ [ TableBody
+ ( "" , [] , [] )
+ (RowHeadColumns 0)
+ []
+ [ Row
+ ( "" , [] , [] )
+ [ Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 3)
+ (ColSpan 1)
+ [ Plain
+ [ Str "Temperature"
+ , SoftBreak
+ , Str "1961-1990"
+ ]
+ ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "min" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "-89.2" , Space , Str "\176C" ] ]
+ ]
+ , Row
+ ( "" , [] , [] )
+ [ Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "mean" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "14" , Space , Str "\176C" ] ]
+ ]
+ , Row
+ ( "" , [] , [] )
+ [ Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "min" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "56.7" , Space , Str "\176C" ] ]
+ ]
+ ]
+ ]
+ (TableFoot ( "" , [] , [] ) [])
+ , Para
+ [ Str "Table"
+ , Space
+ , Str "with"
+ , Space
+ , Str "complex"
+ , Space
+ , Str "header:"
+ ]
+ , Table
+ ( "" , [] , [] )
+ (Caption Nothing [])
+ [ ( AlignDefault , ColWidth 0.3055555555555556 )
+ , ( AlignDefault , ColWidth 0.1111111111111111 )
+ , ( AlignDefault , ColWidth 0.1111111111111111 )
+ , ( AlignDefault , ColWidth 0.1111111111111111 )
+ ]
+ (TableHead
+ ( "" , [] , [] )
+ [ Row
+ ( "" , [] , [] )
+ [ Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 2)
+ (ColSpan 1)
+ [ Plain [ Str "Location" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 3)
+ [ Plain
+ [ Str "Temperature"
+ , Space
+ , Str "1961-1990"
+ , SoftBreak
+ , Str "in"
+ , Space
+ , Str "degree"
+ , Space
+ , Str "Celsius"
+ ]
+ ]
+ ]
+ , Row
+ ( "" , [] , [] )
+ [ Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "min" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "mean" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "max" ] ]
+ ]
+ ])
+ [ TableBody
+ ( "" , [] , [] )
+ (RowHeadColumns 0)
+ []
+ [ Row
+ ( "" , [] , [] )
+ [ Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "Antarctica" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "-89.2" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "N/A" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "19.8" ] ]
+ ]
+ , Row
+ ( "" , [] , [] )
+ [ Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "Earth" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "-89.2" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "14" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "56.7" ] ]
+ ]
+ ]
+ ]
+ (TableFoot ( "" , [] , [] ) [])
, Header
2
( "entities-in-links-and-titles" , [] , [] )
diff --git a/test/markdown-reader-more.txt b/test/markdown-reader-more.txt
index c6f313b20..8d2bed5ef 100644
--- a/test/markdown-reader-more.txt
+++ b/test/markdown-reader-more.txt
@@ -286,6 +286,32 @@ Empty cells
| | |
+---+---+
+
+Table with cells spanning multiple rows or columns:
+
++---------------------+----------+
+| Property | Earth |
++=============+=======+==========+
+| | min | -89.2 °C |
+| Temperature +-------+----------+
+| 1961-1990 | mean | 14 °C |
+| +-------+----------+
+| | min | 56.7 °C |
++-------------+-------+----------+
+
+Table with complex header:
+
++---------------------+-----------------------+
+| Location | Temperature 1961-1990 |
+| | in degree Celsius |
+| +-------+-------+-------+
+| | min | mean | max |
++=====================+=======+=======+=======+
+| Antarctica | -89.2 | N/A | 19.8 |
++---------------------+-------+-------+-------+
+| Earth | -89.2 | 14 | 56.7 |
++---------------------+-------+-------+-------+
+
## Entities in links and titles
[link](/&uuml;rl "&ouml;&ouml;!")
diff --git a/test/rst-reader.native b/test/rst-reader.native
index 51bb940bf..eb81633ff 100644
--- a/test/rst-reader.native
+++ b/test/rst-reader.native
@@ -1474,6 +1474,234 @@ Pandoc
]
]
(TableFoot ( "" , [] , [] ) [])
+ , Para
+ [ Str "Table"
+ , Space
+ , Str "with"
+ , Space
+ , Str "cells"
+ , Space
+ , Str "spanning"
+ , Space
+ , Str "multiple"
+ , Space
+ , Str "rows"
+ , Space
+ , Str "or"
+ , Space
+ , Str "columns:"
+ ]
+ , Table
+ ( "" , [] , [] )
+ (Caption Nothing [])
+ [ ( AlignDefault , ColWidth 0.175 )
+ , ( AlignDefault , ColWidth 0.1 )
+ , ( AlignDefault , ColWidth 0.1375 )
+ ]
+ (TableHead
+ ( "" , [] , [] )
+ [ Row
+ ( "" , [] , [] )
+ [ Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 2)
+ [ Plain [ Str "Property" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "Earth" ] ]
+ ]
+ ])
+ [ TableBody
+ ( "" , [] , [] )
+ (RowHeadColumns 0)
+ []
+ [ Row
+ ( "" , [] , [] )
+ [ Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 3)
+ (ColSpan 1)
+ [ Plain [ Str "Temperature" , SoftBreak , Str "1961-1990" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "min" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "-89.2" , Space , Str "\176C" ] ]
+ ]
+ , Row
+ ( "" , [] , [] )
+ [ Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "mean" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "14" , Space , Str "\176C" ] ]
+ ]
+ , Row
+ ( "" , [] , [] )
+ [ Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "min" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "56.7" , Space , Str "\176C" ] ]
+ ]
+ ]
+ ]
+ (TableFoot ( "" , [] , [] ) [])
+ , Para
+ [ Str "Table"
+ , Space
+ , Str "with"
+ , Space
+ , Str "complex"
+ , Space
+ , Str "header:"
+ ]
+ , Table
+ ( "" , [] , [] )
+ (Caption Nothing [])
+ [ ( AlignDefault , ColWidth 0.275 )
+ , ( AlignDefault , ColWidth 0.1 )
+ , ( AlignDefault , ColWidth 0.1 )
+ , ( AlignDefault , ColWidth 0.1 )
+ ]
+ (TableHead
+ ( "" , [] , [] )
+ [ Row
+ ( "" , [] , [] )
+ [ Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 2)
+ (ColSpan 1)
+ [ Plain [ Str "Location" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 3)
+ [ Plain
+ [ Str "Temperature"
+ , Space
+ , Str "1961-1990"
+ , SoftBreak
+ , Str "in"
+ , Space
+ , Str "degree"
+ , Space
+ , Str "Celsius"
+ ]
+ ]
+ ]
+ , Row
+ ( "" , [] , [] )
+ [ Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "min" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "mean" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "max" ] ]
+ ]
+ ])
+ [ TableBody
+ ( "" , [] , [] )
+ (RowHeadColumns 0)
+ []
+ [ Row
+ ( "" , [] , [] )
+ [ Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "Antarctica" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "-89.2" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "N/A" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "19.8" ] ]
+ ]
+ , Row
+ ( "" , [] , [] )
+ [ Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "Earth" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "-89.2" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "14" ] ]
+ , Cell
+ ( "" , [] , [] )
+ AlignDefault
+ (RowSpan 1)
+ (ColSpan 1)
+ [ Plain [ Str "56.7" ] ]
+ ]
+ ]
+ ]
+ (TableFoot ( "" , [] , [] ) [])
, Header 1 ( "footnotes" , [] , [] ) [ Str "Footnotes" ]
, Para
[ Note
diff --git a/test/rst-reader.rst b/test/rst-reader.rst
index d2d82d435..0a2ad6999 100644
--- a/test/rst-reader.rst
+++ b/test/rst-reader.rst
@@ -543,6 +543,31 @@ Multiple blocks in a cell
| r1 bis | - b 2 | c 2 |
+------------------+-----------+------------+
+Table with cells spanning multiple rows or columns:
+
++---------------------+----------+
+| Property | Earth |
++=============+=======+==========+
+| | min | -89.2 °C |
+| Temperature +-------+----------+
+| 1961-1990 | mean | 14 °C |
+| +-------+----------+
+| | min | 56.7 °C |
++-------------+-------+----------+
+
+Table with complex header:
+
++---------------------+-----------------------+
+| Location | Temperature 1961-1990 |
+| | in degree Celsius |
+| +-------+-------+-------+
+| | min | mean | max |
++=====================+=======+=======+=======+
+| Antarctica | -89.2 | N/A | 19.8 |
++---------------------+-------+-------+-------+
+| Earth | -89.2 | 14 | 56.7 |
++---------------------+-------+-------+-------+
+
Footnotes
=========