diff --git a/markdown.d.ts b/markdown.d.ts index 3756265..c0dcd57 100644 --- a/markdown.d.ts +++ b/markdown.d.ts @@ -6,22 +6,16 @@ export function parse(s :Source, o? :ParseOptions & { asMemoryView? :never|false export function parse(s :Source, o? :ParseOptions & { asMemoryView :true }) :Uint8Array /** Markdown source code can be provided as a JavaScript string or UTF8 encoded data */ -type Source = string|ArrayLike +type Source = string | ArrayLike /** Options for the parse function */ export interface ParseOptions { - /** - * Customize parsing. - * If not provided, the following flags are used, equating to github-style parsing: - * COLLAPSE_WHITESPACE - * PERMISSIVE_ATX_HEADERS - * PERMISSIVE_URL_AUTO_LINKS - * STRIKETHROUGH - * TABLES - * TASK_LISTS - */ + /** Customize parsing. Defaults to ParseFlags.DEFAULT */ parseFlags? :ParseFlags + /** Select output format. Defaults to "html" */ + format? : "html" | "xhtml" + /** * asMemoryView=true causes parse() to return a view of heap memory as a Uint8Array, * instead of a string. @@ -51,7 +45,18 @@ export enum ParseFlags { /** Enable tables extension. */ TABLES, /** Enable task list extension. */ TASK_LISTS, /** Enable wiki links extension. */ WIKI_LINKS, + /** Enable underline extension (disables '_' for emphasis) */ UNDERLINE, - /** Default flags */ DEFAULT, - /** Shorthand for NO_HTML_BLOCKS | NO_HTML_SPANS */ NO_HTML, + /** Default flags are: + * COLLAPSE_WHITESPACE | + * PERMISSIVE_ATX_HEADERS | + * PERMISSIVE_URL_AUTO_LINKS | + * STRIKETHROUGH | + * TABLES | + * TASK_LISTS + */ + DEFAULT, + + /** Shorthand for NO_HTML_BLOCKS | NO_HTML_SPANS */ + NO_HTML, } diff --git a/src/fmt_html.c b/src/fmt_html.c index e24dd1b..a2788f8 100644 --- a/src/fmt_html.c +++ b/src/fmt_html.c @@ -34,6 +34,7 @@ typedef struct HtmlRenderer_st { WBuf* outbuf; int imgnest; int addanchor; + u32 flags; } HtmlRenderer; @@ -246,7 +247,7 @@ static void render_close_img_span(HtmlRenderer* r, const MD_SPAN_IMG_DETAIL* det render_literal(r, "\" title=\""); render_attribute(r, &det->title); } - render_literal(r, "\">"); + render_literal(r, (r->flags & MD_HTML_FLAG_XHTML) ? "\"/>" : "\">"); r->imgnest--; } @@ -273,7 +274,7 @@ static int enter_block_callback(MD_BLOCKTYPE type, void* detail, void* userdata) case MD_BLOCK_UL: render_literal(r, "