summaryrefslogtreecommitdiff
path: root/src/node.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/node.c')
-rw-r--r--src/node.c66
1 files changed, 0 insertions, 66 deletions
diff --git a/src/node.c b/src/node.c
index 72eb619..ab3771b 100644
--- a/src/node.c
+++ b/src/node.c
@@ -766,69 +766,3 @@ cmark_node_check(cmark_node *node, FILE *out)
return errors;
}
-
-int S_is_leaf_node(cmark_node *current_node)
-{
- switch (cmark_node_get_type(current_node)) {
- case CMARK_NODE_HTML:
- case CMARK_NODE_HRULE:
- case CMARK_NODE_CODE_BLOCK:
- case CMARK_NODE_TEXT:
- case CMARK_NODE_SOFTBREAK:
- case CMARK_NODE_LINEBREAK:
- case CMARK_NODE_INLINE_CODE:
- case CMARK_NODE_INLINE_HTML:
- return 1;
- default:
- return 0;
- }
-}
-
-int cmark_walk(cmark_node *root, cmark_node_handler handler, void *state)
-{
- int ev_type = CMARK_EVENT_ENTER;
- cmark_node *current_node = root;
- int depth = 0;
- cmark_node *next, *parent, *first_child;
-
- while (current_node != NULL && depth >= 0) {
-
- next = current_node->next;
- parent = current_node->parent;
-
- if (!handler(current_node, ev_type, state)) {
- return 0;
- }
-
- if (ev_type == CMARK_EVENT_ENTER &&
- !S_is_leaf_node(current_node)) {
- first_child = current_node->first_child;
- if (first_child == NULL) {
- ev_type = CMARK_EVENT_EXIT; // stay on this node
- } else {
- depth += 1;
- current_node = first_child;
- }
- } else {
- if (current_node) {
- next = current_node->next;
- parent = current_node->parent;
- }
- if (next) {
- // don't go past root:
- if (current_node == root) {
- ev_type = CMARK_EVENT_DONE;
- return 1;
- } else {
- ev_type = CMARK_EVENT_ENTER;
- current_node = next;
- }
- } else {
- ev_type = CMARK_EVENT_EXIT;
- depth -= 1;
- current_node = parent;
- }
- }
- }
- return 1;
-}