Added options parameter to cmark_markdown_to_html.
This commit is contained in:
parent
cc78b3e9e2
commit
294880e011
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user