summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api_test/main.c7
-rw-r--r--src/cmark.h12
-rw-r--r--src/node.c33
3 files changed, 52 insertions, 0 deletions
diff --git a/api_test/main.c b/api_test/main.c
index 88f7cef..b098c41 100644
--- a/api_test/main.c
+++ b/api_test/main.c
@@ -75,6 +75,9 @@ constructor(test_batch_runner *runner)
INT_EQ(runner, cmark_node_get_list_type(node),
CMARK_BULLET_LIST,
"default is list type is bullet");
+ INT_EQ(runner, cmark_node_get_list_delim(node),
+ CMARK_NO_DELIM,
+ "default is list delim is NO_DELIM");
INT_EQ(runner, cmark_node_get_list_start(node), 1,
"default is list start is 1");
INT_EQ(runner, cmark_node_get_list_tight(node), 0,
@@ -130,6 +133,8 @@ accessors(test_batch_runner *runner)
cmark_node *ordered_list = cmark_node_next(bullet_list);
INT_EQ(runner, cmark_node_get_list_type(ordered_list),
CMARK_ORDERED_LIST, "get_list_type ordered");
+ INT_EQ(runner, cmark_node_get_list_delim(ordered_list),
+ CMARK_PERIOD_DELIM, "get_list_delim ordered");
INT_EQ(runner, cmark_node_get_list_start(ordered_list), 2,
"get_list_start");
INT_EQ(runner, cmark_node_get_list_tight(ordered_list), 0,
@@ -174,6 +179,8 @@ accessors(test_batch_runner *runner)
OK(runner, cmark_node_set_list_type(bullet_list, CMARK_ORDERED_LIST),
"set_list_type ordered");
+ OK(runner, cmark_node_set_list_delim(bullet_list, CMARK_PAREN_DELIM),
+ "set_list_delim paren");
OK(runner, cmark_node_set_list_start(bullet_list, 3),
"set_list_start");
OK(runner, cmark_node_set_list_tight(bullet_list, 0),
diff --git a/src/cmark.h b/src/cmark.h
index 3d2ed15..8196158 100644
--- a/src/cmark.h
+++ b/src/cmark.h
@@ -238,6 +238,18 @@ cmark_node_get_list_type(cmark_node *node);
CMARK_EXPORT int
cmark_node_set_list_type(cmark_node *node, cmark_list_type type);
+/** Returns the list delimiter type of 'node', or `CMARK_NO_DELIM` if 'node'
+ * is not a list.
+ */
+CMARK_EXPORT cmark_delim_type
+cmark_node_get_list_delim(cmark_node *node);
+
+/** Sets the list delimiter type of 'node', returning 1 on success and 0
+ * on error.
+ */
+CMARK_EXPORT int
+cmark_node_set_list_delim(cmark_node *node, cmark_delim_type delim);
+
/** Returns starting number of 'node', if it is an ordered list, otherwise 0.
*/
CMARK_EXPORT int
diff --git a/src/node.c b/src/node.c
index 88b1281..199dd38 100644
--- a/src/node.c
+++ b/src/node.c
@@ -292,6 +292,39 @@ cmark_node_set_list_type(cmark_node *node, cmark_list_type type) {
}
}
+cmark_delim_type
+cmark_node_get_list_delim(cmark_node *node) {
+ if (node == NULL) {
+ return CMARK_NO_DELIM;
+ }
+
+ if (node->type == CMARK_NODE_LIST) {
+ return node->as.list.delimiter;
+ }
+ else {
+ return CMARK_NO_DELIM;
+ }
+}
+
+int
+cmark_node_set_list_delim(cmark_node *node, cmark_delim_type delim) {
+ if (!(delim == CMARK_PERIOD_DELIM || delim == CMARK_PAREN_DELIM)) {
+ return 0;
+ }
+
+ if (node == NULL) {
+ return 0;
+ }
+
+ if (node->type == CMARK_NODE_LIST) {
+ node->as.list.delimiter = delim;
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+
int
cmark_node_get_list_start(cmark_node *node) {
if (node == NULL) {