diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-06-01 22:59:49 +0200 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-06-01 23:00:20 +0200 |
commit | 8270cf85fc1ee514ccef54d4c545e9ba97b4c003 (patch) | |
tree | b79129efebc065400a0d847125ea8ae5fc9e719d /src | |
parent | 32d19737621ac43435ef0c39424b541e867ab642 (diff) |
Fixed `is_autolink`.
Previously *any* link with an absolute URL was treated as an
autolink. Closes #50. See also jgm/pandoc#2203.
Diffstat (limited to 'src')
-rw-r--r-- | src/commonmark.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/commonmark.c b/src/commonmark.c index 805f139..47da191 100644 --- a/src/commonmark.c +++ b/src/commonmark.c @@ -239,6 +239,7 @@ is_autolink(cmark_node *node) { const char *title; const char *url; + cmark_node *link_text; if (node->type != CMARK_NODE_LINK) { return false; @@ -255,10 +256,13 @@ is_autolink(cmark_node *node) if (title != NULL && strlen(title) > 0) { return false; } - cmark_consolidate_text_nodes(node); - return (strncmp(url, - (char*)node->as.literal.data, - node->as.literal.len) == 0); + + link_text = node->first_child; + cmark_consolidate_text_nodes(link_text); + return ((int)strlen(url) == link_text->as.literal.len && + strncmp(url, + (char*)link_text->as.literal.data, + link_text->as.literal.len) == 0); } // if node is a block node, returns node. |