| 1 | module markdown |
| 2 | |
| 3 | import strings |
| 4 | |
| 5 | fn C.md_html(const_input &char, input_size u32, process_output ProcessFn, userdata voidptr, parser_flags u32, renderer_flags u32) int |
| 6 | |
| 7 | const need_html_esc_flag = 0x1 |
| 8 | const need_url_esc_flag = 0x2 |
| 9 | const md_html_flag_debug = 0x0001 |
| 10 | const md_html_flag_verbatim_entities = 0x0002 |
| 11 | const md_html_flag_skip_utf8_bom = 0x0004 |
| 12 | |
| 13 | type ProcessFn = fn (const_t &char, s u32, x voidptr) |
| 14 | |
| 15 | fn write_data_cb(const_txt &char, size u32, userdata voidptr) { |
| 16 | s := unsafe { tos(&u8(const_txt), int(size)) } |
| 17 | mut sb := unsafe { &strings.Builder(userdata) } |
| 18 | sb.write_string(s) |
| 19 | } |
| 20 | |
| 21 | pub fn to_html(input string) string { |
| 22 | mut wr := strings.new_builder(200) |
| 23 | C.md_html(input.str, input.len, write_data_cb, &wr, C.MD_DIALECT_GITHUB, 0) |
| 24 | return wr.str().trim_space() |
| 25 | } |
| 26 | |