cmark

My personal build of CMark ✏️

Commit
294880e0118e27c97f26beaaa81a79de23f80727
Parent
cc78b3e9e2c05201469356730c60f6bf3d073232
Author
John MacFarlane <jgm@berkeley.edu>
Date

Added options parameter to cmark_markdown_to_html.

Diffstat

5 files changed, 16 insertions, 12 deletions

Status File Name N° Changes Insertions Deletions
Modified api_test/cplusplus.cpp 2 1 1
Modified api_test/main.c 9 6 3
Modified man/man3/cmark.3 9 5 4
Modified src/cmark.c 6 3 3
Modified src/cmark.h 2 1 1
diff --git a/api_test/cplusplus.cpp b/api_test/cplusplus.cpp
@@ -8,7 +8,7 @@ void
 test_cplusplus(test_batch_runner *runner)
 {
     static const char md[] = "paragraph\n";
-    char *html = cmark_markdown_to_html(md, sizeof(md) - 1);
+    char *html = cmark_markdown_to_html(md, sizeof(md) - 1, CMARK_OPT_DEFAULT);
     STR_EQ(runner, html, "<p>paragraph</p>\n", "libcmark works with C++");
     free(html);
 }
diff --git a/api_test/main.c b/api_test/main.c
@@ -606,7 +606,8 @@ utf8(test_batch_runner *runner)
 	// Test string containing null character
 	static const char string_with_null[] = "((((\0))))";
 	char *html = cmark_markdown_to_html(string_with_null,
-					    sizeof(string_with_null) - 1);
+					    sizeof(string_with_null) - 1,
+		                            CMARK_OPT_DEFAULT);
 	STR_EQ(runner, html, "<p>((((" UTF8_REPL "))))</p>\n",
 	       "utf8 with U+0000");
 	free(html);
@@ -656,7 +657,8 @@ test_continuation_byte(test_batch_runner *runner, const char *utf8)
 		}
 		strcat(expected, "))))</p>\n");
 
-		char *html = cmark_markdown_to_html(buf, strlen(buf));
+		char *html = cmark_markdown_to_html(buf, strlen(buf),
+						    CMARK_OPT_DEFAULT);
 		STR_EQ(runner, html, expected,
 		       "invalid utf8 continuation byte %d/%d", pos, len);
 		free(html);
@@ -667,7 +669,8 @@ static void
 test_md_to_html(test_batch_runner *runner, const char *markdown,
 		const char *expected_html, const char *msg)
 {
-	char *html = cmark_markdown_to_html(markdown, strlen(markdown));
+	char *html = cmark_markdown_to_html(markdown, strlen(markdown),
+					    CMARK_OPT_DEFAULT);
 	STR_EQ(runner, html, expected_html, msg);
 	free(html);
 }
diff --git a/man/man3/cmark.3 b/man/man3/cmark.3
@@ -1,4 +1,4 @@
-.TH cmark 3 "March 09, 2015" "LOCAL" "Library Functions Manual"
+.TH cmark 3 "March 15, 2015" "LOCAL" "Library Functions Manual"
 .SH
 NAME
 .PP
@@ -10,7 +10,7 @@ DESCRIPTION
 Simple Interface
 
 .PP
-\fIchar *\f[] \fBcmark_markdown_to_html\f[](\fIconst char *text\f[], \fIint len\f[])
+\fIchar *\f[] \fBcmark_markdown_to_html\f[](\fIconst char *text\f[], \fIint len\f[], \fIint options\f[])
 
 .PP
 Convert \f[I]text\f[] (assumed to be a UTF\-8 encoded string with length
@@ -391,7 +391,8 @@ Simple interface:
 .IP
 .nf
 \f[C]
-cmark_node *document = cmark_parse_document("Hello *world*", 12);
+cmark_node *document = cmark_parse_document("Hello *world*", 12,
+                                            CMARK_OPT_DEFAULT);
 \f[]
 .fi
 .PP
@@ -399,7 +400,7 @@ Streaming interface:
 .IP
 .nf
 \f[C]
-cmark_parser *parser = cmark_parser_new();
+cmark_parser *parser = cmark_parser_new(CMARK_OPT_DEFAULT);
 FILE *fp = fopen("myfile.md", "r");
 while ((bytes = fread(buffer, 1, sizeof(buffer), fp)) > 0) {
        cmark_parser_feed(parser, buffer, bytes);
diff --git a/src/cmark.c b/src/cmark.c
@@ -9,14 +9,14 @@
 const int cmark_version = CMARK_VERSION;
 const char cmark_version_string[] = CMARK_VERSION_STRING;
 
-char *cmark_markdown_to_html(const char *text, int len)
+char *cmark_markdown_to_html(const char *text, int len, int options)
 {
 	cmark_node *doc;
 	char *result;
 
-	doc = cmark_parse_document(text, len, CMARK_OPT_DEFAULT);
+	doc = cmark_parse_document(text, len, options);
 
-	result = cmark_render_html(doc, CMARK_OPT_DEFAULT);
+	result = cmark_render_html(doc, options);
 	cmark_node_free(doc);
 
 	return result;
diff --git a/src/cmark.h b/src/cmark.h
@@ -24,7 +24,7 @@ extern "C" {
  * UTF-8-encoded string.
  */
 CMARK_EXPORT
-char *cmark_markdown_to_html(const char *text, int len);
+char *cmark_markdown_to_html(const char *text, int len, int options);
 
 /** ## Node Structure
  */