summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2016-06-23 09:56:27 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2016-06-23 09:56:27 -0700
commitcf3ae36b3479a563f98780352e9fd9cf1c1cff81 (patch)
tree25c658f83f7fde4aa50e3b9873980654ba056cf6 /src
parent649ce73b841de7c7a3385e1e219b84c61f2081a6 (diff)
Revert "Better parsing of shortcut references."
This reverts commit c069cb55bcadfd0f45890d846ff412b3c892eb87.
Diffstat (limited to 'src')
-rw-r--r--src/inlines.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/inlines.c b/src/inlines.c
index 02e6a9a..8f18e6c 100644
--- a/src/inlines.c
+++ b/src/inlines.c
@@ -751,11 +751,11 @@ noMatch:
// Return a link, an image, or a literal close bracket.
static cmark_node *handle_close_bracket(subject *subj) {
- bufsize_t initial_pos, save_pos;
+ bufsize_t initial_pos;
bufsize_t starturl, endurl, starttitle, endtitle, endall;
bufsize_t n;
bufsize_t sps;
- cmark_reference *ref = NULL;
+ cmark_reference *ref;
bool is_image = false;
cmark_chunk url_chunk, title_chunk;
cmark_chunk url, title;
@@ -830,6 +830,11 @@ static cmark_node *handle_close_bracket(subject *subj) {
// skip spaces
raw_label = cmark_chunk_literal("");
found_label = link_label(subj, &raw_label);
+ if (!found_label || raw_label.len == 0) {
+ cmark_chunk_free(subj->mem, &raw_label);
+ raw_label = cmark_chunk_dup(&subj->input, opener->position,
+ initial_pos - opener->position - 1);
+ }
if (!found_label) {
// If we have a shortcut reference link, back up
@@ -837,22 +842,12 @@ static cmark_node *handle_close_bracket(subject *subj) {
subj->pos = initial_pos;
}
- if (!found_label || raw_label.len == 0) {
- save_pos = subj->pos;
- subj->pos = opener->position - 1;
- cmark_chunk_free(subj->mem, &raw_label);
- found_label = link_label(subj, &raw_label);
- subj->pos = save_pos;
- }
-
- if (found_label) {
- ref = cmark_reference_lookup(subj->refmap, &raw_label);
- }
+ ref = cmark_reference_lookup(subj->refmap, &raw_label);
+ cmark_chunk_free(subj->mem, &raw_label);
- if (ref) {
+ if (ref != NULL) { // found
url = chunk_clone(subj->mem, &ref->url);
title = chunk_clone(subj->mem, &ref->title);
- cmark_chunk_free(subj->mem, &raw_label);
goto match;
} else {
goto noMatch;