Commit 99a556890950491de1d8153d1d33e4ccbb268600

Martin Mitas 2018-05-29T22:42:24

md_is_inline_link_spec_helper: Link destination is mandatory... ... unless it is omitted also with the title.

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,