diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2014-11-06 21:31:45 -0800 | 
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2014-11-06 21:34:11 -0800 | 
| commit | 471a814b81f2ac4340b60fcc49e9ff0c895a9f52 (patch) | |
| tree | a202f4b05d1be89417d829304672a72f31836d86 | |
| parent | 27446657d2731d30190db9c240e326959bf43442 (diff) | |
Quick fix to #168.
Ultimately we'll have a better (stack-based?) parser for
links, and we can have something more elegant.
This fix removes an optimization which gave wrong results for
`*hi [there*]`.
| -rw-r--r-- | src/inlines.c | 19 | 
1 files changed, 6 insertions, 13 deletions
diff --git a/src/inlines.c b/src/inlines.c index d205d60..810230c 100644 --- a/src/inlines.c +++ b/src/inlines.c @@ -669,11 +669,12 @@ static node_inl* handle_left_bracket(subject* subj)  	int n;  	int sps;  	int found_label; -	int endlabel, starturl, endurl, starttitle, endtitle, endall; +	int endlabel, startpos, starturl, endurl, starttitle, endtitle, endall;  	chunk rawlabel;  	chunk url, title; +	startpos = subj->pos;  	found_label = link_label(subj, &rawlabel);  	endlabel = subj->pos; @@ -702,13 +703,7 @@ static node_inl* handle_left_bracket(subject* subj)  				return make_link(lab, url, title);  			} else { -				// if we get here, we matched a label but didn't get further: -				subj->pos = endlabel; -				lab = parse_chunk_inlines(&rawlabel, subj->refmap); -				result = append_inlines(make_str(chunk_literal("[")), -							append_inlines(lab, -								       make_str(chunk_literal("]")))); -				return result; +			    goto noMatch;  			}  		} else {  			chunk rawlabel_tmp; @@ -733,16 +728,14 @@ static node_inl* handle_left_bracket(subject* subj)  				lab = parse_chunk_inlines(&rawlabel, NULL);  				result = make_ref_link(lab, ref);  			} else { -				subj->pos = endlabel; -				lab = parse_chunk_inlines(&rawlabel, subj->refmap); -				result = append_inlines(make_str(chunk_literal("[")), -							append_inlines(lab, make_str(chunk_literal("]")))); +			    goto noMatch;  			}  			return result;  		}  	} +noMatch:  	// If we fall through to here, it means we didn't match a link: -	advance(subj);  // advance past [ +	subj->pos = startpos + 1;  // advance past [  	return make_str(chunk_literal("["));  }  | 
