Logo

index : blog

---

  • summary
  • about
  • tree
  • log
  • branches
<< path: root/public/blog.git/html/modules/cmark-gfm/lib.jai blob: b2d4ea78fd74e71523b6fedcab5609e6895b121c [raw] [clear marker]

        
0CMARK :: #library "lib/libcmark-gfm";
1
2
3Cmark_Options :: enum #specified {
4 DEFAULT :: 0;
5
6 /** Include a `data-sourcepos` attribute on all block elements. */
7 SOURCEPOS :: 1 << 1;
8
9 /** Render `softbreak` elements as hard line breaks. */
10 HARDBREAKS :: 1 << 2;
11
12 /** `CMARK_OPT_SAFE` is defined here for API compatibility,
13 but it no longer has any effect. "Safe" mode is now the default:
14 set `CMARK_OPT_UNSAFE` to disable it.
15 */
16 SAFE :: 1 << 3;
17
18 /** Render raw HTML and unsafe links (`javascript:`, `vbscript:`,
19 * `file:`, and `data:`, except for `image/png`, `image/gif`,
20 * `image/jpeg`, or `image/webp` mime types). By default,
21 * raw HTML is replaced by a placeholder HTML comment. Unsafe
22 * links are replaced by empty strings.
23 */
24 UNSAFE :: 1 << 17;
25
26 /** Render `softbreak` elements as spaces. */
27 NOBREAKS :: 1 << 4;
28
29 /** Legacy option (no effect). */
30 NORMALIZE :: 1 << 8;
31
32 /** Validate UTF-8 in the input before parsing, replacing illegal
33 * sequences with the replacement character U+FFFD.
34 */
35 VALIDATE_UTF8 :: 1 << 9;
36
37 /** Convert straight quotes to curly, --- to em dashes, -- to en dashes. */
38 SMART :: 1 << 10;
39
40 /** Use GitHub-style <pre lang="x"> tags for code blocks instead of <pre><code
41 * class="language-x">.
42 */
43 GITHUB_PRE_LANG :: 1 << 11;
44
45 /** Be liberal in interpreting inline HTML tags. */
46 LIBERAL_HTML_TAG :: 1 << 12;
47
48 /** Parse footnotes. */
49 FOOTNOTES :: 1 << 13;
50
51 /** Only parse strikethroughs if surrounded by exactly 2 tildes.
52 * Gives some compatibility with redcarpet.
53 */
54 STRIKETHROUGH_DOUBLE_TIDLE :: 1 << 14;
55
56 /** Use style attributes to align table cells instead of align attributes. */
57 TABLE_PREFER_STYLE_ATTRIBUTES :: 1 << 15;
58
59 /** Include the remainder of the info string in code blocks in
60 * a separate attribute.
61 */
62 FULL_INFO_STRING :: 1 << 16;
63}
64
65
66markdown_to_html :: (s: string, options: Cmark_Options = .DEFAULT) -> string {
67 return to_string(cmark_markdown_to_html(to_c_string(s), s.count, xx options));
68}
69
70
71#scope_file
72
73
74#import "Basic";
75
76
77cmark_markdown_to_html :: (s: *u8, len: int, opt: int) -> *u8 #foreign CMARK;
78
79
Copyright 2026  E766CB298A6D1E64 | Git-Thing heavily inspired by cgit