md_is_table_underline: Remove requirement for minimal length of a cell underline. Fixes #169.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5381d55..8e54ba2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -24,7 +24,6 @@ Changes:
0.30 notes](https://github.com/commonmark/commonmark-spec/releases/tag/0.30)
for more info.
-
Fixes:
* [#163](https://github.com/mity/md4c/issues/163):
@@ -35,6 +34,11 @@ Fixes:
work, it's not needed, and it can actually be confusing with URLs such as
`http://www.example.com/~johndoe/`.
+ * [#169](https://github.com/mity/md4c/issues/169):
+ Table underline now does not require 3 characters per table column anymore.
+ One dash (optionally with a leading or tailing `:` appended or prepended)
+ is now sufficient. This improves compatibility with the GFM.
+
## Version 0.4.8
diff --git a/src/md4c.c b/src/md4c.c
index 40066b2..9192468 100644
--- a/src/md4c.c
+++ b/src/md4c.c
@@ -5212,19 +5212,17 @@ md_is_table_underline(MD_CTX* ctx, OFF beg, OFF* p_end, unsigned* p_col_count)
}
while(1) {
- OFF cell_beg;
int delimited = FALSE;
/* Cell underline ("-----", ":----", "----:" or ":----:") */
- cell_beg = off;
if(off < ctx->size && CH(off) == _T(':'))
off++;
+ if(off < ctx->size && CH(off) != _T('-'))
+ return FALSE;
while(off < ctx->size && CH(off) == _T('-'))
off++;
if(off < ctx->size && CH(off) == _T(':'))
off++;
- if(off - cell_beg < 3)
- return FALSE;
col_count++;
diff --git a/test/tables.txt b/test/tables.txt
index bef5799..b220f66 100644
--- a/test/tables.txt
+++ b/test/tables.txt
@@ -165,27 +165,6 @@ Lorem ipsum dolor sit amet.
</table>
````````````````````````````````
-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
-.
-<p>| Column 1 | Column 2
-| ---------|--
-| foo | bar
-| baz | qux
-| quux | quuz</p>
-````````````````````````````````
-
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: