From 8d6efe632aaeb1831c86b27e120a344c5e3ee7d4 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 13 Dec 2014 12:08:19 -0800 Subject: API improvements: cmark_event_type parameter for walk handlers. Added cmark_event_type enum, which is used as the second parameter of the handler passed to cmark_walk. See #224. --- src/cmark.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/cmark.h') diff --git a/src/cmark.h b/src/cmark.h index 224ef3a..a43703a 100644 --- a/src/cmark.h +++ b/src/cmark.h @@ -85,7 +85,14 @@ typedef enum { typedef struct cmark_node cmark_node; typedef struct cmark_parser cmark_parser; -typedef int (*cmark_node_handler)(cmark_node*, int, void*); +typedef enum { + CMARK_EVENT_DONE, + CMARK_EVENT_ENTER, + CMARK_EVENT_EXIT +} cmark_event_type; + +typedef int (*cmark_node_handler)(cmark_node *node, cmark_event_type ev_type, + void *state); /** * .SH CREATING AND DESTROYING NODES @@ -311,7 +318,7 @@ char *cmark_render_html(cmark_node *root); /** Walks the tree starting from root, applying handler to each node. * Nodes that can have children are visited twice, once on the way in * and once on the way out. handler is a function that takes a node - * pointer, an integer direction (1 for entering, 0 for leaving), + * pointer, a cmark_event_type, * and a pointer to a state structure that can be consulted and * updated by the handler. The handler should return 1 on success, * 0 on failure. cmark_walk returns 1 if it traversed the entire -- cgit v1.2.3