cmark

My personal build of CMark ✏️

Commit
9dd7a6510aa63506b4ea13b40f44b3094d8f637a
Parent
8a4d49f4571f3a49b298207c99b8578642fe5209
Author
John MacFarlane <jgm@berkeley.edu>
Date

man writer: use chunk literal in code blocks.

Diffstat

2 files changed, 25 insertions, 3 deletions

Status File Name N° Changes Insertions Deletions
Modified man/man3/cmark.3 23 23 0
Modified src/man.c 5 2 3
diff --git a/man/man3/cmark.3 b/man/man3/cmark.3
@@ -102,6 +102,18 @@ way, for example, turning all level\-3 headers into regular paragraphs.
 .IP
 .nf
 \f[C]
+void
+usage_example(cmark_node *root) {
+    cmark_event_type ev_type;
+    cmark_iter *iter = cmark_iter_new(root);
+
+    while ((ev_type = cmark_iter_next(iter)) != CMARK_EVENT_DONE) {
+        cmark_node *cur = cmark_iter_get_node(iter);
+        // Do something with `cur` and `ev_type`
+    }
+
+    cmark_iter_free(iter);
+}
 \f[]
 .fi
 
@@ -302,6 +314,7 @@ Simple interface:
 .IP
 .nf
 \f[C]
+cmark_node *document = cmark_parse_document("Hello *world*", 12);
 \f[]
 .fi
 .PP
@@ -309,6 +322,16 @@ Streaming interface:
 .IP
 .nf
 \f[C]
+cmark_parser *parser = cmark_parser_new();
+FILE *fp = fopen("myfile.md", "r");
+while ((bytes = fread(buffer, 1, sizeof(buffer), fp)) > 0) {
+       cmark_parser_feed(parser, buffer, bytes);
+       if (bytes < sizeof(buffer)) {
+           break;
+       }
+}
+document = cmark_parser_finish(parser);
+cmark_parser_free(parser);
 \f[]
 .fi
 
diff --git a/src/man.c b/src/man.c
@@ -59,7 +59,6 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 		switch(node->type) {
 		case CMARK_NODE_TEXT:
 		case CMARK_NODE_CODE:
-		case CMARK_NODE_INLINE_HTML:
 			escape_man(man, node->as.literal.data,
 				    node->as.literal.len);
 			break;
@@ -131,8 +130,8 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 	case CMARK_NODE_CODE_BLOCK:
 		cr(man);
 		strbuf_puts(man, ".IP\n.nf\n\\f[C]\n");
-		escape_man(man, node->string_content.ptr,
-			   node->string_content.size);
+		escape_man(man, node->as.literal.data,
+			   node->as.literal.len);
 		cr(man);
 		strbuf_puts(man, "\\f[]\n.fi");
 		cr(man);