Skip to content

Commit

Permalink
md_rollback: Fix dummization of virtual closers.
Browse files Browse the repository at this point in the history
Fixes #173.
  • Loading branch information
mity committed Jan 14, 2022
1 parent 6abb778 commit f7c8db7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/md4c.c
Original file line number Diff line number Diff line change
Expand Up @@ -2693,10 +2693,11 @@ md_rollback(MD_CTX* ctx, int opener_index, int closer_index, int how)

/* And reset our flags. */
if(discard_flag) {
mark->flags &= ~(MD_MARK_OPENER | MD_MARK_CLOSER | MD_MARK_RESOLVED);
/* Make zero-length closer a dummy mark as that's how it was born */
if((mark->flags & MD_MARK_CLOSER) && mark->beg == mark->end)
mark->ch = 'D';

mark->flags &= ~(MD_MARK_OPENER | MD_MARK_CLOSER | MD_MARK_RESOLVED);
}

/* Jump as far as we can over unresolved or non-interesting marks. */
Expand Down Expand Up @@ -3938,7 +3939,7 @@ md_analyze_permissive_url_autolink(MD_CTX* ctx, int mark_index)
/* Ok. Lets call it an auto-link. Adapt opener and create closer to zero
* length so all the contents becomes the link text. */
MD_ASSERT(closer->ch == 'D' ||
(ctx->parser.flags & MD_FLAG_PERMISSIVEWWWAUTOLINKS &&
((ctx->parser.flags & MD_FLAG_PERMISSIVEWWWAUTOLINKS) &&
(closer->ch == '.' || closer->ch == ':' || closer->ch == '@')));
opener->end = opener->beg;
closer->ch = opener->ch;
Expand Down

0 comments on commit f7c8db7

Please sign in to comment.