md_rollback: Do not touch TABLECELLBOUNDARIES chain. This chain is not normal opener/closer inline mark chain. Fixes #42.
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
diff --git a/md4c/md4c.c b/md4c/md4c.c
index 50ff1c5..d81e804 100644
--- a/md4c/md4c.c
+++ b/md4c/md4c.c
@@ -125,13 +125,15 @@ struct MD_CTX_tag {
/* For resolving of inline spans. */
MD_MARKCHAIN mark_chains[8];
#define PTR_CHAIN ctx->mark_chains[0]
-#define BACKTICK_OPENERS ctx->mark_chains[1]
-#define LOWERTHEN_OPENERS ctx->mark_chains[2]
-#define ASTERISK_OPENERS ctx->mark_chains[3]
-#define UNDERSCORE_OPENERS ctx->mark_chains[4]
-#define TILDE_OPENERS ctx->mark_chains[5]
-#define BRACKET_OPENERS ctx->mark_chains[6]
-#define TABLECELLBOUNDARIES ctx->mark_chains[7]
+#define TABLECELLBOUNDARIES ctx->mark_chains[1]
+#define BACKTICK_OPENERS ctx->mark_chains[2]
+#define LOWERTHEN_OPENERS ctx->mark_chains[3]
+#define ASTERISK_OPENERS ctx->mark_chains[4]
+#define UNDERSCORE_OPENERS ctx->mark_chains[5]
+#define TILDE_OPENERS ctx->mark_chains[6]
+#define BRACKET_OPENERS ctx->mark_chains[7]
+#define OPENERS_CHAIN_FIRST 2
+#define OPENERS_CHAIN_LAST 7
int n_table_cell_boundaries;
@@ -2624,9 +2626,8 @@ md_rollback(MD_CTX* ctx, int opener_index, int closer_index, int how)
int i;
int mark_index;
- /* Cut all unresolved openers at the mark index.
- * (start at 1 to not touch PTR_CHAIN.) */
- for(i = 1; i < SIZEOF_ARRAY(ctx->mark_chains); i++) {
+ /* Cut all unresolved openers at the mark index. */
+ for(i = OPENERS_CHAIN_FIRST; i < OPENERS_CHAIN_LAST+1; i++) {
MD_MARKCHAIN* chain = &ctx->mark_chains[i];
while(chain->tail >= opener_index)
diff --git a/test/tables.txt b/test/tables.txt
index fc7a4da..c06a4ce 100644
--- a/test/tables.txt
+++ b/test/tables.txt
@@ -309,3 +309,28 @@ 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)
+```
+] http://x.x *x*
+
+|x|x|
+|---|---|
+|x|
+.
+<p>] <a href="http://x.x">http://x.x</a> <em>x</em></p>
+<table>
+<thead>
+<tr>
+<th>x</th>
+<th>x</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td>x</td>
+</tr>
+</tbody>
+</table>
+```