summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-06-01 22:59:49 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2015-06-01 23:00:20 +0200
commit8270cf85fc1ee514ccef54d4c545e9ba97b4c003 (patch)
treeb79129efebc065400a0d847125ea8ae5fc9e719d /src
parent32d19737621ac43435ef0c39424b541e867ab642 (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.c12
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.