Skip to content

Commit

Permalink
Fix parsing of emphasis before links
Browse files Browse the repository at this point in the history
Fix a regression introduced with commit ed0a4bf. Also test the first
delimiter against stack_bottom in process_emphasis. This happened to
work with the old code and only resulted in an unnecessary scan.

Fixes commonmark#424.
  • Loading branch information
nwellnhof committed Sep 24, 2021
1 parent c964590 commit cee65ce
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/inlines.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,8 @@ static cmark_node *handle_period(subject *subj, bool smart) {
}

static void process_emphasis(subject *subj, bufsize_t stack_bottom) {
delimiter *closer = subj->last_delim;
delimiter *candidate;
delimiter *closer = NULL;
delimiter *opener;
delimiter *old_closer;
bool opener_found;
Expand All @@ -650,10 +651,10 @@ static void process_emphasis(subject *subj, bufsize_t stack_bottom) {
stack_bottom, stack_bottom, stack_bottom};

// move back to first relevant delim.
while (closer != NULL &&
closer->previous != NULL &&
closer->previous->position >= stack_bottom) {
closer = closer->previous;
candidate = subj->last_delim;
while (candidate != NULL && candidate->position >= stack_bottom) {
closer = candidate;
candidate = closer->previous;
}

// now move forward, looking for closers, and handling each
Expand Down

0 comments on commit cee65ce

Please sign in to comment.