summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-12-25 16:43:15 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-12-25 16:43:15 -0700
commit72a556fd3bd17feaffba2fb6faa8c8f2a3931643 (patch)
treefc71813d8302bd1ebb8d787e6c336c1dba17520d
parent7e3a34e7ea8a734e15ca27b9b86f14ca727698de (diff)
Updated C parser to handle #252.
Closes #252.
-rw-r--r--src/inlines.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/inlines.c b/src/inlines.c
index 3f69837..83545f4 100644
--- a/src/inlines.c
+++ b/src/inlines.c
@@ -31,6 +31,7 @@ typedef struct delimiter {
int position;
bool can_open;
bool can_close;
+ bool active;
} delimiter;
typedef struct {
@@ -342,6 +343,7 @@ static void push_delimiter(subject *subj, unsigned char c, bool can_open,
delim->previous->next = delim;
}
delim->position = subj->pos;
+ delim->active = true;
subj->last_delim = delim;
}
@@ -702,6 +704,12 @@ static cmark_node* handle_close_bracket(subject* subj, cmark_node *parent)
return make_str(cmark_chunk_literal("]"));
}
+ if (!opener->active) {
+ // take delimiter off stack
+ remove_delimiter(subj, opener);
+ return make_str(cmark_chunk_literal("]"));
+ }
+
// If we got here, we matched a potential link/image text.
is_image = opener->delim_char == '!';
link_text = opener->inl_text->next;
@@ -795,7 +803,7 @@ match:
parent->last_child = inl;
// process_emphasis will remove this delimiter and all later ones.
- // Now, if we have a link, we also want to remove earlier link
+ // Now, if we have a link, we also want to deactivate earlier link
// delimiters. (This code can be removed if we decide to allow links
// inside links.)
if (!is_image) {
@@ -803,7 +811,7 @@ match:
while (opener != NULL) {
tmp_delim = opener->previous;
if (opener->delim_char == '[') {
- remove_delimiter(subj, opener);
+ opener->active = false;
}
opener = tmp_delim;
}