md_analyze_tilde: Pop from chain tail like other emphasis. The function incorrectly used header from the head, leading to wrong result (incompatible with e.. GFM) but even worse to bad internal state md_rollback() is then potentially unable to solve. Fixes #222.
diff --git a/src/md4c.c b/src/md4c.c
index f325c79..580fc32 100644
--- a/src/md4c.c
+++ b/src/md4c.c
@@ -3836,8 +3836,8 @@ md_analyze_tilde(MD_CTX* ctx, int mark_index)
* only tildes sequences of length 1 and 2, and the length of the opener
* and closer has to match. */
- if((mark->flags & MD_MARK_POTENTIAL_CLOSER) && chain->head >= 0) {
- int opener_index = chain->head;
+ if((mark->flags & MD_MARK_POTENTIAL_CLOSER) && chain->tail >= 0) {
+ int opener_index = chain->tail;
md_rollback(ctx, opener_index, mark_index, MD_ROLLBACK_CROSSING);
md_resolve_range(ctx, chain, opener_index, mark_index);
diff --git a/test/regressions.txt b/test/regressions.txt
index a738af2..9d5b755 100644
--- a/test/regressions.txt
+++ b/test/regressions.txt
@@ -672,3 +672,14 @@ _*xx-_-
<p><em>*__-</em>-</p>
<p><em>*xx-</em>-</p>
````````````````````````````````
+
+
+## [Issue 222](https://github.com/mity/md4c/issues/222)
+
+```````````````````````````````` example
+~foo ~bar baz~
+.
+<p>~foo <del>bar baz</del></p>
+.
+--fstrikethrough
+````````````````````````````````