aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2014-11-19 17:02:04 +0100
committerNick Wellnhofer <wellnhofer@aevum.de>2014-11-19 17:02:40 +0100
commit14588ca3cd25982bdd34e5fc20e69c611e1c8817 (patch)
treea4f89c4b7e21bf76e477ce89a24c1253a5219ce4
parent285879585db2f284a1ce0896c4775be8a260d6db (diff)
Accessors for fence info
Only fence info should be relevant for rendering. Accessors for other fenced code data could be added for completeness but they don't seem very useful.
-rw-r--r--src/cmark.h6
-rw-r--r--src/node.c21
2 files changed, 27 insertions, 0 deletions
diff --git a/src/cmark.h b/src/cmark.h
index 5305dfb..d9daccd 100644
--- a/src/cmark.h
+++ b/src/cmark.h
@@ -121,6 +121,12 @@ CMARK_EXPORT int
cmark_node_set_list_tight(cmark_node *node, int tight);
CMARK_EXPORT const char*
+cmark_node_get_fence_info(cmark_node *node);
+
+CMARK_EXPORT int
+cmark_node_set_fence_info(cmark_node *node, const char *info);
+
+CMARK_EXPORT const char*
cmark_node_get_url(cmark_node *node);
CMARK_EXPORT int
diff --git a/src/node.c b/src/node.c
index c1f29d3..814e0e1 100644
--- a/src/node.c
+++ b/src/node.c
@@ -227,6 +227,27 @@ cmark_node_set_list_tight(cmark_node *node, int tight) {
}
const char*
+cmark_node_get_fence_info(cmark_node *node) {
+ if (node->type == NODE_FENCED_CODE) {
+ return cmark_strbuf_cstr(&node->as.code.info);
+ }
+ else {
+ return NULL;
+ }
+}
+
+int
+cmark_node_set_fence_info(cmark_node *node, const char *info) {
+ if (node->type == NODE_FENCED_CODE) {
+ cmark_strbuf_sets(&node->as.code.info, info);
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+
+const char*
cmark_node_get_url(cmark_node *node) {
switch (node->type) {
case NODE_LINK: