Fossil SCM
Switch to commonmark renderer
Commit
de94fdd1fabcf02654edff453fed99a0aa6c2b3b1d1bb10dc33006c680ed0eec
Parent
116e744bbe77107…
1 file changed
+7
-41
+7
-41
| --- src/markdown_html.c | ||
| +++ src/markdown_html.c | ||
| @@ -19,10 +19,11 @@ | ||
| 19 | 19 | ** XHTML output. |
| 20 | 20 | */ |
| 21 | 21 | |
| 22 | 22 | #include "config.h" |
| 23 | 23 | #include "markdown_html.h" |
| 24 | +#include "cmark_amalgamation.h" | |
| 24 | 25 | |
| 25 | 26 | #if INTERFACE |
| 26 | 27 | |
| 27 | 28 | void markdown_to_html( |
| 28 | 29 | struct Blob *input_markdown, |
| @@ -403,48 +404,13 @@ | ||
| 403 | 404 | void markdown_to_html( |
| 404 | 405 | struct Blob *input_markdown, /* Markdown content to be rendered */ |
| 405 | 406 | struct Blob *output_title, /* Put title here. May be NULL */ |
| 406 | 407 | struct Blob *output_body /* Put document body here. */ |
| 407 | 408 | ){ |
| 408 | - struct mkd_renderer html_renderer = { | |
| 409 | - /* prolog and epilog */ | |
| 410 | - html_prolog, | |
| 411 | - html_epilog, | |
| 412 | - | |
| 413 | - /* block level elements */ | |
| 414 | - html_blockcode, | |
| 415 | - html_blockquote, | |
| 416 | - html_raw_block, | |
| 417 | - html_header, | |
| 418 | - html_hrule, | |
| 419 | - html_list, | |
| 420 | - html_list_item, | |
| 421 | - html_paragraph, | |
| 422 | - html_table, | |
| 423 | - html_table_cell, | |
| 424 | - html_table_row, | |
| 425 | - | |
| 426 | - /* span level elements */ | |
| 427 | - html_autolink, | |
| 428 | - html_code_span, | |
| 429 | - html_double_emphasis, | |
| 430 | - html_emphasis, | |
| 431 | - html_image, | |
| 432 | - html_line_break, | |
| 433 | - html_link, | |
| 434 | - html_raw_span, | |
| 435 | - html_triple_emphasis, | |
| 436 | - | |
| 437 | - /* low level elements */ | |
| 438 | - 0, /* entities are copied verbatim */ | |
| 439 | - html_normal_text, | |
| 440 | - | |
| 441 | - /* misc. parameters */ | |
| 442 | - 64, /* maximum stack */ | |
| 443 | - "*_", /* emphasis characters */ | |
| 444 | - 0 /* opaque data */ | |
| 445 | - }; | |
| 446 | - html_renderer.opaque = output_title; | |
| 447 | - if( output_title ) blob_reset(output_title); | |
| 409 | + if( output_title ) blob_reset(output_title); | |
| 448 | 410 | blob_reset(output_body); |
| 449 | - markdown(output_body, input_markdown, &html_renderer); | |
| 411 | + char *cmark_result = cmark_markdown_to_html(blob_str(input_markdown), blob_size(input_markdown), 0 ); | |
| 412 | + html_prolog(output_body,0); | |
| 413 | + blob_append(output_body, cmark_result, strlen(cmark_result)); | |
| 414 | + html_epilog(output_body,0); | |
| 415 | + free(cmark_result); | |
| 450 | 416 | } |
| 451 | 417 |
| --- src/markdown_html.c | |
| +++ src/markdown_html.c | |
| @@ -19,10 +19,11 @@ | |
| 19 | ** XHTML output. |
| 20 | */ |
| 21 | |
| 22 | #include "config.h" |
| 23 | #include "markdown_html.h" |
| 24 | |
| 25 | #if INTERFACE |
| 26 | |
| 27 | void markdown_to_html( |
| 28 | struct Blob *input_markdown, |
| @@ -403,48 +404,13 @@ | |
| 403 | void markdown_to_html( |
| 404 | struct Blob *input_markdown, /* Markdown content to be rendered */ |
| 405 | struct Blob *output_title, /* Put title here. May be NULL */ |
| 406 | struct Blob *output_body /* Put document body here. */ |
| 407 | ){ |
| 408 | struct mkd_renderer html_renderer = { |
| 409 | /* prolog and epilog */ |
| 410 | html_prolog, |
| 411 | html_epilog, |
| 412 | |
| 413 | /* block level elements */ |
| 414 | html_blockcode, |
| 415 | html_blockquote, |
| 416 | html_raw_block, |
| 417 | html_header, |
| 418 | html_hrule, |
| 419 | html_list, |
| 420 | html_list_item, |
| 421 | html_paragraph, |
| 422 | html_table, |
| 423 | html_table_cell, |
| 424 | html_table_row, |
| 425 | |
| 426 | /* span level elements */ |
| 427 | html_autolink, |
| 428 | html_code_span, |
| 429 | html_double_emphasis, |
| 430 | html_emphasis, |
| 431 | html_image, |
| 432 | html_line_break, |
| 433 | html_link, |
| 434 | html_raw_span, |
| 435 | html_triple_emphasis, |
| 436 | |
| 437 | /* low level elements */ |
| 438 | 0, /* entities are copied verbatim */ |
| 439 | html_normal_text, |
| 440 | |
| 441 | /* misc. parameters */ |
| 442 | 64, /* maximum stack */ |
| 443 | "*_", /* emphasis characters */ |
| 444 | 0 /* opaque data */ |
| 445 | }; |
| 446 | html_renderer.opaque = output_title; |
| 447 | if( output_title ) blob_reset(output_title); |
| 448 | blob_reset(output_body); |
| 449 | markdown(output_body, input_markdown, &html_renderer); |
| 450 | } |
| 451 |
| --- src/markdown_html.c | |
| +++ src/markdown_html.c | |
| @@ -19,10 +19,11 @@ | |
| 19 | ** XHTML output. |
| 20 | */ |
| 21 | |
| 22 | #include "config.h" |
| 23 | #include "markdown_html.h" |
| 24 | #include "cmark_amalgamation.h" |
| 25 | |
| 26 | #if INTERFACE |
| 27 | |
| 28 | void markdown_to_html( |
| 29 | struct Blob *input_markdown, |
| @@ -403,48 +404,13 @@ | |
| 404 | void markdown_to_html( |
| 405 | struct Blob *input_markdown, /* Markdown content to be rendered */ |
| 406 | struct Blob *output_title, /* Put title here. May be NULL */ |
| 407 | struct Blob *output_body /* Put document body here. */ |
| 408 | ){ |
| 409 | if( output_title ) blob_reset(output_title); |
| 410 | blob_reset(output_body); |
| 411 | char *cmark_result = cmark_markdown_to_html(blob_str(input_markdown), blob_size(input_markdown), 0 ); |
| 412 | html_prolog(output_body,0); |
| 413 | blob_append(output_body, cmark_result, strlen(cmark_result)); |
| 414 | html_epilog(output_body,0); |
| 415 | free(cmark_result); |
| 416 | } |
| 417 |