diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2014-11-19 17:05:04 +0100 |
---|---|---|
committer | Nick Wellnhofer <wellnhofer@aevum.de> | 2014-11-19 17:05:04 +0100 |
commit | fd13d0211f33a134a4c73882f1f2eaa423f1794a (patch) | |
tree | 90e45e1dd3cf5800e80f522904c5536a4fb11aba /src/node.c | |
parent | 14588ca3cd25982bdd34e5fc20e69c611e1c8817 (diff) |
Accessors for link titles
Diffstat (limited to 'src/node.c')
-rw-r--r-- | src/node.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -275,6 +275,34 @@ cmark_node_set_url(cmark_node *node, const char *url) { return 0; } +const char* +cmark_node_get_title(cmark_node *node) { + switch (node->type) { + case NODE_LINK: + case NODE_IMAGE: + return (char *)node->as.link.title; + default: + break; + } + + return NULL; +} + +int +cmark_node_set_title(cmark_node *node, const char *title) { + switch (node->type) { + case NODE_LINK: + case NODE_IMAGE: + free(node->as.link.title); + node->as.link.title = (unsigned char *)S_strdup(title); + return 1; + default: + break; + } + + return 0; +} + static inline bool S_is_block(cmark_node *node) { return node->type >= CMARK_NODE_FIRST_BLOCK |