diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2014-11-19 16:53:53 +0100 |
---|---|---|
committer | Nick Wellnhofer <wellnhofer@aevum.de> | 2014-11-19 17:00:58 +0100 |
commit | 285879585db2f284a1ce0896c4775be8a260d6db (patch) | |
tree | e23c09bf541867e19bf0cc66fcb25cac744487d7 | |
parent | 3776d23d40b8f638a2a97d7e54f2660c7c435090 (diff) |
Accessors for list data
Only 'list_type', 'start', and 'tight' should be relevant for rendering.
Accessors for other list data could be added for completeness but they
don't seem very useful.
-rw-r--r-- | src/cmark.h | 19 | ||||
-rw-r--r-- | src/node.c | 63 |
2 files changed, 82 insertions, 0 deletions
diff --git a/src/cmark.h b/src/cmark.h index a23b587..5305dfb 100644 --- a/src/cmark.h +++ b/src/cmark.h @@ -44,6 +44,7 @@ typedef enum { } cmark_node_type; typedef enum { + CMARK_NO_LIST, CMARK_BULLET_LIST, CMARK_ORDERED_LIST } cmark_list_type; @@ -101,6 +102,24 @@ cmark_node_get_header_level(cmark_node *node); CMARK_EXPORT int cmark_node_set_header_level(cmark_node *node, int level); +CMARK_EXPORT cmark_list_type +cmark_node_get_list_type(cmark_node *node); + +CMARK_EXPORT int +cmark_node_set_list_type(cmark_node *node, cmark_list_type type); + +CMARK_EXPORT int +cmark_node_get_list_start(cmark_node *node); + +CMARK_EXPORT int +cmark_node_set_list_start(cmark_node *node, int start); + +CMARK_EXPORT int +cmark_node_get_list_tight(cmark_node *node); + +CMARK_EXPORT int +cmark_node_set_list_tight(cmark_node *node, int tight); + CMARK_EXPORT const char* cmark_node_get_url(cmark_node *node); @@ -163,6 +163,69 @@ cmark_node_set_header_level(cmark_node *node, int level) { return 0; } +cmark_list_type +cmark_node_get_list_type(cmark_node *node) { + if (node->type == CMARK_NODE_LIST) { + return node->as.list.list_type; + } + else { + return CMARK_NO_LIST; + } +} + +int +cmark_node_set_list_type(cmark_node *node, cmark_list_type type) { + if (node->type == CMARK_NODE_LIST) { + node->as.list.list_type = type; + return 1; + } + else { + return 0; + } +} + +int +cmark_node_get_list_start(cmark_node *node) { + if (node->type == CMARK_NODE_LIST) { + return node->as.list.start; + } + else { + return 0; + } +} + +int +cmark_node_set_list_start(cmark_node *node, int start) { + if (node->type == CMARK_NODE_LIST) { + node->as.list.start = start; + return 1; + } + else { + return 0; + } +} + +int +cmark_node_get_list_tight(cmark_node *node) { + if (node->type == CMARK_NODE_LIST) { + return node->as.list.tight; + } + else { + return 0; + } +} + +int +cmark_node_set_list_tight(cmark_node *node, int tight) { + if (node->type == CMARK_NODE_LIST) { + node->as.list.tight = tight; + return 1; + } + else { + return 0; + } +} + const char* cmark_node_get_url(cmark_node *node) { switch (node->type) { |