diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2014-11-19 16:38:22 +0100 |
---|---|---|
committer | Nick Wellnhofer <wellnhofer@aevum.de> | 2014-11-19 16:38:22 +0100 |
commit | 3776d23d40b8f638a2a97d7e54f2660c7c435090 (patch) | |
tree | 43e29909fea98a44d7cdca741a68e5d7169ae9ec /src | |
parent | b93d0b3a479bfc05dfbba0ad84172302df7f48cc (diff) |
Accessors for header level
Diffstat (limited to 'src')
-rw-r--r-- | src/cmark.h | 6 | ||||
-rw-r--r-- | src/node.c | 29 |
2 files changed, 35 insertions, 0 deletions
diff --git a/src/cmark.h b/src/cmark.h index e677ed0..a23b587 100644 --- a/src/cmark.h +++ b/src/cmark.h @@ -95,6 +95,12 @@ cmark_node_get_string_content(cmark_node *node); CMARK_EXPORT int cmark_node_set_string_content(cmark_node *node, const char *content); +CMARK_EXPORT int +cmark_node_get_header_level(cmark_node *node); + +CMARK_EXPORT int +cmark_node_set_header_level(cmark_node *node, int level); + CMARK_EXPORT const char* cmark_node_get_url(cmark_node *node); @@ -134,6 +134,35 @@ cmark_node_set_string_content(cmark_node *node, const char *content) { return 0; } +int +cmark_node_get_header_level(cmark_node *node) { + switch (node->type) { + case CMARK_NODE_ATX_HEADER: + case CMARK_NODE_SETEXT_HEADER: + return node->as.header.level; + + default: + break; + } + + return 0; +} + +int +cmark_node_set_header_level(cmark_node *node, int level) { + switch (node->type) { + case CMARK_NODE_ATX_HEADER: + case CMARK_NODE_SETEXT_HEADER: + node->as.header.level = level; + return 1; + + default: + break; + } + + return 0; +} + const char* cmark_node_get_url(cmark_node *node) { switch (node->type) { |