ironmark 1.8.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,3 +4,18 @@
4
4
  export function parse(markdown: string, hard_breaks?: boolean | null, enable_highlight?: boolean | null, enable_strikethrough?: boolean | null, enable_underline?: boolean | null, enable_tables?: boolean | null, enable_autolink?: boolean | null, enable_task_lists?: boolean | null, disable_raw_html?: boolean | null, enable_heading_ids?: boolean | null, enable_heading_anchors?: boolean | null, enable_indented_code_blocks?: boolean | null, no_html_blocks?: boolean | null, no_html_spans?: boolean | null, tag_filter?: boolean | null, collapse_whitespace?: boolean | null, permissive_atx_headers?: boolean | null, enable_wiki_links?: boolean | null, enable_latex_math?: boolean | null): string;
5
5
 
6
6
  export function parseToAst(markdown: string, hard_breaks?: boolean | null, enable_highlight?: boolean | null, enable_strikethrough?: boolean | null, enable_underline?: boolean | null, enable_tables?: boolean | null, enable_autolink?: boolean | null, enable_task_lists?: boolean | null, disable_raw_html?: boolean | null, enable_heading_ids?: boolean | null, enable_heading_anchors?: boolean | null, enable_indented_code_blocks?: boolean | null, no_html_blocks?: boolean | null, no_html_spans?: boolean | null, tag_filter?: boolean | null, collapse_whitespace?: boolean | null, permissive_atx_headers?: boolean | null, enable_wiki_links?: boolean | null, enable_latex_math?: boolean | null): string;
7
+
8
+ /**
9
+ * Render Markdown as ANSI-coloured terminal output.
10
+ *
11
+ * Produces a string containing ANSI 256-colour escape codes suitable for
12
+ * display in a terminal emulator. Use `color: false` to get plain text
13
+ * (all ANSI codes stripped).
14
+ *
15
+ * @param markdown - Markdown source string.
16
+ * @param options - Optional parse options (same as `parse()`).
17
+ * @param width - Terminal column width for word-wrap and underlines (default: 80, 0 = use default).
18
+ * @param color - Emit ANSI colour codes (default: true).
19
+ * @param lineNumbers - Show line numbers in fenced code blocks (default: false).
20
+ */
21
+ export function renderAnsi(markdown: string, hard_breaks: boolean | null | undefined, enable_highlight: boolean | null | undefined, enable_strikethrough: boolean | null | undefined, enable_underline: boolean | null | undefined, enable_tables: boolean | null | undefined, enable_autolink: boolean | null | undefined, enable_task_lists: boolean | null | undefined, disable_raw_html: boolean | null | undefined, enable_heading_ids: boolean | null | undefined, enable_heading_anchors: boolean | null | undefined, enable_indented_code_blocks: boolean | null | undefined, no_html_blocks: boolean | null | undefined, no_html_spans: boolean | null | undefined, tag_filter: boolean | null | undefined, collapse_whitespace: boolean | null | undefined, permissive_atx_headers: boolean | null | undefined, enable_wiki_links: boolean | null | undefined, enable_latex_math: boolean | null | undefined, width: number, color?: boolean | null, line_numbers?: boolean | null): string;
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./ironmark_bg.js";
5
5
  __wbg_set_wasm(wasm);
6
6
 
7
7
  export {
8
- parse, parseToAst
8
+ parse, parseToAst, renderAnsi
9
9
  } from "./ironmark_bg.js";
@@ -87,6 +87,61 @@ export function parseToAst(markdown, hard_breaks, enable_highlight, enable_strik
87
87
  wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
88
88
  }
89
89
  }
90
+
91
+ /**
92
+ * Render Markdown as ANSI-coloured terminal output.
93
+ *
94
+ * Produces a string containing ANSI 256-colour escape codes suitable for
95
+ * display in a terminal emulator. Use `color: false` to get plain text
96
+ * (all ANSI codes stripped).
97
+ *
98
+ * @param markdown - Markdown source string.
99
+ * @param options - Optional parse options (same as `parse()`).
100
+ * @param width - Terminal column width for word-wrap and underlines (default: 80, 0 = use default).
101
+ * @param color - Emit ANSI colour codes (default: true).
102
+ * @param lineNumbers - Show line numbers in fenced code blocks (default: false).
103
+ * @param {string} markdown
104
+ * @param {boolean | null | undefined} hard_breaks
105
+ * @param {boolean | null | undefined} enable_highlight
106
+ * @param {boolean | null | undefined} enable_strikethrough
107
+ * @param {boolean | null | undefined} enable_underline
108
+ * @param {boolean | null | undefined} enable_tables
109
+ * @param {boolean | null | undefined} enable_autolink
110
+ * @param {boolean | null | undefined} enable_task_lists
111
+ * @param {boolean | null | undefined} disable_raw_html
112
+ * @param {boolean | null | undefined} enable_heading_ids
113
+ * @param {boolean | null | undefined} enable_heading_anchors
114
+ * @param {boolean | null | undefined} enable_indented_code_blocks
115
+ * @param {boolean | null | undefined} no_html_blocks
116
+ * @param {boolean | null | undefined} no_html_spans
117
+ * @param {boolean | null | undefined} tag_filter
118
+ * @param {boolean | null | undefined} collapse_whitespace
119
+ * @param {boolean | null | undefined} permissive_atx_headers
120
+ * @param {boolean | null | undefined} enable_wiki_links
121
+ * @param {boolean | null | undefined} enable_latex_math
122
+ * @param {number} width
123
+ * @param {boolean | null} [color]
124
+ * @param {boolean | null} [line_numbers]
125
+ * @returns {string}
126
+ */
127
+ export function renderAnsi(markdown, hard_breaks, enable_highlight, enable_strikethrough, enable_underline, enable_tables, enable_autolink, enable_task_lists, disable_raw_html, enable_heading_ids, enable_heading_anchors, enable_indented_code_blocks, no_html_blocks, no_html_spans, tag_filter, collapse_whitespace, permissive_atx_headers, enable_wiki_links, enable_latex_math, width, color, line_numbers) {
128
+ let deferred2_0;
129
+ let deferred2_1;
130
+ try {
131
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
132
+ const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
133
+ const len0 = WASM_VECTOR_LEN;
134
+ wasm.renderAnsi(retptr, ptr0, len0, isLikeNone(hard_breaks) ? 0xFFFFFF : hard_breaks ? 1 : 0, isLikeNone(enable_highlight) ? 0xFFFFFF : enable_highlight ? 1 : 0, isLikeNone(enable_strikethrough) ? 0xFFFFFF : enable_strikethrough ? 1 : 0, isLikeNone(enable_underline) ? 0xFFFFFF : enable_underline ? 1 : 0, isLikeNone(enable_tables) ? 0xFFFFFF : enable_tables ? 1 : 0, isLikeNone(enable_autolink) ? 0xFFFFFF : enable_autolink ? 1 : 0, isLikeNone(enable_task_lists) ? 0xFFFFFF : enable_task_lists ? 1 : 0, isLikeNone(disable_raw_html) ? 0xFFFFFF : disable_raw_html ? 1 : 0, isLikeNone(enable_heading_ids) ? 0xFFFFFF : enable_heading_ids ? 1 : 0, isLikeNone(enable_heading_anchors) ? 0xFFFFFF : enable_heading_anchors ? 1 : 0, isLikeNone(enable_indented_code_blocks) ? 0xFFFFFF : enable_indented_code_blocks ? 1 : 0, isLikeNone(no_html_blocks) ? 0xFFFFFF : no_html_blocks ? 1 : 0, isLikeNone(no_html_spans) ? 0xFFFFFF : no_html_spans ? 1 : 0, isLikeNone(tag_filter) ? 0xFFFFFF : tag_filter ? 1 : 0, isLikeNone(collapse_whitespace) ? 0xFFFFFF : collapse_whitespace ? 1 : 0, isLikeNone(permissive_atx_headers) ? 0xFFFFFF : permissive_atx_headers ? 1 : 0, isLikeNone(enable_wiki_links) ? 0xFFFFFF : enable_wiki_links ? 1 : 0, isLikeNone(enable_latex_math) ? 0xFFFFFF : enable_latex_math ? 1 : 0, width, isLikeNone(color) ? 0xFFFFFF : color ? 1 : 0, isLikeNone(line_numbers) ? 0xFFFFFF : line_numbers ? 1 : 0);
135
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
136
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
137
+ deferred2_0 = r0;
138
+ deferred2_1 = r1;
139
+ return getStringFromWasm0(r0, r1);
140
+ } finally {
141
+ wasm.__wbindgen_add_to_stack_pointer(16);
142
+ wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
143
+ }
144
+ }
90
145
  export function __wbindgen_cast_0000000000000001(arg0, arg1) {
91
146
  // Cast intrinsic for `Ref(String) -> Externref`.
92
147
  const ret = getStringFromWasm0(arg0, arg1);
Binary file
@@ -3,6 +3,7 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const parse: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number) => void;
5
5
  export const parseToAst: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number) => void;
6
+ export const renderAnsi: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number, v: number, w: number, x: number) => void;
6
7
  export const ironmark_free: (a: number) => void;
7
8
  export const ironmark_parse: (a: number) => number;
8
9
  export const __wbindgen_add_to_stack_pointer: (a: number) => number;
package/wasm/shared.js CHANGED
@@ -14,24 +14,24 @@ function toStr(markdown) {
14
14
  function optionArgs(markdown, options) {
15
15
  return [
16
16
  toStr(markdown),
17
- options?.hardBreaks ?? undefined,
18
- options?.enableHighlight ?? undefined,
19
- options?.enableStrikethrough ?? undefined,
20
- options?.enableUnderline ?? undefined,
21
- options?.enableTables ?? undefined,
22
- options?.enableAutolink ?? undefined,
23
- options?.enableTaskLists ?? undefined,
24
- options?.disableRawHtml ?? undefined,
25
- options?.enableHeadingIds ?? undefined,
26
- options?.enableHeadingAnchors ?? undefined,
27
- options?.enableIndentedCodeBlocks ?? undefined,
28
- options?.noHtmlBlocks ?? undefined,
29
- options?.noHtmlSpans ?? undefined,
30
- options?.tagFilter ?? undefined,
31
- options?.collapseWhitespace ?? undefined,
32
- options?.permissiveAtxHeaders ?? undefined,
33
- options?.enableWikiLinks ?? undefined,
34
- options?.enableLatexMath ?? undefined,
17
+ options?.hardBreaks,
18
+ options?.enableHighlight,
19
+ options?.enableStrikethrough,
20
+ options?.enableUnderline,
21
+ options?.enableTables,
22
+ options?.enableAutolink,
23
+ options?.enableTaskLists,
24
+ options?.disableRawHtml,
25
+ options?.enableHeadingIds,
26
+ options?.enableHeadingAnchors,
27
+ options?.enableIndentedCodeBlocks,
28
+ options?.noHtmlBlocks,
29
+ options?.noHtmlSpans,
30
+ options?.tagFilter,
31
+ options?.collapseWhitespace,
32
+ options?.permissiveAtxHeaders,
33
+ options?.enableWikiLinks,
34
+ options?.enableLatexMath,
35
35
  ];
36
36
  }
37
37
 
@@ -46,3 +46,15 @@ export function createParseToAst(wasmParseToAst) {
46
46
  return wasmParseToAst(...optionArgs(markdown, options));
47
47
  };
48
48
  }
49
+
50
+ export function createRenderAnsi(wasmRenderAnsi) {
51
+ return function renderAnsi(markdown, options) {
52
+ return wasmRenderAnsi(
53
+ ...optionArgs(markdown, options),
54
+ // width is plain u32 (not Option): 0 = use default (80)
55
+ options?.width ?? 0,
56
+ options?.color,
57
+ options?.lineNumbers,
58
+ );
59
+ };
60
+ }
package/wasm/web.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as wasmGlue from "./pkg/ironmark_bg.js";
2
- import { createParse, createParseToAst } from "./shared.js";
2
+ import { createParse, createParseToAst, createRenderAnsi } from "./shared.js";
3
3
 
4
4
  let initialized = false;
5
5
 
@@ -29,3 +29,4 @@ export async function init(input) {
29
29
 
30
30
  export const parse = createParse(wasmGlue.parse);
31
31
  export const parseToAst = createParseToAst(wasmGlue.parseToAst);
32
+ export const renderAnsi = createRenderAnsi(wasmGlue.renderAnsi);