cmark

My personal build of CMark ✏️

Commit
d6077ea037e23f6e2c0d83dda7b5d7106f48d1a3
Parent
ab19f3cf3c247a5216ae7e7e78ef8c2eaac7ce0a
Author
John MacFarlane <fiddlosopher@gmail.com>
Date

Re-added cmark_ prefix to strbuf and chunk.

Reverts 225d720.

Diffstat

23 files changed, 421 insertions, 422 deletions

Status File Name N° Changes Insertions Deletions
Modified man/man3/cmark.3 2 1 1
Modified src/blocks.c 86 43 43
Modified src/buffer.c 108 54 54
Modified src/buffer.h 82 41 41
Modified src/chunk.h 34 17 17
Modified src/houdini.h 26 13 13
Modified src/houdini_href_e.c 12 6 6
Modified src/houdini_html_e.c 10 5 5
Modified src/houdini_html_u.c 16 8 8
Modified src/html.c 94 47 47
Modified src/inlines.c 146 73 73
Modified src/inlines.h 6 3 3
Modified src/man.c 72 36 36
Modified src/node.c 16 8 8
Modified src/node.h 7 3 4
Modified src/parser.h 4 2 2
Modified src/print.c 74 37 37
Modified src/references.c 16 8 8
Modified src/references.h 4 2 2
Modified src/scanners.c 2 1 1
Modified src/scanners.h 2 1 1
Modified src/utf8.c 18 9 9
Modified src/utf8.h 6 3 3
diff --git a/man/man3/cmark.3 b/man/man3/cmark.3
@@ -1,4 +1,4 @@
-.TH cmark 3 "December 14, 2014" "LOCAL" "Library Functions Manual"
+.TH cmark 3 "December 15, 2014" "LOCAL" "Library Functions Manual"
 .SH
 NAME
 .PP
diff --git a/src/blocks.c b/src/blocks.c
@@ -37,7 +37,7 @@ static cmark_node* make_block(cmark_node_type tag, int start_line, int start_col
 		e->start_line = start_line;
 		e->start_column = start_column;
 		e->end_line = start_line;
-		strbuf_init(&e->string_content, 32);
+		cmark_strbuf_init(&e->string_content, 32);
 	}
 
 	return e;
@@ -54,10 +54,10 @@ cmark_parser *cmark_parser_new()
 {
 	cmark_parser *parser = (cmark_parser*)malloc(sizeof(cmark_parser));
 	cmark_node *document = make_document();
-	strbuf *line = (strbuf*)malloc(sizeof(strbuf));
-	strbuf *buf  = (strbuf*)malloc(sizeof(strbuf));
-	strbuf_init(line, 256);
-	strbuf_init(buf, 0);
+	cmark_strbuf *line = (cmark_strbuf*)malloc(sizeof(cmark_strbuf));
+	cmark_strbuf *buf  = (cmark_strbuf*)malloc(sizeof(cmark_strbuf));
+	cmark_strbuf_init(line, 256);
+	cmark_strbuf_init(buf, 0);
 
 	parser->refmap = cmark_reference_map_new();
 	parser->root = document;
@@ -71,9 +71,9 @@ cmark_parser *cmark_parser_new()
 
 void cmark_parser_free(cmark_parser *parser)
 {
-	strbuf_free(parser->curline);
+	cmark_strbuf_free(parser->curline);
 	free(parser->curline);
-	strbuf_free(parser->linebuf);
+	cmark_strbuf_free(parser->linebuf);
 	free(parser->linebuf);
 	cmark_reference_map_free(parser->refmap);
 	free(parser);
@@ -83,7 +83,7 @@ static cmark_node*
 finalize(cmark_parser *parser, cmark_node* b, int line_number);
 
 // Returns true if line has only space characters, else false.
-static bool is_blank(strbuf *s, int offset)
+static bool is_blank(cmark_strbuf *s, int offset)
 {
 	while (offset < s->size) {
 		switch (s->ptr[offset]) {
@@ -115,13 +115,13 @@ static inline bool accepts_lines(cmark_node_type block_type)
 		block_type == NODE_CODE_BLOCK);
 }
 
-static void add_line(cmark_node* cmark_node, chunk *ch, int offset)
+static void add_line(cmark_node* cmark_node, cmark_chunk *ch, int offset)
 {
 	assert(cmark_node->open);
-	strbuf_put(&cmark_node->string_content, ch->data + offset, ch->len - offset);
+	cmark_strbuf_put(&cmark_node->string_content, ch->data + offset, ch->len - offset);
 }
 
-static void remove_trailing_blank_lines(strbuf *ln)
+static void remove_trailing_blank_lines(cmark_strbuf *ln)
 {
 	int i;
 
@@ -133,13 +133,13 @@ static void remove_trailing_blank_lines(strbuf *ln)
 	}
 
 	if (i < 0) {
-		strbuf_clear(ln);
+		cmark_strbuf_clear(ln);
 		return;
 	}
 
-	i = strbuf_strchr(ln, '\n', i);
+	i = cmark_strbuf_strchr(ln, '\n', i);
 	if (i >= 0)
-		strbuf_truncate(ln, i);
+		cmark_strbuf_truncate(ln, i);
 }
 
 // Check to see if a cmark_node ends with a blank line, descending
@@ -200,10 +200,10 @@ finalize(cmark_parser *parser, cmark_node* b, int line_number)
 
 	switch (b->type) {
 		case NODE_PARAGRAPH:
-			while (strbuf_at(&b->string_content, 0) == '[' &&
+			while (cmark_strbuf_at(&b->string_content, 0) == '[' &&
 					(pos = cmark_parse_reference_inline(&b->string_content, parser->refmap))) {
 
-				strbuf_drop(&b->string_content, pos);
+				cmark_strbuf_drop(&b->string_content, pos);
 			}
 			if (is_blank(&b->string_content, 0)) {
 				// remove blank node (former reference def)
@@ -214,29 +214,29 @@ finalize(cmark_parser *parser, cmark_node* b, int line_number)
 		case NODE_CODE_BLOCK:
 			if (!b->as.code.fenced) { // indented code
 				remove_trailing_blank_lines(&b->string_content);
-				strbuf_putc(&b->string_content, '\n');
+				cmark_strbuf_putc(&b->string_content, '\n');
 			} else {
 
 				// first line of contents becomes info
-				firstlinelen = strbuf_strchr(&b->string_content, '\n', 0);
+				firstlinelen = cmark_strbuf_strchr(&b->string_content, '\n', 0);
 
-				strbuf tmp = GH_BUF_INIT;
+				cmark_strbuf tmp = GH_BUF_INIT;
 				houdini_unescape_html_f(
 					&tmp,
 					b->string_content.ptr,
 					firstlinelen
 					);
-				strbuf_trim(&tmp);
-				strbuf_unescape(&tmp);
-				b->as.code.info = chunk_buf_detach(&tmp);
+				cmark_strbuf_trim(&tmp);
+				cmark_strbuf_unescape(&tmp);
+				b->as.code.info = cmark_chunk_buf_detach(&tmp);
 
-				strbuf_drop(&b->string_content, firstlinelen + 1);
+				cmark_strbuf_drop(&b->string_content, firstlinelen + 1);
 			}
-			b->as.literal = chunk_buf_detach(&b->string_content);
+			b->as.literal = cmark_chunk_buf_detach(&b->string_content);
 			break;
 
 	        case NODE_HTML:
-			b->as.literal = chunk_buf_detach(&b->string_content);
+			b->as.literal = cmark_chunk_buf_detach(&b->string_content);
 			break;
 
 		case NODE_LIST: // determine tight/loose status
@@ -325,7 +325,7 @@ static void process_inlines(cmark_node* root, cmark_reference_map *refmap)
 // Attempts to parse a list item marker (bullet or enumerated).
 // On success, returns length of the marker, and populates
 // data with the details.  On failure, returns 0.
-static int parse_list_marker(chunk *input, int pos, cmark_list **dataptr)
+static int parse_list_marker(cmark_chunk *input, int pos, cmark_list **dataptr)
 {
 	unsigned char c;
 	int startpos;
@@ -466,15 +466,15 @@ S_parser_feed(cmark_parser *parser, const unsigned char *buffer, size_t len,
 			line_len = end - buffer;
 		}
 		else {
-			strbuf_put(parser->linebuf, buffer, end - buffer);
+			cmark_strbuf_put(parser->linebuf, buffer, end - buffer);
 			break;
 		}
 
 		if (parser->linebuf->size > 0) {
-			strbuf_put(parser->linebuf, buffer, line_len);
+			cmark_strbuf_put(parser->linebuf, buffer, line_len);
 			S_process_line(parser, parser->linebuf->ptr,
 				       parser->linebuf->size);
-			strbuf_clear(parser->linebuf);
+			cmark_strbuf_clear(parser->linebuf);
 		}
 		else {
 			S_process_line(parser, buffer, line_len);
@@ -484,11 +484,11 @@ S_parser_feed(cmark_parser *parser, const unsigned char *buffer, size_t len,
 	}
 }
 
-static void chop_trailing_hashtags(chunk *ch)
+static void chop_trailing_hashtags(cmark_chunk *ch)
 {
 	int n, orig_n;
 
-	chunk_rtrim(ch);
+	cmark_chunk_rtrim(ch);
 	orig_n = n = ch->len - 1;
 
 	// if string ends in space followed by #s, remove these:
@@ -498,7 +498,7 @@ static void chop_trailing_hashtags(chunk *ch)
 	// Check for a be a space before the final #s:
 	if (n != orig_n && n >= 0 && peek_at(ch, n) == ' ') {
 		ch->len = n;
-		chunk_rtrim(ch);
+		cmark_chunk_rtrim(ch);
 	}
 }
 
@@ -517,14 +517,14 @@ S_process_line(cmark_parser *parser, const unsigned char *buffer, size_t bytes)
 	bool blank = false;
 	int first_nonspace;
 	int indent;
-	chunk input;
+	cmark_chunk input;
 
 	utf8proc_detab(parser->curline, buffer, bytes);
 
 	// Add a newline to the end if not present:
 	// TODO this breaks abstraction:
 	if (parser->curline->ptr[parser->curline->size - 1] != '\n') {
-		strbuf_putc(parser->curline, '\n');
+		cmark_strbuf_putc(parser->curline, '\n');
 	}
 	input.data = parser->curline->ptr;
 	input.len = parser->curline->size;
@@ -645,7 +645,7 @@ S_process_line(cmark_parser *parser, const unsigned char *buffer, size_t bytes)
 				container->as.code.fence_char = 0;
 				container->as.code.fence_length = 0;
 				container->as.code.fence_offset = 0;
-				container->as.code.info = chunk_literal("");
+				container->as.code.info = cmark_chunk_literal("");
 			} else { // indent > 4 in lazy line
 				break;
 			}
@@ -663,7 +663,7 @@ S_process_line(cmark_parser *parser, const unsigned char *buffer, size_t bytes)
 			offset = first_nonspace + matched;
 			container = add_child(parser, container, NODE_HEADER, parser->line_number, offset + 1);
 
-			int hashpos = chunk_strchr(&input, '#', first_nonspace);
+			int hashpos = cmark_chunk_strchr(&input, '#', first_nonspace);
 			int level = 0;
 
 			while (peek_at(&input, hashpos) == '#') {
@@ -680,7 +680,7 @@ S_process_line(cmark_parser *parser, const unsigned char *buffer, size_t bytes)
 			container->as.code.fence_char = peek_at(&input, first_nonspace);
 			container->as.code.fence_length = matched;
 			container->as.code.fence_offset = first_nonspace - offset;
-			container->as.code.info = chunk_literal("");
+			container->as.code.info = cmark_chunk_literal("");
 			offset = first_nonspace + matched;
 
 		} else if ((matched = scan_html_block_tag(&input, first_nonspace))) {
@@ -691,8 +691,8 @@ S_process_line(cmark_parser *parser, const unsigned char *buffer, size_t bytes)
 		} else if (container->type == NODE_PARAGRAPH &&
 				(lev = scan_setext_header_line(&input, first_nonspace)) &&
 				// check that there is only one line in the paragraph:
-				strbuf_strrchr(&container->string_content, '\n',
-					strbuf_len(&container->string_content) - 2) < 0) {
+				cmark_strbuf_strrchr(&container->string_content, '\n',
+					cmark_strbuf_len(&container->string_content) - 2) < 0) {
 
 			container->type = NODE_HEADER;
 			container->as.header.level = lev;
@@ -789,7 +789,7 @@ S_process_line(cmark_parser *parser, const unsigned char *buffer, size_t bytes)
 			container == last_matched_container &&
 			!blank &&
 			cur->type == NODE_PARAGRAPH &&
-			strbuf_len(&cur->string_content) > 0) {
+			cmark_strbuf_len(&cur->string_content) > 0) {
 
 		add_line(cur, &input, offset);
 
@@ -857,7 +857,7 @@ S_process_line(cmark_parser *parser, const unsigned char *buffer, size_t bytes)
 
 		parser->current = container;
 	}
-	strbuf_clear(parser->curline);
+	cmark_strbuf_clear(parser->curline);
 
 }
 
@@ -866,11 +866,11 @@ cmark_node *cmark_parser_finish(cmark_parser *parser)
 	if (parser->linebuf->size) {
 		S_process_line(parser, parser->linebuf->ptr,
 			     parser->linebuf->size);
-		strbuf_clear(parser->linebuf);
+		cmark_strbuf_clear(parser->linebuf);
 	}
 
 	finalize_document(parser);
-	strbuf_free(parser->curline);
+	cmark_strbuf_free(parser->curline);
 #if CMARK_DEBUG_NODES
 	if (cmark_node_check(parser->root, stderr)) {
 		abort();
diff --git a/src/buffer.c b/src/buffer.c
@@ -8,36 +8,36 @@
 
 #include "buffer.h"
 
-/* Used as default value for strbuf->ptr so that people can always
- * assume ptr is non-NULL and zero terminated even for new strbufs.
+/* Used as default value for cmark_strbuf->ptr so that people can always
+ * assume ptr is non-NULL and zero terminated even for new cmark_strbufs.
  */
-unsigned char strbuf__initbuf[1];
-unsigned char strbuf__oom[1];
+unsigned char cmark_strbuf__initbuf[1];
+unsigned char cmark_strbuf__oom[1];
 
 #define ENSURE_SIZE(b, d)					\
-	if ((d) > buf->asize && strbuf_grow(b, (d)) < 0)	\
+	if ((d) > buf->asize && cmark_strbuf_grow(b, (d)) < 0)	\
 		return -1;
 
 #ifndef MIN
 #define MIN(x,y)  ((x<y) ? x : y)
 #endif
 
-void strbuf_init(strbuf *buf, int initial_size)
+void cmark_strbuf_init(cmark_strbuf *buf, int initial_size)
 {
 	buf->asize = 0;
 	buf->size = 0;
-	buf->ptr = strbuf__initbuf;
+	buf->ptr = cmark_strbuf__initbuf;
 
 	if (initial_size)
-		strbuf_grow(buf, initial_size);
+		cmark_strbuf_grow(buf, initial_size);
 }
 
-int strbuf_try_grow(strbuf *buf, int target_size, bool mark_oom)
+int cmark_strbuf_try_grow(cmark_strbuf *buf, int target_size, bool mark_oom)
 {
 	unsigned char *new_ptr;
 	int new_size;
 
-	if (buf->ptr == strbuf__oom)
+	if (buf->ptr == cmark_strbuf__oom)
 		return -1;
 
 	if (target_size <= buf->asize)
@@ -63,7 +63,7 @@ int strbuf_try_grow(strbuf *buf, int target_size, bool mark_oom)
 
 	if (!new_ptr) {
 		if (mark_oom)
-			buf->ptr = strbuf__oom;
+			buf->ptr = cmark_strbuf__oom;
 		return -1;
 	}
 
@@ -78,32 +78,32 @@ int strbuf_try_grow(strbuf *buf, int target_size, bool mark_oom)
 	return 0;
 }
 
-int strbuf_grow(strbuf *buf, int target_size)
+int cmark_strbuf_grow(cmark_strbuf *buf, int target_size)
 {
-	return strbuf_try_grow(buf, target_size, true);
+	return cmark_strbuf_try_grow(buf, target_size, true);
 }
 
-bool strbuf_oom(const strbuf *buf)
+bool cmark_strbuf_oom(const cmark_strbuf *buf)
 {
-	return (buf->ptr == strbuf__oom);
+	return (buf->ptr == cmark_strbuf__oom);
 }
 
-size_t strbuf_len(const strbuf *buf)
+size_t cmark_strbuf_len(const cmark_strbuf *buf)
 {
 	return buf->size;
 }
 
-void strbuf_free(strbuf *buf)
+void cmark_strbuf_free(cmark_strbuf *buf)
 {
 	if (!buf) return;
 
-	if (buf->ptr != strbuf__initbuf && buf->ptr != strbuf__oom)
+	if (buf->ptr != cmark_strbuf__initbuf && buf->ptr != cmark_strbuf__oom)
 		free(buf->ptr);
 
-	strbuf_init(buf, 0);
+	cmark_strbuf_init(buf, 0);
 }
 
-void strbuf_clear(strbuf *buf)
+void cmark_strbuf_clear(cmark_strbuf *buf)
 {
 	buf->size = 0;
 
@@ -111,10 +111,10 @@ void strbuf_clear(strbuf *buf)
 		buf->ptr[0] = '\0';
 }
 
-int strbuf_set(strbuf *buf, const unsigned char *data, int len)
+int cmark_strbuf_set(cmark_strbuf *buf, const unsigned char *data, int len)
 {
 	if (len <= 0 || data == NULL) {
-		strbuf_clear(buf);
+		cmark_strbuf_clear(buf);
 	} else {
 		if (data != buf->ptr) {
 			ENSURE_SIZE(buf, len + 1);
@@ -126,14 +126,14 @@ int strbuf_set(strbuf *buf, const unsigned char *data, int len)
 	return 0;
 }
 
-int strbuf_sets(strbuf *buf, const char *string)
+int cmark_strbuf_sets(cmark_strbuf *buf, const char *string)
 {
-	return strbuf_set(buf,
+	return cmark_strbuf_set(buf,
 			  (const unsigned char *)string,
 			  string ? strlen(string) : 0);
 }
 
-int strbuf_putc(strbuf *buf, int c)
+int cmark_strbuf_putc(cmark_strbuf *buf, int c)
 {
 	ENSURE_SIZE(buf, buf->size + 2);
 	buf->ptr[buf->size++] = c;
@@ -141,7 +141,7 @@ int strbuf_putc(strbuf *buf, int c)
 	return 0;
 }
 
-int strbuf_put(strbuf *buf, const unsigned char *data, int len)
+int cmark_strbuf_put(cmark_strbuf *buf, const unsigned char *data, int len)
 {
 	if (len <= 0)
 		return 0;
@@ -153,12 +153,12 @@ int strbuf_put(strbuf *buf, const unsigned char *data, int len)
 	return 0;
 }
 
-int strbuf_puts(strbuf *buf, const char *string)
+int cmark_strbuf_puts(cmark_strbuf *buf, const char *string)
 {
-	return strbuf_put(buf, (const unsigned char *)string, strlen(string));
+	return cmark_strbuf_put(buf, (const unsigned char *)string, strlen(string));
 }
 
-int strbuf_vprintf(strbuf *buf, const char *format, va_list ap)
+int cmark_strbuf_vprintf(cmark_strbuf *buf, const char *format, va_list ap)
 {
 	const int expected_size = buf->size + (strlen(format) * 2);
 	int len;
@@ -174,7 +174,7 @@ int strbuf_vprintf(strbuf *buf, const char *format, va_list ap)
 
 		if (len < 0) {
 			free(buf->ptr);
-			buf->ptr = strbuf__oom;
+			buf->ptr = cmark_strbuf__oom;
 			return -1;
 		}
 
@@ -189,19 +189,19 @@ int strbuf_vprintf(strbuf *buf, const char *format, va_list ap)
 	return 0;
 }
 
-int strbuf_printf(strbuf *buf, const char *format, ...)
+int cmark_strbuf_printf(cmark_strbuf *buf, const char *format, ...)
 {
 	int r;
 	va_list ap;
 
 	va_start(ap, format);
-	r = strbuf_vprintf(buf, format, ap);
+	r = cmark_strbuf_vprintf(buf, format, ap);
 	va_end(ap);
 
 	return r;
 }
 
-void strbuf_copy_cstr(char *data, int datasize, const strbuf *buf)
+void cmark_strbuf_copy_cstr(char *data, int datasize, const cmark_strbuf *buf)
 {
 	int copylen;
 
@@ -219,29 +219,29 @@ void strbuf_copy_cstr(char *data, int datasize, const strbuf *buf)
 	data[copylen] = '\0';
 }
 
-void strbuf_swap(strbuf *buf_a, strbuf *buf_b)
+void cmark_strbuf_swap(cmark_strbuf *buf_a, cmark_strbuf *buf_b)
 {
-	strbuf t = *buf_a;
+	cmark_strbuf t = *buf_a;
 	*buf_a = *buf_b;
 	*buf_b = t;
 }
 
-unsigned char *strbuf_detach(strbuf *buf)
+unsigned char *cmark_strbuf_detach(cmark_strbuf *buf)
 {
 	unsigned char *data = buf->ptr;
 
-	if (buf->asize == 0 || buf->ptr == strbuf__oom) {
+	if (buf->asize == 0 || buf->ptr == cmark_strbuf__oom) {
 		/* return an empty string */
 		return (unsigned char *)calloc(1, 1);
 	}
 
-	strbuf_init(buf, 0);
+	cmark_strbuf_init(buf, 0);
 	return data;
 }
 
-void strbuf_attach(strbuf *buf, unsigned char *ptr, int asize)
+void cmark_strbuf_attach(cmark_strbuf *buf, unsigned char *ptr, int asize)
 {
-	strbuf_free(buf);
+	cmark_strbuf_free(buf);
 
 	if (ptr) {
 		buf->ptr = ptr;
@@ -251,18 +251,18 @@ void strbuf_attach(strbuf *buf, unsigned char *ptr, int asize)
 		else /* pass 0 to fall back on strlen + 1 */
 			buf->asize = buf->size + 1;
 	} else {
-		strbuf_grow(buf, asize);
+		cmark_strbuf_grow(buf, asize);
 	}
 }
 
-int strbuf_cmp(const strbuf *a, const strbuf *b)
+int cmark_strbuf_cmp(const cmark_strbuf *a, const cmark_strbuf *b)
 {
 	int result = memcmp(a->ptr, b->ptr, MIN(a->size, b->size));
 	return (result != 0) ? result :
 		(a->size < b->size) ? -1 : (a->size > b->size) ? 1 : 0;
 }
 
-int strbuf_strchr(const strbuf *buf, int c, int pos)
+int cmark_strbuf_strchr(const cmark_strbuf *buf, int c, int pos)
 {
 	const unsigned char *p = (unsigned char *)memchr(buf->ptr + pos, c, buf->size - pos);
 	if (!p)
@@ -271,7 +271,7 @@ int strbuf_strchr(const strbuf *buf, int c, int pos)
 	return (int)(p - (const unsigned char *)buf->ptr);
 }
 
-int strbuf_strrchr(const strbuf *buf, int c, int pos)
+int cmark_strbuf_strrchr(const cmark_strbuf *buf, int c, int pos)
 {
 	int i;
 
@@ -283,7 +283,7 @@ int strbuf_strrchr(const strbuf *buf, int c, int pos)
 	return -1;
 }
 
-void strbuf_truncate(strbuf *buf, int len)
+void cmark_strbuf_truncate(cmark_strbuf *buf, int len)
 {
 	if (len < buf->size) {
 		buf->size = len;
@@ -291,7 +291,7 @@ void strbuf_truncate(strbuf *buf, int len)
 	}
 }
 
-void strbuf_drop(strbuf *buf, int n)
+void cmark_strbuf_drop(cmark_strbuf *buf, int n)
 {
 	if (n > 0) {
 		buf->size = buf->size - n;
@@ -302,7 +302,7 @@ void strbuf_drop(strbuf *buf, int n)
 	}
 }
 
-void strbuf_rtrim(strbuf *buf)
+void cmark_strbuf_rtrim(cmark_strbuf *buf)
 {
 	if (!buf->size)
 		return;
@@ -317,7 +317,7 @@ void strbuf_rtrim(strbuf *buf)
 	buf->ptr[buf->size] = '\0';
 }
 
-void strbuf_trim(strbuf *buf)
+void cmark_strbuf_trim(cmark_strbuf *buf)
 {
 	int i = 0;
 
@@ -327,14 +327,14 @@ void strbuf_trim(strbuf *buf)
 	while (i < buf->size && isspace(buf->ptr[i]))
 		i++;
 
-	strbuf_drop(buf, i);
+	cmark_strbuf_drop(buf, i);
 
-	strbuf_rtrim(buf);
+	cmark_strbuf_rtrim(buf);
 }
 
 // Destructively modify string, collapsing consecutive
 // space and newline characters into a single space.
-void strbuf_normalize_whitespace(strbuf *s)
+void cmark_strbuf_normalize_whitespace(cmark_strbuf *s)
 {
 	bool last_char_was_space = false;
 	int r, w;
@@ -356,11 +356,11 @@ void strbuf_normalize_whitespace(strbuf *s)
 		}
 	}
 
-	strbuf_truncate(s, w);
+	cmark_strbuf_truncate(s, w);
 }
 
 // Destructively unescape a string: remove backslashes before punctuation chars.
-extern void strbuf_unescape(strbuf *buf)
+extern void cmark_strbuf_unescape(cmark_strbuf *buf)
 {
 	int r, w;
 
@@ -371,5 +371,5 @@ extern void strbuf_unescape(strbuf *buf)
 		buf->ptr[w++] = buf->ptr[r];
 	}
 
-	strbuf_truncate(buf, w);
+	cmark_strbuf_truncate(buf, w);
 }
diff --git a/src/buffer.h b/src/buffer.h
@@ -12,21 +12,21 @@ extern "C" {
 typedef struct {
 	unsigned char *ptr;
 	int asize, size;
-} strbuf;
+} cmark_strbuf;
 
-extern unsigned char strbuf__initbuf[];
+extern unsigned char cmark_strbuf__initbuf[];
 
-extern unsigned char strbuf__oom[];
+extern unsigned char cmark_strbuf__oom[];
 
-#define GH_BUF_INIT { strbuf__initbuf, 0, 0 }
+#define GH_BUF_INIT { cmark_strbuf__initbuf, 0, 0 }
 
 /**
- * Initialize a strbuf structure.
+ * Initialize a cmark_strbuf structure.
  *
  * For the cases where GH_BUF_INIT cannot be used to do static
  * initialization.
  */
-void strbuf_init(strbuf *buf, int initial_size);
+void cmark_strbuf_init(cmark_strbuf *buf, int initial_size);
 
 /**
  * Attempt to grow the buffer to hold at least `target_size` bytes.
@@ -36,7 +36,7 @@ void strbuf_init(strbuf *buf, int initial_size);
  * existing buffer content will be preserved, but calling code must handle
  * that buffer was not expanded.
  */
-int strbuf_try_grow(strbuf *buf, int target_size, bool mark_oom);
+int cmark_strbuf_try_grow(cmark_strbuf *buf, int target_size, bool mark_oom);
 
 /**
  * Grow the buffer to hold at least `target_size` bytes.
@@ -46,65 +46,65 @@ int strbuf_try_grow(strbuf *buf, int target_size, bool mark_oom);
  *
  * @return 0 on success or -1 on failure
  */
-int strbuf_grow(strbuf *buf, int target_size);
+int cmark_strbuf_grow(cmark_strbuf *buf, int target_size);
 
-void strbuf_free(strbuf *buf);
-void strbuf_swap(strbuf *buf_a, strbuf *buf_b);
+void cmark_strbuf_free(cmark_strbuf *buf);
+void cmark_strbuf_swap(cmark_strbuf *buf_a, cmark_strbuf *buf_b);
 
 /**
- * Test if there have been any reallocation failures with this strbuf.
+ * Test if there have been any reallocation failures with this cmark_strbuf.
  *
- * Any function that writes to a strbuf can fail due to memory allocation
- * issues.  If one fails, the strbuf will be marked with an OOM error and
- * further calls to modify the buffer will fail.  Check strbuf_oom() at the
+ * Any function that writes to a cmark_strbuf can fail due to memory allocation
+ * issues.  If one fails, the cmark_strbuf will be marked with an OOM error and
+ * further calls to modify the buffer will fail.  Check cmark_strbuf_oom() at the
  * end of your sequence and it will be true if you ran out of memory at any
  * point with that buffer.
  *
  * @return false if no error, true if allocation error
  */
-bool strbuf_oom(const strbuf *buf);
+bool cmark_strbuf_oom(const cmark_strbuf *buf);
 
-size_t strbuf_len(const strbuf *buf);
+size_t cmark_strbuf_len(const cmark_strbuf *buf);
 
-int strbuf_cmp(const strbuf *a, const strbuf *b);
+int cmark_strbuf_cmp(const cmark_strbuf *a, const cmark_strbuf *b);
 
-void strbuf_attach(strbuf *buf, unsigned char *ptr, int asize);
-unsigned char *strbuf_detach(strbuf *buf);
-void strbuf_copy_cstr(char *data, int datasize, const strbuf *buf);
+void cmark_strbuf_attach(cmark_strbuf *buf, unsigned char *ptr, int asize);
+unsigned char *cmark_strbuf_detach(cmark_strbuf *buf);
+void cmark_strbuf_copy_cstr(char *data, int datasize, const cmark_strbuf *buf);
 
-static inline const char *strbuf_cstr(const strbuf *buf)
+static inline const char *cmark_strbuf_cstr(const cmark_strbuf *buf)
 {
 	return (char *)buf->ptr;
 }
 
-#define strbuf_at(buf, n) ((buf)->ptr[n])
+#define cmark_strbuf_at(buf, n) ((buf)->ptr[n])
 
 /*
  * Functions below that return int value error codes will return 0 on
  * success or -1 on failure (which generally means an allocation failed).
- * Using a strbuf where the allocation has failed with result in -1 from
+ * Using a cmark_strbuf where the allocation has failed with result in -1 from
  * all further calls using that buffer.  As a result, you can ignore the
  * return code of these functions and call them in a series then just call
- * strbuf_oom at the end.
+ * cmark_strbuf_oom at the end.
  */
-int strbuf_set(strbuf *buf, const unsigned char *data, int len);
-int strbuf_sets(strbuf *buf, const char *string);
-int strbuf_putc(strbuf *buf, int c);
-int strbuf_put(strbuf *buf, const unsigned char *data, int len);
-int strbuf_puts(strbuf *buf, const char *string);
-int strbuf_printf(strbuf *buf, const char *format, ...)
+int cmark_strbuf_set(cmark_strbuf *buf, const unsigned char *data, int len);
+int cmark_strbuf_sets(cmark_strbuf *buf, const char *string);
+int cmark_strbuf_putc(cmark_strbuf *buf, int c);
+int cmark_strbuf_put(cmark_strbuf *buf, const unsigned char *data, int len);
+int cmark_strbuf_puts(cmark_strbuf *buf, const char *string);
+int cmark_strbuf_printf(cmark_strbuf *buf, const char *format, ...)
 	CMARK_ATTRIBUTE((format (printf, 2, 3)));
-int strbuf_vprintf(strbuf *buf, const char *format, va_list ap);
-void strbuf_clear(strbuf *buf);
-
-int strbuf_strchr(const strbuf *buf, int c, int pos);
-int strbuf_strrchr(const strbuf *buf, int c, int pos);
-void strbuf_drop(strbuf *buf, int n);
-void strbuf_truncate(strbuf *buf, int len);
-void strbuf_rtrim(strbuf *buf);
-void strbuf_trim(strbuf *buf);
-void strbuf_normalize_whitespace(strbuf *s);
-void strbuf_unescape(strbuf *s);
+int cmark_strbuf_vprintf(cmark_strbuf *buf, const char *format, va_list ap);
+void cmark_strbuf_clear(cmark_strbuf *buf);
+
+int cmark_strbuf_strchr(const cmark_strbuf *buf, int c, int pos);
+int cmark_strbuf_strrchr(const cmark_strbuf *buf, int c, int pos);
+void cmark_strbuf_drop(cmark_strbuf *buf, int n);
+void cmark_strbuf_truncate(cmark_strbuf *buf, int len);
+void cmark_strbuf_rtrim(cmark_strbuf *buf);
+void cmark_strbuf_trim(cmark_strbuf *buf);
+void cmark_strbuf_normalize_whitespace(cmark_strbuf *s);
+void cmark_strbuf_unescape(cmark_strbuf *s);
 
 #ifdef __cplusplus
 }
diff --git a/src/chunk.h b/src/chunk.h
@@ -11,9 +11,9 @@ typedef struct {
 	unsigned char *data;
 	int len;
 	int alloc;  // also implies a NULL-terminated string
-} chunk;
+} cmark_chunk;
 
-static inline void chunk_free(chunk *c)
+static inline void cmark_chunk_free(cmark_chunk *c)
 {
 	if (c->alloc)
 		free(c->data);
@@ -23,7 +23,7 @@ static inline void chunk_free(chunk *c)
 	c->len = 0;
 }
 
-static inline void chunk_ltrim(chunk *c)
+static inline void cmark_chunk_ltrim(cmark_chunk *c)
 {
 	assert(!c->alloc);
 
@@ -33,7 +33,7 @@ static inline void chunk_ltrim(chunk *c)
 	}
 }
 
-static inline void chunk_rtrim(chunk *c)
+static inline void cmark_chunk_rtrim(cmark_chunk *c)
 {
 	while (c->len > 0) {
 		if (!isspace(c->data[c->len - 1]))
@@ -43,19 +43,19 @@ static inline void chunk_rtrim(chunk *c)
 	}
 }
 
-static inline void chunk_trim(chunk *c)
+static inline void cmark_chunk_trim(cmark_chunk *c)
 {
-	chunk_ltrim(c);
-	chunk_rtrim(c);
+	cmark_chunk_ltrim(c);
+	cmark_chunk_rtrim(c);
 }
 
-static inline int chunk_strchr(chunk *ch, int c, int offset)
+static inline int cmark_chunk_strchr(cmark_chunk *ch, int c, int offset)
 {
 	const unsigned char *p = (unsigned char *)memchr(ch->data + offset, c, ch->len - offset);
 	return p ? (int)(p - ch->data) : ch->len;
 }
 
-static inline const char *chunk_to_cstr(chunk *c)
+static inline const char *cmark_chunk_to_cstr(cmark_chunk *c)
 {
 	unsigned char *str;
 
@@ -73,7 +73,7 @@ static inline const char *chunk_to_cstr(chunk *c)
 	return (char *)str;
 }
 
-static inline void chunk_set_cstr(chunk *c, const char *str)
+static inline void cmark_chunk_set_cstr(cmark_chunk *c, const char *str)
 {
 	if (c->alloc) {
 		free(c->data);
@@ -84,24 +84,24 @@ static inline void chunk_set_cstr(chunk *c, const char *str)
 	memcpy(c->data, str, c->len + 1);
 }
 
-static inline chunk chunk_literal(const char *data)
+static inline cmark_chunk cmark_chunk_literal(const char *data)
 {
-	chunk c = {(unsigned char *)data, data ? strlen(data) : 0, 0};
+	cmark_chunk c = {(unsigned char *)data, data ? strlen(data) : 0, 0};
 	return c;
 }
 
-static inline chunk chunk_dup(const chunk *ch, int pos, int len)
+static inline cmark_chunk cmark_chunk_dup(const cmark_chunk *ch, int pos, int len)
 {
-	chunk c = {ch->data + pos, len, 0};
+	cmark_chunk c = {ch->data + pos, len, 0};
 	return c;
 }
 
-static inline chunk chunk_buf_detach(strbuf *buf)
+static inline cmark_chunk cmark_chunk_buf_detach(cmark_strbuf *buf)
 {
-	chunk c;
+	cmark_chunk c;
 
 	c.len = buf->size;
-	c.data = strbuf_detach(buf);
+	c.data = cmark_strbuf_detach(buf);
 	c.alloc = 1;
 
 	return c;
diff --git a/src/houdini.h b/src/houdini.h
@@ -31,19 +31,19 @@ extern "C" {
 #define HOUDINI_ESCAPED_SIZE(x) (((x) * 12) / 10)
 #define HOUDINI_UNESCAPED_SIZE(x) (x)
 
-extern size_t houdini_unescape_ent(strbuf *ob, const uint8_t *src, size_t size);
-extern int houdini_escape_html(strbuf *ob, const uint8_t *src, size_t size);
-extern int houdini_escape_html0(strbuf *ob, const uint8_t *src, size_t size, int secure);
-extern int houdini_unescape_html(strbuf *ob, const uint8_t *src, size_t size);
-extern void houdini_unescape_html_f(strbuf *ob, const uint8_t *src, size_t size);
-extern int houdini_escape_xml(strbuf *ob, const uint8_t *src, size_t size);
-extern int houdini_escape_uri(strbuf *ob, const uint8_t *src, size_t size);
-extern int houdini_escape_url(strbuf *ob, const uint8_t *src, size_t size);
-extern int houdini_escape_href(strbuf *ob, const uint8_t *src, size_t size);
-extern int houdini_unescape_uri(strbuf *ob, const uint8_t *src, size_t size);
-extern int houdini_unescape_url(strbuf *ob, const uint8_t *src, size_t size);
-extern int houdini_escape_js(strbuf *ob, const uint8_t *src, size_t size);
-extern int houdini_unescape_js(strbuf *ob, const uint8_t *src, size_t size);
+extern size_t houdini_unescape_ent(cmark_strbuf *ob, const uint8_t *src, size_t size);
+extern int houdini_escape_html(cmark_strbuf *ob, const uint8_t *src, size_t size);
+extern int houdini_escape_html0(cmark_strbuf *ob, const uint8_t *src, size_t size, int secure);
+extern int houdini_unescape_html(cmark_strbuf *ob, const uint8_t *src, size_t size);
+extern void houdini_unescape_html_f(cmark_strbuf *ob, const uint8_t *src, size_t size);
+extern int houdini_escape_xml(cmark_strbuf *ob, const uint8_t *src, size_t size);
+extern int houdini_escape_uri(cmark_strbuf *ob, const uint8_t *src, size_t size);
+extern int houdini_escape_url(cmark_strbuf *ob, const uint8_t *src, size_t size);
+extern int houdini_escape_href(cmark_strbuf *ob, const uint8_t *src, size_t size);
+extern int houdini_unescape_uri(cmark_strbuf *ob, const uint8_t *src, size_t size);
+extern int houdini_unescape_url(cmark_strbuf *ob, const uint8_t *src, size_t size);
+extern int houdini_escape_js(cmark_strbuf *ob, const uint8_t *src, size_t size);
+extern int houdini_unescape_js(cmark_strbuf *ob, const uint8_t *src, size_t size);
 
 #ifdef __cplusplus
 }
diff --git a/src/houdini_href_e.c b/src/houdini_href_e.c
@@ -49,7 +49,7 @@ static const char HREF_SAFE[] = {
 };
 
 int
-houdini_escape_href(strbuf *ob, const uint8_t *src, size_t size)
+houdini_escape_href(cmark_strbuf *ob, const uint8_t *src, size_t size)
 {
 	static const uint8_t hex_chars[] = "0123456789ABCDEF";
 	size_t  i = 0, org;
@@ -63,7 +63,7 @@ houdini_escape_href(strbuf *ob, const uint8_t *src, size_t size)
 			i++;
 
 		if (likely(i > org))
-			strbuf_put(ob, src + org, i - org);
+			cmark_strbuf_put(ob, src + org, i - org);
 
 		/* escaping */
 		if (i >= size)
@@ -73,14 +73,14 @@ houdini_escape_href(strbuf *ob, const uint8_t *src, size_t size)
 		/* amp appears all the time in URLs, but needs
 		 * HTML-entity escaping to be inside an href */
 		case '&':
-			strbuf_puts(ob, "&amp;");
+			cmark_strbuf_puts(ob, "&amp;");
 			break;
 
 		/* the single quote is a valid URL character
 		 * according to the standard; it needs HTML
 		 * entity escaping too */
 		case '\'':
-			strbuf_puts(ob, "&#x27;");
+			cmark_strbuf_puts(ob, "&#x27;");
 			break;
 
 		/* the space can be escaped to %20 or a plus
@@ -89,7 +89,7 @@ houdini_escape_href(strbuf *ob, const uint8_t *src, size_t size)
 		 * when building GET strings */
 #if 0
 		case ' ':
-			strbuf_putc(ob, '+');
+			cmark_strbuf_putc(ob, '+');
 			break;
 #endif
 
@@ -97,7 +97,7 @@ houdini_escape_href(strbuf *ob, const uint8_t *src, size_t size)
 		default:
 			hex_str[1] = hex_chars[(src[i] >> 4) & 0xF];
 			hex_str[2] = hex_chars[src[i] & 0xF];
-			strbuf_put(ob, hex_str, 3);
+			cmark_strbuf_put(ob, hex_str, 3);
 		}
 
 		i++;
diff --git a/src/houdini_html_e.c b/src/houdini_html_e.c
@@ -45,7 +45,7 @@ static const char *HTML_ESCAPES[] = {
 };
 
 int
-houdini_escape_html0(strbuf *ob, const uint8_t *src, size_t size, int secure)
+houdini_escape_html0(cmark_strbuf *ob, const uint8_t *src, size_t size, int secure)
 {
 	size_t  i = 0, org, esc = 0;
 
@@ -55,7 +55,7 @@ houdini_escape_html0(strbuf *ob, const uint8_t *src, size_t size, int secure)
 			i++;
 
 		if (i > org)
-			strbuf_put(ob, src + org, i - org);
+			cmark_strbuf_put(ob, src + org, i - org);
 
 		/* escaping */
 		if (unlikely(i >= size))
@@ -63,9 +63,9 @@ houdini_escape_html0(strbuf *ob, const uint8_t *src, size_t size, int secure)
 
 		/* The forward slash is only escaped in secure mode */
 		if ((src[i] == '/' || src[i] == '\'') && !secure) {
-			strbuf_putc(ob, src[i]);
+			cmark_strbuf_putc(ob, src[i]);
 		} else {
-			strbuf_puts(ob, HTML_ESCAPES[esc]);
+			cmark_strbuf_puts(ob, HTML_ESCAPES[esc]);
 		}
 
 		i++;
@@ -75,7 +75,7 @@ houdini_escape_html0(strbuf *ob, const uint8_t *src, size_t size, int secure)
 }
 
 int
-houdini_escape_html(strbuf *ob, const uint8_t *src, size_t size)
+houdini_escape_html(cmark_strbuf *ob, const uint8_t *src, size_t size)
 {
 	return houdini_escape_html0(ob, src, size, 1);
 }
diff --git a/src/houdini_html_u.c b/src/houdini_html_u.c
@@ -8,7 +8,7 @@
 #include "html_unescape.h"
 
 size_t
-houdini_unescape_ent(strbuf *ob, const uint8_t *src, size_t size)
+houdini_unescape_ent(cmark_strbuf *ob, const uint8_t *src, size_t size)
 {
 	size_t i = 0;
 
@@ -55,7 +55,7 @@ houdini_unescape_ent(strbuf *ob, const uint8_t *src, size_t size)
 				const struct html_ent *entity = find_entity((char *)src, i);
 
 				if (entity != NULL) {
-					strbuf_put(ob, entity->utf8, entity->utf8_len);
+					cmark_strbuf_put(ob, entity->utf8, entity->utf8_len);
 					return i + 1;
 				}
 
@@ -68,7 +68,7 @@ houdini_unescape_ent(strbuf *ob, const uint8_t *src, size_t size)
 }
 
 int
-houdini_unescape_html(strbuf *ob, const uint8_t *src, size_t size)
+houdini_unescape_html(cmark_strbuf *ob, const uint8_t *src, size_t size)
 {
 	size_t  i = 0, org, ent;
 
@@ -82,10 +82,10 @@ houdini_unescape_html(strbuf *ob, const uint8_t *src, size_t size)
 				if (i >= size)
 					return 0;
 
-				strbuf_grow(ob, HOUDINI_UNESCAPED_SIZE(size));
+				cmark_strbuf_grow(ob, HOUDINI_UNESCAPED_SIZE(size));
 			}
 
-			strbuf_put(ob, src + org, i - org);
+			cmark_strbuf_put(ob, src + org, i - org);
 		}
 
 		/* escaping */
@@ -99,14 +99,14 @@ houdini_unescape_html(strbuf *ob, const uint8_t *src, size_t size)
 
 		/* not really an entity */
 		if (ent == 0)
-			strbuf_putc(ob, '&');
+			cmark_strbuf_putc(ob, '&');
 	}
 
 	return 1;
 }
 
-void houdini_unescape_html_f(strbuf *ob, const uint8_t *src, size_t size)
+void houdini_unescape_html_f(cmark_strbuf *ob, const uint8_t *src, size_t size)
 {
 	if (!houdini_unescape_html(ob, src, size))
-		strbuf_put(ob, src, size);
+		cmark_strbuf_put(ob, src, size);
 }
diff --git a/src/html.c b/src/html.c
@@ -11,7 +11,7 @@
 
 // Functions to convert cmark_nodes to HTML strings.
 
-static void escape_html(strbuf *dest, const unsigned char *source, int length)
+static void escape_html(cmark_strbuf *dest, const unsigned char *source, int length)
 {
 	if (length < 0)
 		length = strlen((char *)source);
@@ -19,7 +19,7 @@ static void escape_html(strbuf *dest, const unsigned char *source, int length)
 	houdini_escape_html0(dest, source, (size_t)length, 0);
 }
 
-static void escape_href(strbuf *dest, const unsigned char *source, int length)
+static void escape_href(cmark_strbuf *dest, const unsigned char *source, int length)
 {
 	if (length < 0)
 		length = strlen((char *)source);
@@ -27,14 +27,14 @@ static void escape_href(strbuf *dest, const unsigned char *source, int length)
 	houdini_escape_href(dest, source, (size_t)length);
 }
 
-static inline void cr(strbuf *html)
+static inline void cr(cmark_strbuf *html)
 {
 	if (html->size && html->ptr[html->size - 1] != '\n')
-		strbuf_putc(html, '\n');
+		cmark_strbuf_putc(html, '\n');
 }
 
 struct render_state {
-	strbuf* html;
+	cmark_strbuf* html;
 	cmark_node *plain;
 };
 
@@ -44,7 +44,7 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 	struct render_state *state = vstate;
 	cmark_node *parent;
 	cmark_node *grandparent;
-	strbuf *html = state->html;
+	cmark_strbuf *html = state->html;
 	char start_header[] = "<h0>";
 	char end_header[] = "</h0>";
 	bool tight;
@@ -66,7 +66,7 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 
 		case CMARK_NODE_LINEBREAK:
 		case CMARK_NODE_SOFTBREAK:
-			strbuf_putc(html, ' ');
+			cmark_strbuf_putc(html, ' ');
 			break;
 
 		default:
@@ -82,10 +82,10 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 	case CMARK_NODE_BLOCK_QUOTE:
 		if (entering) {
 			cr(html);
-			strbuf_puts(html, "<blockquote>\n");
+			cmark_strbuf_puts(html, "<blockquote>\n");
 		} else {
 			cr(html);
-			strbuf_puts(html, "</blockquote>\n");
+			cmark_strbuf_puts(html, "</blockquote>\n");
 		}
 		break;
 
@@ -96,17 +96,17 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 		if (entering) {
 			cr(html);
 			if (list_type == CMARK_BULLET_LIST) {
-				strbuf_puts(html, "<ul>\n");
+				cmark_strbuf_puts(html, "<ul>\n");
 			}
 			else if (start == 1) {
-				strbuf_puts(html, "<ol>\n");
+				cmark_strbuf_puts(html, "<ol>\n");
 			}
 			else {
-				strbuf_printf(html, "<ol start=\"%d\">\n",
+				cmark_strbuf_printf(html, "<ol start=\"%d\">\n",
 					      start);
 			}
 		} else {
-			strbuf_puts(html,
+			cmark_strbuf_puts(html,
 				    list_type == CMARK_BULLET_LIST ?
 				    "</ul>\n" : "</ol>\n");
 		}
@@ -116,9 +116,9 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 	case CMARK_NODE_LIST_ITEM:
 		if (entering) {
 			cr(html);
-			strbuf_puts(html, "<li>");
+			cmark_strbuf_puts(html, "<li>");
 		} else {
-			strbuf_puts(html, "</li>\n");
+			cmark_strbuf_puts(html, "</li>\n");
 		}
 		break;
 
@@ -126,11 +126,11 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 		if (entering) {
 			cr(html);
 			start_header[2] = '0' + node->as.header.level;
-			strbuf_puts(html, start_header);
+			cmark_strbuf_puts(html, start_header);
 		} else {
 			end_header[3] = '0' + node->as.header.level;
-			strbuf_puts(html, end_header);
-			strbuf_putc(html, '\n');
+			cmark_strbuf_puts(html, end_header);
+			cmark_strbuf_putc(html, '\n');
 		}
 		break;
 
@@ -139,7 +139,7 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 
 		if (&node->as.code.fence_length == 0
 		    || node->as.code.info.len == 0) {
-			strbuf_puts(html, "<pre><code>");
+			cmark_strbuf_puts(html, "<pre><code>");
 		}
 		else {
 			int first_tag = 0;
@@ -148,23 +148,23 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 				first_tag += 1;
 			}
 
-			strbuf_puts(html, "<pre><code class=\"language-");
+			cmark_strbuf_puts(html, "<pre><code class=\"language-");
 			escape_html(html, node->as.code.info.data, first_tag);
-			strbuf_puts(html, "\">");
+			cmark_strbuf_puts(html, "\">");
 		}
 
 		escape_html(html, node->as.literal.data, node->as.literal.len);
-		strbuf_puts(html, "</code></pre>\n");
+		cmark_strbuf_puts(html, "</code></pre>\n");
 		break;
 
 	case CMARK_NODE_HTML:
 		cr(html);
-		strbuf_put(html, node->as.literal.data, node->as.literal.len);
+		cmark_strbuf_put(html, node->as.literal.data, node->as.literal.len);
 		break;
 
 	case CMARK_NODE_HRULE:
 		cr(html);
-		strbuf_puts(html, "<hr />\n");
+		cmark_strbuf_puts(html, "<hr />\n");
 		break;
 
 	case CMARK_NODE_PARAGRAPH:
@@ -179,9 +179,9 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 		if (!tight) {
 			if (entering) {
 				cr(html);
-				strbuf_puts(html, "<p>");
+				cmark_strbuf_puts(html, "<p>");
 			} else {
-				strbuf_puts(html, "</p>\n");
+				cmark_strbuf_puts(html, "</p>\n");
 			}
 		}
 		break;
@@ -192,71 +192,71 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 		break;
 
 	case CMARK_NODE_LINEBREAK:
-		strbuf_puts(html, "<br />\n");
+		cmark_strbuf_puts(html, "<br />\n");
 		break;
 
 	case CMARK_NODE_SOFTBREAK:
-		strbuf_putc(html, '\n');
+		cmark_strbuf_putc(html, '\n');
 		break;
 
 	case CMARK_NODE_CODE:
-		strbuf_puts(html, "<code>");
+		cmark_strbuf_puts(html, "<code>");
 		escape_html(html, node->as.literal.data, node->as.literal.len);
-		strbuf_puts(html, "</code>");
+		cmark_strbuf_puts(html, "</code>");
 		break;
 
 	case CMARK_NODE_INLINE_HTML:
-		strbuf_put(html, node->as.literal.data, node->as.literal.len);
+		cmark_strbuf_put(html, node->as.literal.data, node->as.literal.len);
 		break;
 
 	case CMARK_NODE_STRONG:
 		if (entering) {
-			strbuf_puts(html, "<strong>");
+			cmark_strbuf_puts(html, "<strong>");
 		} else {
-			strbuf_puts(html, "</strong>");
+			cmark_strbuf_puts(html, "</strong>");
 		}
 		break;
 
 	case CMARK_NODE_EMPH:
 		if (entering) {
-			strbuf_puts(html, "<em>");
+			cmark_strbuf_puts(html, "<em>");
 		} else {
-			strbuf_puts(html, "</em>");
+			cmark_strbuf_puts(html, "</em>");
 		}
 		break;
 
 	case CMARK_NODE_LINK:
 		if (entering) {
-			strbuf_puts(html, "<a href=\"");
+			cmark_strbuf_puts(html, "<a href=\"");
 			if (node->as.link.url)
 				escape_href(html, node->as.link.url, -1);
 
 			if (node->as.link.title) {
-				strbuf_puts(html, "\" title=\"");
+				cmark_strbuf_puts(html, "\" title=\"");
 				escape_html(html, node->as.link.title, -1);
 			}
 
-			strbuf_puts(html, "\">");
+			cmark_strbuf_puts(html, "\">");
 		} else {
-			strbuf_puts(html, "</a>");
+			cmark_strbuf_puts(html, "</a>");
 		}
 		break;
 
 	case CMARK_NODE_IMAGE:
 		if (entering) {
-			strbuf_puts(html, "<img src=\"");
+			cmark_strbuf_puts(html, "<img src=\"");
 			if (node->as.link.url)
 				escape_href(html, node->as.link.url, -1);
 
-			strbuf_puts(html, "\" alt=\"");
+			cmark_strbuf_puts(html, "\" alt=\"");
 			state->plain = node;
 		} else {
 			if (node->as.link.title) {
-				strbuf_puts(html, "\" title=\"");
+				cmark_strbuf_puts(html, "\" title=\"");
 				escape_html(html, node->as.link.title, -1);
 			}
 
-			strbuf_puts(html, "\" />");
+			cmark_strbuf_puts(html, "\" />");
 		}
 		break;
 
@@ -265,14 +265,14 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 		break;
 	}
 
-	// strbuf_putc(html, 'x');
+	// cmark_strbuf_putc(html, 'x');
 	return 1;
 }
 
 char *cmark_render_html(cmark_node *root)
 {
 	char *result;
-	strbuf html = GH_BUF_INIT;
+	cmark_strbuf html = GH_BUF_INIT;
 	cmark_event_type ev_type;
 	cmark_node *cur;
 	struct render_state state = { &html, NULL };
@@ -282,9 +282,9 @@ char *cmark_render_html(cmark_node *root)
 		cur = cmark_iter_get_node(iter);
 		S_render_node(cur, ev_type, &state);
 	}
-	result = (char *)strbuf_detach(&html);
+	result = (char *)cmark_strbuf_detach(&html);
 
 	cmark_iter_free(iter);
-	strbuf_free(&html);
+	cmark_strbuf_free(&html);
 	return result;
 }
diff --git a/src/inlines.c b/src/inlines.c
@@ -34,7 +34,7 @@ typedef struct delimiter {
 } delimiter;
 
 typedef struct {
-	chunk input;
+	cmark_chunk input;
 	int pos;
 	cmark_reference_map *refmap;
 	delimiter *last_delim;
@@ -45,24 +45,24 @@ S_insert_emph(subject *subj, delimiter *opener, delimiter *closer);
 
 static int parse_inline(subject* subj, cmark_node * parent);
 
-static void subject_from_buf(subject *e, strbuf *buffer,
+static void subject_from_buf(subject *e, cmark_strbuf *buffer,
 			     cmark_reference_map *refmap);
 static int subject_find_special_char(subject *subj);
 
-static unsigned char *cmark_clean_autolink(chunk *url, int is_email)
+static unsigned char *cmark_clean_autolink(cmark_chunk *url, int is_email)
 {
-	strbuf buf = GH_BUF_INIT;
+	cmark_strbuf buf = GH_BUF_INIT;
 
-	chunk_trim(url);
+	cmark_chunk_trim(url);
 
 	if (url->len == 0)
 		return NULL;
 
 	if (is_email)
-		strbuf_puts(&buf, "mailto:");
+		cmark_strbuf_puts(&buf, "mailto:");
 
 	houdini_unescape_html_f(&buf, url->data, url->len);
-	return strbuf_detach(&buf);
+	return cmark_strbuf_detach(&buf);
 }
 
 static inline cmark_node *make_link(cmark_node *label, unsigned char *url, unsigned char *title)
@@ -80,13 +80,13 @@ static inline cmark_node *make_link(cmark_node *label, unsigned char *url, unsig
 	return e;
 }
 
-static inline cmark_node* make_autolink(cmark_node* label, chunk url, int is_email)
+static inline cmark_node* make_autolink(cmark_node* label, cmark_chunk url, int is_email)
 {
 	return make_link(label, cmark_clean_autolink(&url, is_email), NULL);
 }
 
 // Create an inline with a literal string value.
-static inline cmark_node* make_literal(cmark_node_type t, chunk s)
+static inline cmark_node* make_literal(cmark_node_type t, cmark_chunk s)
 {
 	cmark_node * e = (cmark_node *)calloc(1, sizeof(*e));
 	if(e != NULL) {
@@ -139,7 +139,7 @@ static unsigned char *bufdup(const unsigned char *buf)
 	return new_buf;
 }
 
-static void subject_from_buf(subject *e, strbuf *buffer,
+static void subject_from_buf(subject *e, cmark_strbuf *buffer,
 			     cmark_reference_map *refmap)
 {
 	e->input.data = buffer->ptr;
@@ -149,7 +149,7 @@ static void subject_from_buf(subject *e, strbuf *buffer,
 	e->refmap = refmap;
 	e->last_delim = NULL;
 
-	chunk_rtrim(&e->input);
+	cmark_chunk_rtrim(&e->input);
 }
 
 static inline int isbacktick(int c)
@@ -177,7 +177,7 @@ static inline int is_eof(subject* subj)
 #define advance(subj) (subj)->pos += 1
 
 // Take characters while a predicate holds, and return a string.
-static inline chunk take_while(subject* subj, int (*f)(int))
+static inline cmark_chunk take_while(subject* subj, int (*f)(int))
 {
 	unsigned char c;
 	int startpos = subj->pos;
@@ -188,7 +188,7 @@ static inline chunk take_while(subject* subj, int (*f)(int))
 		len++;
 	}
 
-	return chunk_dup(&subj->input, startpos, len);
+	return cmark_chunk_dup(&subj->input, startpos, len);
 }
 
 // Try to process a backtick code span that began with a
@@ -221,7 +221,7 @@ static int scan_to_closing_backticks(subject* subj, int openticklength)
 // Assumes that the subject has a backtick at the current position.
 static cmark_node* handle_backticks(subject *subj)
 {
-	chunk openticks = take_while(subj, isbacktick);
+	cmark_chunk openticks = take_while(subj, isbacktick);
 	int startpos = subj->pos;
 	int endpos = scan_to_closing_backticks(subj, openticks.len);
 
@@ -229,13 +229,13 @@ static cmark_node* handle_backticks(subject *subj)
 		subj->pos = startpos; // rewind
 		return make_str(openticks);
 	} else {
-		strbuf buf = GH_BUF_INIT;
+		cmark_strbuf buf = GH_BUF_INIT;
 
-		strbuf_set(&buf, subj->input.data + startpos, endpos - startpos - openticks.len);
-		strbuf_trim(&buf);
-		strbuf_normalize_whitespace(&buf);
+		cmark_strbuf_set(&buf, subj->input.data + startpos, endpos - startpos - openticks.len);
+		cmark_strbuf_trim(&buf);
+		cmark_strbuf_normalize_whitespace(&buf);
 
-		return make_code(chunk_buf_detach(&buf));
+		return make_code(cmark_chunk_buf_detach(&buf));
 	}
 }
 
@@ -349,7 +349,7 @@ static cmark_node* handle_strong_emph(subject* subj, unsigned char c)
 
 	numdelims = scan_delims(subj, c, &can_open, &can_close);
 
-	inl_text = make_str(chunk_dup(&subj->input, subj->pos - numdelims, numdelims));
+	inl_text = make_str(cmark_chunk_dup(&subj->input, subj->pos - numdelims, numdelims));
 
 	if (can_open || can_close) {
 		push_delimiter(subj, c, can_open, can_close, inl_text);
@@ -435,7 +435,7 @@ S_insert_emph(subject *subj, delimiter *opener, delimiter *closer)
 	// if opener has 0 characters, remove it and its associated inline
 	if (opener_num_chars == 0) {
 		// replace empty opener inline with emph
-		chunk_free(&(opener_inl->as.literal));
+		cmark_chunk_free(&(opener_inl->as.literal));
 		emph = opener_inl;
 		emph->type = use_delims == 1 ? NODE_EMPH : NODE_STRONG;
 		// remove opener from list
@@ -483,12 +483,12 @@ static cmark_node* handle_backslash(subject *subj)
 	unsigned char nextchar = peek_char(subj);
 	if (ispunct(nextchar)) {  // only ascii symbols and newline can be escaped
 		advance(subj);
-		return make_str(chunk_dup(&subj->input, subj->pos - 1, 1));
+		return make_str(cmark_chunk_dup(&subj->input, subj->pos - 1, 1));
 	} else if (nextchar == '\n') {
 		advance(subj);
 		return make_linebreak();
 	} else {
-		return make_str(chunk_literal("\\"));
+		return make_str(cmark_chunk_literal("\\"));
 	}
 }
 
@@ -496,7 +496,7 @@ static cmark_node* handle_backslash(subject *subj)
 // Assumes the subject has an '&' character at the current position.
 static cmark_node* handle_entity(subject* subj)
 {
-	strbuf ent = GH_BUF_INIT;
+	cmark_strbuf ent = GH_BUF_INIT;
 	size_t len;
 
 	advance(subj);
@@ -507,20 +507,20 @@ static cmark_node* handle_entity(subject* subj)
 				   );
 
 	if (len == 0)
-		return make_str(chunk_literal("&"));
+		return make_str(cmark_chunk_literal("&"));
 
 	subj->pos += len;
-	return make_str(chunk_buf_detach(&ent));
+	return make_str(cmark_chunk_buf_detach(&ent));
 }
 
 // Like make_str, but parses entities.
 // Returns an inline sequence consisting of str and entity elements.
-static cmark_node *make_str_with_entities(chunk *content)
+static cmark_node *make_str_with_entities(cmark_chunk *content)
 {
-	strbuf unescaped = GH_BUF_INIT;
+	cmark_strbuf unescaped = GH_BUF_INIT;
 
 	if (houdini_unescape_html(&unescaped, content->data, (size_t)content->len)) {
-		return make_str(chunk_buf_detach(&unescaped));
+		return make_str(cmark_chunk_buf_detach(&unescaped));
 	} else {
 		return make_str(*content);
 	}
@@ -528,11 +528,11 @@ static cmark_node *make_str_with_entities(chunk *content)
 
 // Clean a URL: remove surrounding whitespace and surrounding <>,
 // and remove \ that escape punctuation.
-unsigned char *cmark_clean_url(chunk *url)
+unsigned char *cmark_clean_url(cmark_chunk *url)
 {
-	strbuf buf = GH_BUF_INIT;
+	cmark_strbuf buf = GH_BUF_INIT;
 
-	chunk_trim(url);
+	cmark_chunk_trim(url);
 
 	if (url->len == 0)
 		return NULL;
@@ -543,13 +543,13 @@ unsigned char *cmark_clean_url(chunk *url)
 		houdini_unescape_html_f(&buf, url->data, url->len);
 	}
 
-	strbuf_unescape(&buf);
-	return strbuf_detach(&buf);
+	cmark_strbuf_unescape(&buf);
+	return cmark_strbuf_detach(&buf);
 }
 
-unsigned char *cmark_clean_title(chunk *title)
+unsigned char *cmark_clean_title(cmark_chunk *title)
 {
-       strbuf buf = GH_BUF_INIT;
+       cmark_strbuf buf = GH_BUF_INIT;
        unsigned char first, last;
 
        if (title->len == 0)
@@ -567,8 +567,8 @@ unsigned char *cmark_clean_title(chunk *title)
                houdini_unescape_html_f(&buf, title->data, title->len);
        }
 
-       strbuf_unescape(&buf);
-       return strbuf_detach(&buf);
+       cmark_strbuf_unescape(&buf);
+       return cmark_strbuf_detach(&buf);
 }
 
 // Parse an autolink or HTML tag.
@@ -576,14 +576,14 @@ unsigned char *cmark_clean_title(chunk *title)
 static cmark_node* handle_pointy_brace(subject* subj)
 {
 	int matchlen = 0;
-	chunk contents;
+	cmark_chunk contents;
 
 	advance(subj);  // advance past first <
 
 	// first try to match a URL autolink
 	matchlen = scan_autolink_uri(&subj->input, subj->pos);
 	if (matchlen > 0) {
-		contents = chunk_dup(&subj->input, subj->pos, matchlen - 1);
+		contents = cmark_chunk_dup(&subj->input, subj->pos, matchlen - 1);
 		subj->pos += matchlen;
 
 		return make_autolink(
@@ -595,7 +595,7 @@ static cmark_node* handle_pointy_brace(subject* subj)
 	// next try to match an email autolink
 	matchlen = scan_autolink_email(&subj->input, subj->pos);
 	if (matchlen > 0) {
-		contents = chunk_dup(&subj->input, subj->pos, matchlen - 1);
+		contents = cmark_chunk_dup(&subj->input, subj->pos, matchlen - 1);
 		subj->pos += matchlen;
 
 		return make_autolink(
@@ -607,20 +607,20 @@ static cmark_node* handle_pointy_brace(subject* subj)
 	// finally, try to match an html tag
 	matchlen = scan_html_tag(&subj->input, subj->pos);
 	if (matchlen > 0) {
-		contents = chunk_dup(&subj->input, subj->pos - 1, matchlen + 1);
+		contents = cmark_chunk_dup(&subj->input, subj->pos - 1, matchlen + 1);
 		subj->pos += matchlen;
 		return make_raw_html(contents);
 	}
 
 	// if nothing matches, just return the opening <:
-	return make_str(chunk_literal("<"));
+	return make_str(cmark_chunk_literal("<"));
 }
 
 // Parse a link label.  Returns 1 if successful.
 // Note:  unescaped brackets are not allowed in labels.
 // The label begins with `[` and ends with the first `]` character
 // encountered.  Backticks in labels do not start code spans.
-static int link_label(subject* subj, chunk *raw_label)
+static int link_label(subject* subj, cmark_chunk *raw_label)
 {
 	int startpos = subj->pos;
 	int length = 0;
@@ -651,7 +651,7 @@ static int link_label(subject* subj, chunk *raw_label)
 	}
 
 	if (c == ']') { // match found
-		*raw_label = chunk_dup(&subj->input, startpos + 1, subj->pos - (startpos + 1));
+		*raw_label = cmark_chunk_dup(&subj->input, startpos + 1, subj->pos - (startpos + 1));
 		advance(subj);  // advance past ]
 		return 1;
 	}
@@ -671,13 +671,13 @@ static cmark_node* handle_close_bracket(subject* subj, cmark_node *parent)
 	int sps;
 	cmark_reference *ref;
 	bool is_image = false;
-	chunk urlchunk, titlechunk;
+	cmark_chunk urlcmark_chunk, titlecmark_chunk;
 	unsigned char *url, *title;
 	delimiter *opener;
 	delimiter *tmp_delim;
 	cmark_node *link_text;
 	cmark_node *inl;
-	chunk raw_label;
+	cmark_chunk raw_label;
 	int found_label;
 
 	advance(subj);  // advance past ]
@@ -693,7 +693,7 @@ static cmark_node* handle_close_bracket(subject* subj, cmark_node *parent)
 	}
 
 	if (opener == NULL) {
-		return make_str(chunk_literal("]"));
+		return make_str(cmark_chunk_literal("]"));
 	}
 
 	// If we got here, we matched a potential link/image text.
@@ -721,12 +721,12 @@ static cmark_node* handle_close_bracket(subject* subj, cmark_node *parent)
 		if (peek_at(subj, endall) == ')') {
 			subj->pos = endall + 1;
 
-			urlchunk = chunk_dup(&subj->input, starturl, endurl - starturl);
-			titlechunk = chunk_dup(&subj->input, starttitle, endtitle - starttitle);
-			url = cmark_clean_url(&urlchunk);
-			title = cmark_clean_title(&titlechunk);
-			chunk_free(&urlchunk);
-			chunk_free(&titlechunk);
+			urlcmark_chunk = cmark_chunk_dup(&subj->input, starturl, endurl - starturl);
+			titlecmark_chunk = cmark_chunk_dup(&subj->input, starttitle, endtitle - starttitle);
+			url = cmark_clean_url(&urlcmark_chunk);
+			title = cmark_clean_title(&titlecmark_chunk);
+			cmark_chunk_free(&urlcmark_chunk);
+			cmark_chunk_free(&titlecmark_chunk);
 			goto match;
 
 		} else {
@@ -737,11 +737,11 @@ static cmark_node* handle_close_bracket(subject* subj, cmark_node *parent)
 	// Next, look for a following [link label] that matches in refmap.
 	// skip spaces
 	subj->pos = subj->pos + scan_spacechars(&subj->input, subj->pos);
-	raw_label = chunk_literal("");
+	raw_label = cmark_chunk_literal("");
 	found_label = link_label(subj, &raw_label);
 	if (!found_label || raw_label.len == 0) {
-		chunk_free(&raw_label);
-		raw_label = chunk_dup(&subj->input, opener->position,
+		cmark_chunk_free(&raw_label);
+		raw_label = cmark_chunk_dup(&subj->input, opener->position,
 				      initial_pos - opener->position - 1);
 	}
 
@@ -752,7 +752,7 @@ static cmark_node* handle_close_bracket(subject* subj, cmark_node *parent)
 	}
 
 	ref = cmark_reference_lookup(subj->refmap, &raw_label);
-	chunk_free(&raw_label);
+	cmark_chunk_free(&raw_label);
 
 	if (ref != NULL) { // found
 		url = bufdup(ref->url);
@@ -766,12 +766,12 @@ noMatch:
 	// If we fall through to here, it means we didn't match a link:
 	remove_delimiter(subj, opener);  // remove this opener from delimiter list
 	subj->pos = initial_pos;
-	return make_str(chunk_literal("]"));
+	return make_str(cmark_chunk_literal("]"));
 
 match:
 	inl = opener->inl_text;
 	inl->type = is_image ? NODE_IMAGE : NODE_LINK;
-	chunk_free(&inl->as.literal);
+	cmark_chunk_free(&inl->as.literal);
 	inl->first_child = link_text;
 	process_emphasis(subj, opener->previous);
 	inl->as.link.url   = url;
@@ -863,7 +863,7 @@ static int subject_find_special_char(subject *subj)
 static int parse_inline(subject* subj, cmark_node * parent)
 {
 	cmark_node* new_inl = NULL;
-	chunk contents;
+	cmark_chunk contents;
 	unsigned char c;
 	int endpos;
 	c = peek_char(subj);
@@ -892,7 +892,7 @@ static int parse_inline(subject* subj, cmark_node * parent)
 		break;
 	case '[':
 		advance(subj);
-		new_inl = make_str(chunk_literal("["));
+		new_inl = make_str(cmark_chunk_literal("["));
 		push_delimiter(subj, '[', true, false, new_inl);
 		break;
 	case ']':
@@ -902,20 +902,20 @@ static int parse_inline(subject* subj, cmark_node * parent)
 		advance(subj);
 		if (peek_char(subj) == '[') {
 			advance(subj);
-			new_inl = make_str(chunk_literal("!["));
+			new_inl = make_str(cmark_chunk_literal("!["));
 			push_delimiter(subj, '!', false, true, new_inl);
 		} else {
-			new_inl = make_str(chunk_literal("!"));
+			new_inl = make_str(cmark_chunk_literal("!"));
 		}
 		break;
 	default:
 		endpos = subject_find_special_char(subj);
-		contents = chunk_dup(&subj->input, subj->pos, endpos - subj->pos);
+		contents = cmark_chunk_dup(&subj->input, subj->pos, endpos - subj->pos);
 		subj->pos = endpos;
 
 		// if we're at a newline, strip trailing spaces.
 		if (peek_char(subj) == '\n') {
-			chunk_rtrim(&contents);
+			cmark_chunk_rtrim(&contents);
 		}
 
 		new_inl = make_str(contents);
@@ -953,13 +953,13 @@ static void spnl(subject* subj)
 // Modify refmap if a reference is encountered.
 // Return 0 if no reference found, otherwise position of subject
 // after reference is parsed.
-int cmark_parse_reference_inline(strbuf *input, cmark_reference_map *refmap)
+int cmark_parse_reference_inline(cmark_strbuf *input, cmark_reference_map *refmap)
 {
 	subject subj;
 
-	chunk lab;
-	chunk url;
-	chunk title;
+	cmark_chunk lab;
+	cmark_chunk url;
+	cmark_chunk title;
 
 	int matchlen = 0;
 	int beforetitle;
@@ -981,7 +981,7 @@ int cmark_parse_reference_inline(strbuf *input, cmark_reference_map *refmap)
 	spnl(&subj);
 	matchlen = scan_link_url(&subj.input, subj.pos);
 	if (matchlen) {
-		url = chunk_dup(&subj.input, subj.pos, matchlen);
+		url = cmark_chunk_dup(&subj.input, subj.pos, matchlen);
 		subj.pos += matchlen;
 	} else {
 		return 0;
@@ -992,11 +992,11 @@ int cmark_parse_reference_inline(strbuf *input, cmark_reference_map *refmap)
 	spnl(&subj);
 	matchlen = scan_link_title(&subj.input, subj.pos);
 	if (matchlen) {
-		title = chunk_dup(&subj.input, subj.pos, matchlen);
+		title = cmark_chunk_dup(&subj.input, subj.pos, matchlen);
 		subj.pos += matchlen;
 	} else {
 		subj.pos = beforetitle;
-		title = chunk_literal("");
+		title = cmark_chunk_literal("");
 	}
 	// parse final spaces and newline:
 	while (peek_char(&subj) == ' ') {
diff --git a/src/inlines.h b/src/inlines.h
@@ -5,12 +5,12 @@
 extern "C" {
 #endif
 
-unsigned char *cmark_clean_url(chunk *url);
-unsigned char *cmark_clean_title(chunk *title);
+unsigned char *cmark_clean_url(cmark_chunk *url);
+unsigned char *cmark_clean_title(cmark_chunk *title);
 
 void cmark_parse_inlines(cmark_node* parent, cmark_reference_map *refmap);
 
-int cmark_parse_reference_inline(strbuf *input, cmark_reference_map *refmap);
+int cmark_parse_reference_inline(cmark_strbuf *input, cmark_reference_map *refmap);
 
 #ifdef __cplusplus
 }
diff --git a/src/man.c b/src/man.c
@@ -10,7 +10,7 @@
 
 // Functions to convert cmark_nodes to groff man strings.
 
-static void escape_man(strbuf *dest, const unsigned char *source, int length)
+static void escape_man(cmark_strbuf *dest, const unsigned char *source, int length)
 {
 	int i;
 	unsigned char c;
@@ -18,27 +18,27 @@ static void escape_man(strbuf *dest, const unsigned char *source, int length)
 	for (i = 0; i < length; i++) {
 		c = source[i];
 		if (c == '.' && i == 0) {
-			strbuf_puts(dest, "\\&.");
+			cmark_strbuf_puts(dest, "\\&.");
 		} else if (c == '\'' && i == 0) {
-			strbuf_puts(dest, "\\&'");
+			cmark_strbuf_puts(dest, "\\&'");
 		} else if (c == '-') {
-			strbuf_puts(dest, "\\-");
+			cmark_strbuf_puts(dest, "\\-");
 		} else if (c == '\\') {
-			strbuf_puts(dest, "\\e");
+			cmark_strbuf_puts(dest, "\\e");
 		} else {
-			strbuf_putc(dest, source[i]);
+			cmark_strbuf_putc(dest, source[i]);
 		}
 	}
 }
 
-static inline void cr(strbuf *man)
+static inline void cr(cmark_strbuf *man)
 {
 	if (man->size && man->ptr[man->size - 1] != '\n')
-		strbuf_putc(man, '\n');
+		cmark_strbuf_putc(man, '\n');
 }
 
 struct render_state {
-	strbuf* man;
+	cmark_strbuf* man;
 	cmark_node *plain;
 };
 
@@ -47,7 +47,7 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 {
 	struct render_state *state = vstate;
 	cmark_node *tmp;
-	strbuf *man = state->man;
+	cmark_strbuf *man = state->man;
 	int list_number;
 	bool entering = (ev_type == CMARK_EVENT_ENTER);
 
@@ -65,7 +65,7 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 
 		case CMARK_NODE_LINEBREAK:
 		case CMARK_NODE_SOFTBREAK:
-			strbuf_putc(man, ' ');
+			cmark_strbuf_putc(man, ' ');
 			break;
 
 		default:
@@ -81,11 +81,11 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 	case CMARK_NODE_BLOCK_QUOTE:
 		if (entering) {
 			cr(man);
-			strbuf_puts(man, ".RS");
+			cmark_strbuf_puts(man, ".RS");
 			cr(man);
 		} else {
 			cr(man);
-			strbuf_puts(man, ".RE");
+			cmark_strbuf_puts(man, ".RE");
 			cr(man);
 		}
 		break;
@@ -96,10 +96,10 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 	case CMARK_NODE_LIST_ITEM:
 		if (entering) {
 			cr(man);
-			strbuf_puts(man, ".IP ");
+			cmark_strbuf_puts(man, ".IP ");
 			if (cmark_node_get_list_type(node->parent) ==
 			    CMARK_BULLET_LIST) {
-				strbuf_puts(man, "\\[bu] 2");
+				cmark_strbuf_puts(man, "\\[bu] 2");
 			} else {
 				list_number = cmark_node_get_list_start(node->parent);
 				tmp = node;
@@ -107,7 +107,7 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 					tmp = tmp->prev;
 					list_number += 1;
 				}
-				strbuf_printf(man, "\"%d.\" 4", list_number);
+				cmark_strbuf_printf(man, "\"%d.\" 4", list_number);
 			}
 			cr(man);
 		} else {
@@ -118,7 +118,7 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 	case CMARK_NODE_HEADER:
 		if (entering) {
 			cr(man);
-			strbuf_puts(man,
+			cmark_strbuf_puts(man,
 				    cmark_node_get_header_level(node) == 1 ?
 				    ".SH" : ".SS");
 			cr(man);
@@ -129,11 +129,11 @@ 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");
+		cmark_strbuf_puts(man, ".IP\n.nf\n\\f[C]\n");
 		escape_man(man, node->as.literal.data,
 			   node->as.literal.len);
 		cr(man);
-		strbuf_puts(man, "\\f[]\n.fi");
+		cmark_strbuf_puts(man, "\\f[]\n.fi");
 		cr(man);
 		break;
 
@@ -142,7 +142,7 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 
 	case CMARK_NODE_HRULE:
 		cr(man);
-		strbuf_puts(man, ".PP\n  *  *  *  *  *");
+		cmark_strbuf_puts(man, ".PP\n  *  *  *  *  *");
 		cr(man);
 		break;
 
@@ -155,7 +155,7 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 				// no blank line or .PP
 			} else {
 				cr(man);
-				strbuf_puts(man, ".PP\n");
+				cmark_strbuf_puts(man, ".PP\n");
 			}
 		} else {
 			cr(man);
@@ -168,18 +168,18 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 		break;
 
 	case CMARK_NODE_LINEBREAK:
-		strbuf_puts(man, ".PD 0\n.P\n.PD");
+		cmark_strbuf_puts(man, ".PD 0\n.P\n.PD");
 		cr(man);
 		break;
 
 	case CMARK_NODE_SOFTBREAK:
-		strbuf_putc(man, '\n');
+		cmark_strbuf_putc(man, '\n');
 		break;
 
 	case CMARK_NODE_CODE:
-		strbuf_puts(man, "\\f[C]");
+		cmark_strbuf_puts(man, "\\f[C]");
 		escape_man(man, node->as.literal.data, node->as.literal.len);
-		strbuf_puts(man, "\\f[]");
+		cmark_strbuf_puts(man, "\\f[]");
 		break;
 
 	case CMARK_NODE_INLINE_HTML:
@@ -187,33 +187,33 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 
 	case CMARK_NODE_STRONG:
 		if (entering) {
-			strbuf_puts(man, "\\f[B]");
+			cmark_strbuf_puts(man, "\\f[B]");
 		} else {
-			strbuf_puts(man, "\\f[]");
+			cmark_strbuf_puts(man, "\\f[]");
 		}
 		break;
 
 	case CMARK_NODE_EMPH:
 		if (entering) {
-			strbuf_puts(man, "\\f[I]");
+			cmark_strbuf_puts(man, "\\f[I]");
 		} else {
-			strbuf_puts(man, "\\f[]");
+			cmark_strbuf_puts(man, "\\f[]");
 		}
 		break;
 
 	case CMARK_NODE_LINK:
 		if (!entering) {
-			strbuf_printf(man, " (%s)",
+			cmark_strbuf_printf(man, " (%s)",
 				      cmark_node_get_url(node));
 		}
 		break;
 
 	case CMARK_NODE_IMAGE:
 		if (entering) {
-			strbuf_puts(man, "[IMAGE: ");
+			cmark_strbuf_puts(man, "[IMAGE: ");
 			state->plain = node;
 		} else {
-			strbuf_puts(man, "]");
+			cmark_strbuf_puts(man, "]");
 		}
 		break;
 
@@ -222,14 +222,14 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 		break;
 	}
 
-	// strbuf_putc(man, 'x');
+	// cmark_strbuf_putc(man, 'x');
 	return 1;
 }
 
 char *cmark_render_man(cmark_node *root)
 {
 	char *result;
-	strbuf man = GH_BUF_INIT;
+	cmark_strbuf man = GH_BUF_INIT;
 	struct render_state state = { &man, NULL };
 	cmark_node *cur;
 	cmark_event_type ev_type;
@@ -239,9 +239,9 @@ char *cmark_render_man(cmark_node *root)
 		cur = cmark_iter_get_node(iter);
 		S_render_node(cur, ev_type, &state);
 	}
-	result = (char *)strbuf_detach(&man);
+	result = (char *)cmark_strbuf_detach(&man);
 
 	cmark_iter_free(iter);
-	strbuf_free(&man);
+	cmark_strbuf_free(&man);
 	return result;
 }
diff --git a/src/node.c b/src/node.c
@@ -38,17 +38,17 @@ void S_free_nodes(cmark_node *e)
 {
 	cmark_node *next;
 	while (e != NULL) {
-		strbuf_free(&e->string_content);
+		cmark_strbuf_free(&e->string_content);
 		switch (e->type){
 		case NODE_CODE_BLOCK:
-			chunk_free(&e->as.code.info);
-			chunk_free(&e->as.literal);
+			cmark_chunk_free(&e->as.code.info);
+			cmark_chunk_free(&e->as.literal);
 			break;
 		case NODE_TEXT:
 		case NODE_INLINE_HTML:
 		case NODE_CODE:
 		case NODE_HTML:
-			chunk_free(&e->as.literal);
+			cmark_chunk_free(&e->as.literal);
 			break;
 		case NODE_LINK:
 		case NODE_IMAGE:
@@ -188,7 +188,7 @@ cmark_node_get_literal(cmark_node *node) {
 	case NODE_TEXT:
 	case NODE_INLINE_HTML:
 	case NODE_CODE:
-		return chunk_to_cstr(&node->as.literal);
+		return cmark_chunk_to_cstr(&node->as.literal);
 
 	default:
 		break;
@@ -209,7 +209,7 @@ cmark_node_set_literal(cmark_node *node, const char *content) {
 	case NODE_TEXT:
 	case NODE_INLINE_HTML:
 	case NODE_CODE:
-		chunk_set_cstr(&node->as.literal, content);
+		cmark_chunk_set_cstr(&node->as.literal, content);
 		return 1;
 
 	default:
@@ -352,7 +352,7 @@ cmark_node_get_fence_info(cmark_node *node) {
 	}
 
 	if (node->type == NODE_CODE_BLOCK) {
-		return chunk_to_cstr(&node->as.code.info);
+		return cmark_chunk_to_cstr(&node->as.code.info);
 	}
 	else {
 		return NULL;
@@ -366,7 +366,7 @@ cmark_node_set_fence_info(cmark_node *node, const char *info) {
 	}
 
 	if (node->type == NODE_CODE_BLOCK) {
-		chunk_set_cstr(&node->as.code.info, info);
+		cmark_chunk_set_cstr(&node->as.code.info, info);
 		return 1;
 	}
 	else {
diff --git a/src/node.h b/src/node.h
@@ -26,7 +26,7 @@ typedef struct {
 	int               fence_length;
 	int               fence_offset;
 	unsigned char     fence_char;
-	chunk             info;
+	cmark_chunk       info;
 } cmark_code;
 
 typedef struct {
@@ -54,10 +54,10 @@ struct cmark_node {
 	bool open;
 	bool last_line_blank;
 
-	strbuf string_content;
+	cmark_strbuf string_content;
 
 	union {
-		chunk             literal;
+		cmark_chunk       literal;
 		cmark_list        list;
 		cmark_code        code;
 		cmark_header      header;
@@ -73,4 +73,3 @@ cmark_node_check(cmark_node *node, FILE *out);
 #endif
 
 #endif
-
diff --git a/src/parser.h b/src/parser.h
@@ -16,8 +16,8 @@ struct cmark_parser {
 	struct cmark_node* root;
 	struct cmark_node* current;
 	int line_number;
-	strbuf *curline;
-	strbuf *linebuf;
+	cmark_strbuf *curline;
+	cmark_strbuf *linebuf;
 };
 
 #ifdef __cplusplus
diff --git a/src/print.c b/src/print.c
@@ -7,129 +7,129 @@
 
 #define INDENT 2
 
-static void print_str(strbuf* buffer, const unsigned char *s, int len)
+static void print_str(cmark_strbuf* buffer, const unsigned char *s, int len)
 {
 	int i;
 
 	if (len < 0)
 		len = strlen((char *)s);
 
-	strbuf_putc(buffer, '"');
+	cmark_strbuf_putc(buffer, '"');
 	for (i = 0; i < len; ++i) {
 		unsigned char c = s[i];
 
 		switch (c) {
 		case '\n':
-			strbuf_printf(buffer, "\\n");
+			cmark_strbuf_printf(buffer, "\\n");
 			break;
 		case '"':
-			strbuf_printf(buffer, "\\\"");
+			cmark_strbuf_printf(buffer, "\\\"");
 			break;
 		case '\\':
-			strbuf_printf(buffer, "\\\\");
+			cmark_strbuf_printf(buffer, "\\\\");
 			break;
 		default:
-			strbuf_putc(buffer, (int)c);
+			cmark_strbuf_putc(buffer, (int)c);
 		}
 	}
-	strbuf_putc(buffer, '"');
+	cmark_strbuf_putc(buffer, '"');
 }
 
 // Prettyprint an inline list, for debugging.
-static void render_nodes(strbuf* buffer, cmark_node* node, int indent)
+static void render_nodes(cmark_strbuf* buffer, cmark_node* node, int indent)
 {
 	int i;
 	cmark_list *data;
 
 	while(node != NULL) {
 		for (i=0; i < indent; i++) {
-			strbuf_putc(buffer, ' ');
+			cmark_strbuf_putc(buffer, ' ');
 		}
 		switch(node->type) {
 		case NODE_DOCUMENT:
 			break;
 		case NODE_BLOCK_QUOTE:
-			strbuf_printf(buffer, "block_quote\n");
+			cmark_strbuf_printf(buffer, "block_quote\n");
 			break;
 		case NODE_LIST_ITEM:
-			strbuf_printf(buffer, "list_item\n");
+			cmark_strbuf_printf(buffer, "list_item\n");
 			break;
 		case NODE_LIST:
 			data = &(node->as.list);
 			if (data->list_type == CMARK_ORDERED_LIST) {
-				strbuf_printf(buffer, "list (type=ordered tight=%s start=%d delim=%s)\n",
+				cmark_strbuf_printf(buffer, "list (type=ordered tight=%s start=%d delim=%s)\n",
 				       (data->tight ? "true" : "false"),
 				       data->start,
 				       (data->delimiter == CMARK_PAREN_DELIM ? "parens" : "period"));
 			} else {
-				strbuf_printf(buffer, "list (type=bullet tight=%s bullet_char=%c)\n",
+				cmark_strbuf_printf(buffer, "list (type=bullet tight=%s bullet_char=%c)\n",
 				       (data->tight ? "true" : "false"),
 				       data->bullet_char);
 			}
 			break;
 		case NODE_HEADER:
-			strbuf_printf(buffer, "header (level=%d)\n", node->as.header.level);
+			cmark_strbuf_printf(buffer, "header (level=%d)\n", node->as.header.level);
 			break;
 		case NODE_PARAGRAPH:
-			strbuf_printf(buffer, "paragraph\n");
+			cmark_strbuf_printf(buffer, "paragraph\n");
 			break;
 		case NODE_HRULE:
-			strbuf_printf(buffer, "hrule\n");
+			cmark_strbuf_printf(buffer, "hrule\n");
 			break;
 		case NODE_CODE_BLOCK:
-			strbuf_printf(buffer, "code_block info=");
+			cmark_strbuf_printf(buffer, "code_block info=");
 			print_str(buffer, node->as.code.info.data,
 				  node->as.code.info.len);
-			strbuf_putc(buffer, ' ');
+			cmark_strbuf_putc(buffer, ' ');
 			print_str(buffer, node->as.literal.data,
 				  node->as.literal.len);
-			strbuf_putc(buffer, '\n');
+			cmark_strbuf_putc(buffer, '\n');
 			break;
 		case NODE_HTML:
-			strbuf_printf(buffer, "html ");
+			cmark_strbuf_printf(buffer, "html ");
 			print_str(buffer, node->as.literal.data,
 				  node->as.literal.len);
-			strbuf_putc(buffer, '\n');
+			cmark_strbuf_putc(buffer, '\n');
 			break;
 		case NODE_TEXT:
-			strbuf_printf(buffer, "text ");
+			cmark_strbuf_printf(buffer, "text ");
 			print_str(buffer, node->as.literal.data, node->as.literal.len);
-			strbuf_putc(buffer, '\n');
+			cmark_strbuf_putc(buffer, '\n');
 			break;
 		case NODE_LINEBREAK:
-			strbuf_printf(buffer, "linebreak\n");
+			cmark_strbuf_printf(buffer, "linebreak\n");
 			break;
 		case NODE_SOFTBREAK:
-			strbuf_printf(buffer, "softbreak\n");
+			cmark_strbuf_printf(buffer, "softbreak\n");
 			break;
 		case NODE_CODE:
-			strbuf_printf(buffer, "code ");
+			cmark_strbuf_printf(buffer, "code ");
 			print_str(buffer, node->as.literal.data, node->as.literal.len);
-			strbuf_putc(buffer, '\n');
+			cmark_strbuf_putc(buffer, '\n');
 			break;
 		case NODE_INLINE_HTML:
-			strbuf_printf(buffer, "inline_html ");
+			cmark_strbuf_printf(buffer, "inline_html ");
 			print_str(buffer, node->as.literal.data, node->as.literal.len);
-			strbuf_putc(buffer, '\n');
+			cmark_strbuf_putc(buffer, '\n');
 			break;
 		case NODE_LINK:
 		case NODE_IMAGE:
-			strbuf_printf(buffer, "%s url=", node->type == NODE_LINK ? "link" : "image");
+			cmark_strbuf_printf(buffer, "%s url=", node->type == NODE_LINK ? "link" : "image");
 
 			if (node->as.link.url)
 				print_str(buffer, node->as.link.url, -1);
 
 			if (node->as.link.title) {
-				strbuf_printf(buffer, " title=");
+				cmark_strbuf_printf(buffer, " title=");
 				print_str(buffer, node->as.link.title, -1);
 			}
-			strbuf_putc(buffer, '\n');
+			cmark_strbuf_putc(buffer, '\n');
 			break;
 		case NODE_STRONG:
-			strbuf_printf(buffer, "strong\n");
+			cmark_strbuf_printf(buffer, "strong\n");
 			break;
 		case NODE_EMPH:
-			strbuf_printf(buffer, "emph\n");
+			cmark_strbuf_printf(buffer, "emph\n");
 			break;
 		default:
 			break;
@@ -160,9 +160,9 @@ static void render_nodes(strbuf* buffer, cmark_node* node, int indent)
 char *cmark_render_ast(cmark_node *root)
 {
 	char* result;
-	strbuf buffer = GH_BUF_INIT;
+	cmark_strbuf buffer = GH_BUF_INIT;
 	render_nodes(&buffer, root, -2);
-	result = (char *)strbuf_detach(&buffer);
-	strbuf_free(&buffer);
+	result = (char *)cmark_strbuf_detach(&buffer);
+	cmark_strbuf_free(&buffer);
 	return result;
 }
diff --git a/src/references.c b/src/references.c
@@ -30,9 +30,9 @@ static void reference_free(cmark_reference *ref)
 // remove leading/trailing whitespace, case fold
 // Return NULL if the reference name is actually empty (i.e. composed
 // solely from whitespace)
-static unsigned char *normalize_reference(chunk *ref)
+static unsigned char *normalize_reference(cmark_chunk *ref)
 {
-	strbuf normalized = GH_BUF_INIT;
+	cmark_strbuf normalized = GH_BUF_INIT;
 	unsigned char *result;
 
 	if(ref == NULL)
@@ -42,10 +42,10 @@ static unsigned char *normalize_reference(chunk *ref)
 		return NULL;
 
 	utf8proc_case_fold(&normalized, ref->data, ref->len);
-	strbuf_trim(&normalized);
-	strbuf_normalize_whitespace(&normalized);
+	cmark_strbuf_trim(&normalized);
+	cmark_strbuf_normalize_whitespace(&normalized);
 
-	result = strbuf_detach(&normalized);
+	result = cmark_strbuf_detach(&normalized);
 	assert(result);
 
 	if (result[0] == '\0') {
@@ -73,8 +73,8 @@ static void add_reference(cmark_reference_map *map, cmark_reference* ref)
 	map->table[ref->hash % REFMAP_SIZE] = ref;
 }
 
-void cmark_reference_create(cmark_reference_map *map, chunk *label, chunk *url,
-			    chunk *title)
+void cmark_reference_create(cmark_reference_map *map, cmark_chunk *label, cmark_chunk *url,
+			    cmark_chunk *title)
 {
 	cmark_reference *ref;
 	unsigned char *reflabel = normalize_reference(label);
@@ -97,7 +97,7 @@ void cmark_reference_create(cmark_reference_map *map, chunk *label, chunk *url,
 
 // Returns reference if refmap contains a reference with matching
 // label, otherwise NULL.
-cmark_reference* cmark_reference_lookup(cmark_reference_map *map, chunk *label)
+cmark_reference* cmark_reference_lookup(cmark_reference_map *map, cmark_chunk *label)
 {
 	cmark_reference *ref = NULL;
 	unsigned char *norm;
diff --git a/src/references.h b/src/references.h
@@ -27,8 +27,8 @@ typedef struct cmark_reference_map cmark_reference_map;
 
 cmark_reference_map *cmark_reference_map_new(void);
 void cmark_reference_map_free(cmark_reference_map *map);
-cmark_reference* cmark_reference_lookup(cmark_reference_map *map, chunk *label);
-extern void cmark_reference_create(cmark_reference_map *map, chunk *label, chunk *url, chunk *title);
+cmark_reference* cmark_reference_lookup(cmark_reference_map *map, cmark_chunk *label);
+extern void cmark_reference_create(cmark_reference_map *map, cmark_chunk *label, cmark_chunk *url, cmark_chunk *title);
 
 #ifdef __cplusplus
 }
diff --git a/src/scanners.c b/src/scanners.c
@@ -3,7 +3,7 @@
 #include "chunk.h"
 #include "scanners.h"
 
-int _scan_at(int (*scanner)(const unsigned char *), chunk *c, int offset)
+int _scan_at(int (*scanner)(const unsigned char *), cmark_chunk *c, int offset)
 {
 	int res;
 	unsigned char *ptr = (unsigned char *)c->data;
diff --git a/src/scanners.h b/src/scanners.h
@@ -5,7 +5,7 @@
 extern "C" {
 #endif
 
-int _scan_at(int (*scanner)(const unsigned char *), chunk *c, int offset);
+int _scan_at(int (*scanner)(const unsigned char *), cmark_chunk *c, int offset);
 int _scan_autolink_uri(const unsigned char *p);
 int _scan_autolink_email(const unsigned char *p);
 int _scan_html_tag(const unsigned char *p);
diff --git a/src/utf8.c b/src/utf8.c
@@ -22,10 +22,10 @@ static const int8_t utf8proc_utf8class[256] = {
 	3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
 	4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0 };
 
-static void encode_unknown(strbuf *buf)
+static void encode_unknown(cmark_strbuf *buf)
 {
 	static const uint8_t repl[] = {239, 191, 189};
-	strbuf_put(buf, repl, 3);
+	cmark_strbuf_put(buf, repl, 3);
 }
 
 static int utf8proc_charlen(const uint8_t *str, int str_len)
@@ -109,7 +109,7 @@ static int utf8proc_valid(const uint8_t *str, int str_len)
 	return length;
 }
 
-void utf8proc_detab(strbuf *ob, const uint8_t *line, size_t size)
+void utf8proc_detab(cmark_strbuf *ob, const uint8_t *line, size_t size)
 {
 	static const uint8_t whitespace[] = "    ";
 
@@ -124,21 +124,21 @@ void utf8proc_detab(strbuf *ob, const uint8_t *line, size_t size)
 		}
 
 		if (i > org)
-			strbuf_put(ob, line + org, i - org);
+			cmark_strbuf_put(ob, line + org, i - org);
 
 		if (i >= size)
 			break;
 
 		if (line[i] == '\t') {
 			int numspaces = 4 - (tab % 4);
-			strbuf_put(ob, whitespace, numspaces);
+			cmark_strbuf_put(ob, whitespace, numspaces);
 			i += 1;
 			tab += numspaces;
 		} else {
 			int charlen = utf8proc_valid(line + i, size - i);
 
 			if (charlen >= 0) {
-				strbuf_put(ob, line + i, charlen);
+				cmark_strbuf_put(ob, line + i, charlen);
 			} else {
 				encode_unknown(ob);
 				charlen = -charlen;
@@ -188,7 +188,7 @@ int utf8proc_iterate(const uint8_t *str, int str_len, int32_t *dst)
 	return length;
 }
 
-void utf8proc_encode_char(int32_t uc, strbuf *buf)
+void utf8proc_encode_char(int32_t uc, cmark_strbuf *buf)
 {
 	uint8_t dst[4];
 	int len = 0;
@@ -224,10 +224,10 @@ void utf8proc_encode_char(int32_t uc, strbuf *buf)
 		return;
 	}
 
-	strbuf_put(buf, dst, len);
+	cmark_strbuf_put(buf, dst, len);
 }
 
-void utf8proc_case_fold(strbuf *dest, const uint8_t *str, int len)
+void utf8proc_case_fold(cmark_strbuf *dest, const uint8_t *str, int len)
 {
 	int32_t c;
 
diff --git a/src/utf8.h b/src/utf8.h
@@ -8,10 +8,10 @@
 extern "C" {
 #endif
 
-void utf8proc_case_fold(strbuf *dest, const uint8_t *str, int len);
-void utf8proc_encode_char(int32_t uc, strbuf *buf);
+void utf8proc_case_fold(cmark_strbuf *dest, const uint8_t *str, int len);
+void utf8proc_encode_char(int32_t uc, cmark_strbuf *buf);
 int utf8proc_iterate(const uint8_t *str, int str_len, int32_t *dst);
-void utf8proc_detab(strbuf *dest, const uint8_t *line, size_t size);
+void utf8proc_detab(cmark_strbuf *dest, const uint8_t *line, size_t size);
 int utf8proc_is_space(int32_t uc);
 int utf8proc_is_punctuation(int32_t uc);