CMARK :: #library "lib/libcmark-gfm"; Cmark_Options :: enum #specified { DEFAULT :: 0; /** Include a `data-sourcepos` attribute on all block elements. */ SOURCEPOS :: 1 << 1; /** Render `softbreak` elements as hard line breaks. */ HARDBREAKS :: 1 << 2; /** `CMARK_OPT_SAFE` is defined here for API compatibility, but it no longer has any effect. "Safe" mode is now the default: set `CMARK_OPT_UNSAFE` to disable it. */ SAFE :: 1 << 3; /** Render raw HTML and unsafe links (`javascript:`, `vbscript:`, * `file:`, and `data:`, except for `image/png`, `image/gif`, * `image/jpeg`, or `image/webp` mime types). By default, * raw HTML is replaced by a placeholder HTML comment. Unsafe * links are replaced by empty strings. */ UNSAFE :: 1 << 17; /** Render `softbreak` elements as spaces. */ NOBREAKS :: 1 << 4; /** Legacy option (no effect). */ NORMALIZE :: 1 << 8; /** Validate UTF-8 in the input before parsing, replacing illegal * sequences with the replacement character U+FFFD. */ VALIDATE_UTF8 :: 1 << 9; /** Convert straight quotes to curly, --- to em dashes, -- to en dashes. */ SMART :: 1 << 10; /** Use GitHub-style
 tags for code blocks instead of 
.
    */
    GITHUB_PRE_LANG :: 1 << 11;

    /** Be liberal in interpreting inline HTML tags. */
    LIBERAL_HTML_TAG :: 1 << 12;

    /** Parse footnotes. */
    FOOTNOTES :: 1 << 13;

    /** Only parse strikethroughs if surrounded by exactly 2 tildes.
    * Gives some compatibility with redcarpet.
    */
    STRIKETHROUGH_DOUBLE_TIDLE :: 1 << 14;

    /** Use style attributes to align table cells instead of align attributes. */
    TABLE_PREFER_STYLE_ATTRIBUTES :: 1 << 15;

    /** Include the remainder of the info string in code blocks in
    * a separate attribute.
    */
    FULL_INFO_STRING :: 1 << 16;
}


markdown_to_html :: (s: string, options: Cmark_Options = .DEFAULT) -> string {
    return to_string(cmark_markdown_to_html(to_c_string(s), s.count, xx options));
}


#scope_file


#import "Basic";


cmark_markdown_to_html :: (s: *u8, len: int, opt: int) -> *u8 #foreign CMARK;