Skip to content

Commit

Permalink
md_analyze_tilde: Pop from chain tail like other emphasis.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mity committed Jan 17, 2024
1 parent 006611b commit 4728cd9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/md4c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions test/regressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
````````````````````````````````

0 comments on commit 4728cd9

Please sign in to comment.