From d071b4177c1a3897f4682e245046a45f362b6ac5 Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Fri, 1 Oct 2021 14:21:33 +0200 Subject: Squashed 'deps/md4c/' content from commit 7f05330 git-subtree-dir: deps/md4c git-subtree-split: 7f0533068b4319d8cb3d0f33ca9aa66a857734a6 --- test/tables.txt | 378 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 378 insertions(+) create mode 100644 test/tables.txt (limited to 'test/tables.txt') diff --git a/test/tables.txt b/test/tables.txt new file mode 100644 index 0000000..bef5799 --- /dev/null +++ b/test/tables.txt @@ -0,0 +1,378 @@ + +# Tables + +With the flag `MD_FLAG_TABLES`, MD4C enables extension for recognition of +tables. + +Basic table example of a table with two columns and three lines (when not +counting the header) is as follows: + +```````````````````````````````` example +| Column 1 | Column 2 | +|----------|----------| +| foo | bar | +| baz | qux | +| quux | quuz | +. + + + + + + + + + +
Column 1Column 2
foobar
bazqux
quuxquuz
+```````````````````````````````` + +The leading and succeeding pipe characters (`|`) on each line are optional: + +```````````````````````````````` example +Column 1 | Column 2 | +---------|--------- | +foo | bar | +baz | qux | +quux | quuz | +. + + + + + + + + + +
Column 1Column 2
foobar
bazqux
quuxquuz
+```````````````````````````````` + +```````````````````````````````` example +| Column 1 | Column 2 +|----------|--------- +| foo | bar +| baz | qux +| quux | quuz +. + + + + + + + + + +
Column 1Column 2
foobar
bazqux
quuxquuz
+```````````````````````````````` + +```````````````````````````````` example +Column 1 | Column 2 +---------|--------- +foo | bar +baz | qux +quux | quuz +. + + + + + + + + + +
Column 1Column 2
foobar
bazqux
quuxquuz
+```````````````````````````````` + +However for one-column table, at least one pipe has to be used in the table +header underline, otherwise it would be parsed as a Setext title followed by +a paragraph. + +```````````````````````````````` example +Column 1 +-------- +foo +baz +quux +. +

Column 1

+

foo +baz +quux

+```````````````````````````````` + +Leading and trailing whitespace in a table cell is ignored and the columns do +not need to be aligned. + +```````````````````````````````` example +Column 1 |Column 2 +---|--- +foo | bar +baz| qux +quux|quuz +. + + + + + + + + + +
Column 1Column 2
foobar
bazqux
quuxquuz
+```````````````````````````````` + +The table cannot interrupt a paragraph. + +```````````````````````````````` example +Lorem ipsum dolor sit amet. +| Column 1 | Column 2 +| ---------|--------- +| foo | bar +| baz | qux +| quux | quuz +. +

Lorem ipsum dolor sit amet. +| Column 1 | Column 2 +| ---------|--------- +| foo | bar +| baz | qux +| quux | quuz

+```````````````````````````````` + +Similarly, paragraph cannot interrupt a table: + +```````````````````````````````` example +Column 1 | Column 2 +---------|--------- +foo | bar +baz | qux +quux | quuz +Lorem ipsum dolor sit amet. +. + + + + + + + + + + +
Column 1Column 2
foobar
bazqux
quuxquuz
Lorem ipsum dolor sit amet.
+```````````````````````````````` + +The underline of the table is crucial for recognition of the table, count of +its columns and their alignment: The line has to contain at least one pipe, +and it has provide at least three dash (`-`) characters for every column in +the table. + +Thus this is not a table because there are too few dashes for Column 2. + +```````````````````````````````` example +| Column 1 | Column 2 +| ---------|-- +| foo | bar +| baz | qux +| quux | quuz +. +

| Column 1 | Column 2 +| ---------|-- +| foo | bar +| baz | qux +| quux | quuz

+```````````````````````````````` + +The first, the last or both the first and the last dash in each column +underline can be replaced with a colon (`:`) to request left, right or middle +alignment of the respective column: + +```````````````````````````````` example +| Column 1 | Column 2 | Column 3 | Column 4 | +|----------|:---------|:--------:|---------:| +| default | left | center | right | +. + + + + + + + +
Column 1Column 2Column 3Column 4
defaultleftcenterright
+```````````````````````````````` + +To include a literal pipe character in any cell, it has to be escaped. + +```````````````````````````````` example +Column 1 | Column 2 +---------|--------- +foo | bar +baz | qux \| xyzzy +quux | quuz +. + + + + + + + + + +
Column 1Column 2
foobar
bazqux | xyzzy
quuxquuz
+```````````````````````````````` + +Contents of each cell is parsed as an inline text which may contents any +inline Markdown spans like emphasis, strong emphasis, links etc. + +```````````````````````````````` example +Column 1 | Column 2 +---------|--------- +*foo* | bar +**baz** | [qux] +quux | [quuz](/url2) + +[qux]: /url +. + + + + + + + + + +
Column 1Column 2
foobar
bazqux
quuxquuz
+```````````````````````````````` + +However pipes which are inside a code span are not recognized as cell +boundaries. + +```````````````````````````````` example +Column 1 | Column 2 +---------|--------- +`foo | bar` +baz | qux +quux | quuz +. + + + + + + + + + +
Column 1Column 2
foo | bar
bazqux
quuxquuz
+```````````````````````````````` + + +## GitHub Issues + +### [Issue 41](https://github.com/mity/md4c/issues/41) +```````````````````````````````` example +* x|x +---|--- +. + +```````````````````````````````` +(Not a table, because the underline has wrong indentation and is not part of the +list item.) + +```````````````````````````````` example +* x|x + ---|--- +x|x +. + +

x|x

+```````````````````````````````` +(Here the underline has the right indentation so the table is detected. +But the last line is not part of it due its indentation.) + + +### [Issue 42](https://github.com/mity/md4c/issues/42) + +```````````````````````````````` example +] http://x.x *x* + +|x|x| +|---|---| +|x| +. +

] http://x.x x

+ + + + + + + + + + + + + +
xx
x
+```````````````````````````````` + + +### [Issue 104](https://github.com/mity/md4c/issues/104) + +```````````````````````````````` example +A | B +--- | --- +[x](url) +. + + + + + + + + + + + + + +
AB
x
+```````````````````````````````` + + +### [Issue 138](https://github.com/mity/md4c/issues/138) + +```````````````````````````````` example +| abc | def | +| --- | --- | +. + + + + + + + +
abcdef
+```````````````````````````````` -- cgit v1.2.3