summaryrefslogtreecommitdiff
path: root/src/inlines.c
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-01-03 20:45:12 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2017-01-03 20:45:12 -0800
commitcc50a3aba3e34dc58ca819a65b907871e2ea6fd9 (patch)
treefdaad4695a5a68a63f6d899f713cf3a9b020df43 /src/inlines.c
parent26182bb868d3da7dd8a3389729bea79d489855b7 (diff)
Fix "multiple of 3" determination in emph/strong parsing.
We need to store the length of the original delimiter run, instead of using the length of the remaining delimiters after some have been subtracted. Test case: a***b* c* Thanks to Raph Levin for reporting.
Diffstat (limited to 'src/inlines.c')
-rw-r--r--src/inlines.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/inlines.c b/src/inlines.c
index 099078e..02b4723 100644
--- a/src/inlines.c
+++ b/src/inlines.c
@@ -40,6 +40,7 @@ typedef struct delimiter {
struct delimiter *previous;
struct delimiter *next;
cmark_node *inl_text;
+ bufsize_t length;
unsigned char delim_char;
bool can_open;
bool can_close;
@@ -408,6 +409,7 @@ static void push_delimiter(subject *subj, unsigned char c, bool can_open,
delim->can_open = can_open;
delim->can_close = can_close;
delim->inl_text = inl_text;
+ delim->length = inl_text->as.literal.len;
delim->previous = subj->last_delim;
delim->next = NULL;
if (delim->previous != NULL) {
@@ -553,10 +555,7 @@ static void process_emphasis(subject *subj, delimiter *stack_bottom) {
// interior closer of size 2 can't match opener of size 1
// or of size 1 can't match 2
odd_match = (closer->can_open || opener->can_close) &&
- ((opener->inl_text->as.literal.len +
- closer->inl_text->as.literal.len) %
- 3 ==
- 0);
+ ((opener->length + closer->length) % 3 == 0);
if (opener->delim_char == closer->delim_char && opener->can_open &&
!odd_match) {
opener_found = true;