md_is_inline_link_spec_helper: Link destination is mandatory... ... unless it is omitted also with the title.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
diff --git a/md4c/md4c.c b/md4c/md4c.c
index 8f9ed19..3607c5a 100644
--- a/md4c/md4c.c
+++ b/md4c/md4c.c
@@ -2305,17 +2305,23 @@ md_is_inline_link_spec_helper(MD_CTX* ctx, const MD_LINE* lines, int n_lines,
off = lines[line_index].beg;
}
- /* (Optional) link destination. */
- if(!is_link_dest_fn(ctx, off, lines[line_index].end,
- &off, &attr->dest_beg, &attr->dest_end)) {
- if(is_link_dest_fn == md_is_link_destination_B) {
- attr->dest_beg = off;
- attr->dest_end = off;
- } else {
- return FALSE;
- }
+ /* Link destination may be omitted, but only when not also having a title. */
+ if(off < ctx->size && CH(off) == _T(')')) {
+ attr->dest_beg = off;
+ attr->dest_end = off;
+ attr->title = NULL;
+ attr->title_size = 0;
+ attr->title_needs_free = FALSE;
+ off++;
+ *p_end = off;
+ return TRUE;
}
+ /* Link destination. */
+ if(!is_link_dest_fn(ctx, off, lines[line_index].end,
+ &off, &attr->dest_beg, &attr->dest_end))
+ return FALSE;
+
/* (Optional) title. */
if(md_is_link_title(ctx, lines + line_index, n_lines - line_index, off,
&off, &title_contents_line_index, &tmp_line_index,