@hongdown/wasm 0.2.0-dev.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.
@@ -0,0 +1,236 @@
1
+ //#region src/types.d.ts
2
+ /**
3
+ * Padding style for ordered list numbers.
4
+ *
5
+ * - `"start"`: Pad before the number (default): ` 1.`, ` 2.`, ..., ` 10.`
6
+ * - `"end"`: Pad after the number: `1. `, `2. `, ..., `10.`
7
+ */
8
+ type OrderedListPad = "start" | "end";
9
+ /**
10
+ * Dash transformation setting.
11
+ *
12
+ * - `false`: Disabled
13
+ * - `string`: Pattern to transform to the dash character
14
+ */
15
+ type DashSetting = false | string;
16
+ /**
17
+ * Formatting options for the Hongdown formatter.
18
+ *
19
+ * All options are optional. When not specified, default values are used.
20
+ */
21
+ interface FormatOptions {
22
+ /**
23
+ * Line width for wrapping.
24
+ * @default 80
25
+ */
26
+ lineWidth?: number;
27
+ /**
28
+ * Use setext-style (underlined) for h1 headings.
29
+ * @default true
30
+ */
31
+ setextH1?: boolean;
32
+ /**
33
+ * Use setext-style (underlined) for h2 headings.
34
+ * @default true
35
+ */
36
+ setextH2?: boolean;
37
+ /**
38
+ * Marker character for unordered lists: `"-"`, `"*"`, or `"+"`.
39
+ * @default "-"
40
+ */
41
+ unorderedMarker?: string;
42
+ /**
43
+ * Number of leading spaces before the list marker.
44
+ * @default 1
45
+ */
46
+ leadingSpaces?: number;
47
+ /**
48
+ * Number of trailing spaces after the list marker.
49
+ * @default 2
50
+ */
51
+ trailingSpaces?: number;
52
+ /**
53
+ * Indentation width for nested list items.
54
+ * @default 4
55
+ */
56
+ indentWidth?: number;
57
+ /**
58
+ * Marker style for ordered lists at odd nesting levels.
59
+ * Use `"."` for `1.` or `")"` for `1)`.
60
+ * @default "."
61
+ */
62
+ oddLevelMarker?: string;
63
+ /**
64
+ * Marker style for ordered lists at even nesting levels.
65
+ * Use `"."` for `1.` or `")"` for `1)`.
66
+ * @default ")"
67
+ */
68
+ evenLevelMarker?: string;
69
+ /**
70
+ * Padding style for ordered list numbers.
71
+ * @default "start"
72
+ */
73
+ orderedListPad?: OrderedListPad;
74
+ /**
75
+ * Indentation width for nested ordered list items.
76
+ * @default 4
77
+ */
78
+ orderedListIndentWidth?: number;
79
+ /**
80
+ * Fence character for code blocks: `"~"` or `` "`" ``.
81
+ * @default "~"
82
+ */
83
+ fenceChar?: string;
84
+ /**
85
+ * Minimum fence length for code blocks.
86
+ * @default 4
87
+ */
88
+ minFenceLength?: number;
89
+ /**
90
+ * Add space between fence and language identifier.
91
+ * @default true
92
+ */
93
+ spaceAfterFence?: boolean;
94
+ /**
95
+ * Default language identifier for code blocks without one.
96
+ * When empty, code blocks without a language identifier remain without one.
97
+ * @default ""
98
+ */
99
+ defaultLanguage?: string;
100
+ /**
101
+ * The style string for thematic breaks.
102
+ * @default "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
103
+ */
104
+ thematicBreakStyle?: string;
105
+ /**
106
+ * Number of leading spaces before thematic breaks (0-3).
107
+ * @default 3
108
+ */
109
+ thematicBreakLeadingSpaces?: number;
110
+ /**
111
+ * Convert straight double quotes to curly quotes.
112
+ * `"text"` becomes `"text"` (U+201C and U+201D).
113
+ * @default true
114
+ */
115
+ curlyDoubleQuotes?: boolean;
116
+ /**
117
+ * Convert straight single quotes to curly quotes.
118
+ * `'text'` becomes `'text'` (U+2018 and U+2019).
119
+ * @default true
120
+ */
121
+ curlySingleQuotes?: boolean;
122
+ /**
123
+ * Convert straight apostrophes to curly apostrophes.
124
+ * `it's` becomes `it's` (U+2019).
125
+ * @default false
126
+ */
127
+ curlyApostrophes?: boolean;
128
+ /**
129
+ * Convert three dots to ellipsis character.
130
+ * `...` becomes `…` (U+2026).
131
+ * @default true
132
+ */
133
+ ellipsis?: boolean;
134
+ /**
135
+ * Convert a pattern to en-dash.
136
+ * Set to a string like `"--"` to enable.
137
+ * The pattern is replaced with `–` (U+2013).
138
+ * @default false
139
+ */
140
+ enDash?: DashSetting;
141
+ /**
142
+ * Convert a pattern to em-dash.
143
+ * Set to `false` to disable, or a string like `"---"` for a different pattern.
144
+ * The pattern is replaced with `—` (U+2014).
145
+ * @default "--"
146
+ */
147
+ emDash?: DashSetting;
148
+ }
149
+ /**
150
+ * A warning generated during formatting.
151
+ */
152
+ interface Warning {
153
+ /**
154
+ * Line number where the warning was generated (1-indexed).
155
+ */
156
+ line: number;
157
+ /**
158
+ * Warning message.
159
+ */
160
+ message: string;
161
+ }
162
+ /**
163
+ * Result of formatting with warnings.
164
+ */
165
+ interface FormatResult {
166
+ /**
167
+ * The formatted Markdown output.
168
+ */
169
+ output: string;
170
+ /**
171
+ * Warnings generated during formatting.
172
+ */
173
+ warnings: Warning[];
174
+ }
175
+ //#endregion
176
+ //#region src/index.d.ts
177
+
178
+ /**
179
+ * Format Markdown according to Hong Minhee's style conventions.
180
+ *
181
+ * This function supports formatting directives embedded in HTML comments:
182
+ *
183
+ * - `<!-- hongdown-disable-file -->` - Disable formatting for the entire file.
184
+ * - `<!-- hongdown-disable-next-line -->` - Disable formatting for the next block.
185
+ * - `<!-- hongdown-disable-next-section -->` - Disable formatting until the next
186
+ * section heading.
187
+ * - `<!-- hongdown-disable -->` - Disable formatting from this point.
188
+ * - `<!-- hongdown-enable -->` - Re-enable formatting.
189
+ *
190
+ * @param input - Markdown source to format
191
+ * @param options - Formatting options (all optional)
192
+ * @returns The formatted Markdown string
193
+ *
194
+ * @example
195
+ * ```typescript
196
+ * import { format } from "@hongdown/wasm";
197
+ *
198
+ * // Basic usage
199
+ * const result = await format("# Hello\nWorld");
200
+ *
201
+ * // With options
202
+ * const result = await format(markdown, {
203
+ * lineWidth: 100,
204
+ * setextH1: false,
205
+ * fenceChar: "`",
206
+ * });
207
+ * ```
208
+ */
209
+ declare function format(input: string, options?: FormatOptions): Promise<string>;
210
+ /**
211
+ * Format Markdown and return both output and warnings.
212
+ *
213
+ * This is similar to {@link format}, but also returns any warnings generated
214
+ * during formatting (e.g., inconsistent table column counts).
215
+ *
216
+ * @param input - Markdown source to format
217
+ * @param options - Formatting options (all optional)
218
+ * @returns Object with formatted output and any warnings
219
+ *
220
+ * @example
221
+ * ```typescript
222
+ * import { formatWithWarnings } from "@hongdown/wasm";
223
+ *
224
+ * const { output, warnings } = await formatWithWarnings(markdown);
225
+ *
226
+ * if (warnings.length > 0) {
227
+ * for (const warning of warnings) {
228
+ * console.warn(`Line ${warning.line}: ${warning.message}`);
229
+ * }
230
+ * }
231
+ * ```
232
+ */
233
+ declare function formatWithWarnings(input: string, options?: FormatOptions): Promise<FormatResult>;
234
+ //#endregion
235
+ export { type DashSetting, type FormatOptions, type FormatResult, type OrderedListPad, type Warning, format, formatWithWarnings };
236
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/types.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;AAMA;AAQA;AAOA;;;AAoJW,KAnKC,cAAA,GAmKD,OAAA,GAAA,KAAA;;AAMX;AAeA;;;;AClHsB,KD9DV,WAAA,GCgED,KAAA,GAAA,MACR;AA4BH;;;;;UDtFiB,aAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA6DE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA+ER;;;;;;;WAQA;;;;;UAMM,OAAA;;;;;;;;;;;;;UAeA,YAAA;;;;;;;;YASL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBC3HU,MAAA,0BAEX,gBACR;;;;;;;;;;;;;;;;;;;;;;;;iBA4BmB,kBAAA,0BAEX,gBACR,QAAQ"}
@@ -0,0 +1,236 @@
1
+ //#region src/types.d.ts
2
+ /**
3
+ * Padding style for ordered list numbers.
4
+ *
5
+ * - `"start"`: Pad before the number (default): ` 1.`, ` 2.`, ..., ` 10.`
6
+ * - `"end"`: Pad after the number: `1. `, `2. `, ..., `10.`
7
+ */
8
+ type OrderedListPad = "start" | "end";
9
+ /**
10
+ * Dash transformation setting.
11
+ *
12
+ * - `false`: Disabled
13
+ * - `string`: Pattern to transform to the dash character
14
+ */
15
+ type DashSetting = false | string;
16
+ /**
17
+ * Formatting options for the Hongdown formatter.
18
+ *
19
+ * All options are optional. When not specified, default values are used.
20
+ */
21
+ interface FormatOptions {
22
+ /**
23
+ * Line width for wrapping.
24
+ * @default 80
25
+ */
26
+ lineWidth?: number;
27
+ /**
28
+ * Use setext-style (underlined) for h1 headings.
29
+ * @default true
30
+ */
31
+ setextH1?: boolean;
32
+ /**
33
+ * Use setext-style (underlined) for h2 headings.
34
+ * @default true
35
+ */
36
+ setextH2?: boolean;
37
+ /**
38
+ * Marker character for unordered lists: `"-"`, `"*"`, or `"+"`.
39
+ * @default "-"
40
+ */
41
+ unorderedMarker?: string;
42
+ /**
43
+ * Number of leading spaces before the list marker.
44
+ * @default 1
45
+ */
46
+ leadingSpaces?: number;
47
+ /**
48
+ * Number of trailing spaces after the list marker.
49
+ * @default 2
50
+ */
51
+ trailingSpaces?: number;
52
+ /**
53
+ * Indentation width for nested list items.
54
+ * @default 4
55
+ */
56
+ indentWidth?: number;
57
+ /**
58
+ * Marker style for ordered lists at odd nesting levels.
59
+ * Use `"."` for `1.` or `")"` for `1)`.
60
+ * @default "."
61
+ */
62
+ oddLevelMarker?: string;
63
+ /**
64
+ * Marker style for ordered lists at even nesting levels.
65
+ * Use `"."` for `1.` or `")"` for `1)`.
66
+ * @default ")"
67
+ */
68
+ evenLevelMarker?: string;
69
+ /**
70
+ * Padding style for ordered list numbers.
71
+ * @default "start"
72
+ */
73
+ orderedListPad?: OrderedListPad;
74
+ /**
75
+ * Indentation width for nested ordered list items.
76
+ * @default 4
77
+ */
78
+ orderedListIndentWidth?: number;
79
+ /**
80
+ * Fence character for code blocks: `"~"` or `` "`" ``.
81
+ * @default "~"
82
+ */
83
+ fenceChar?: string;
84
+ /**
85
+ * Minimum fence length for code blocks.
86
+ * @default 4
87
+ */
88
+ minFenceLength?: number;
89
+ /**
90
+ * Add space between fence and language identifier.
91
+ * @default true
92
+ */
93
+ spaceAfterFence?: boolean;
94
+ /**
95
+ * Default language identifier for code blocks without one.
96
+ * When empty, code blocks without a language identifier remain without one.
97
+ * @default ""
98
+ */
99
+ defaultLanguage?: string;
100
+ /**
101
+ * The style string for thematic breaks.
102
+ * @default "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
103
+ */
104
+ thematicBreakStyle?: string;
105
+ /**
106
+ * Number of leading spaces before thematic breaks (0-3).
107
+ * @default 3
108
+ */
109
+ thematicBreakLeadingSpaces?: number;
110
+ /**
111
+ * Convert straight double quotes to curly quotes.
112
+ * `"text"` becomes `"text"` (U+201C and U+201D).
113
+ * @default true
114
+ */
115
+ curlyDoubleQuotes?: boolean;
116
+ /**
117
+ * Convert straight single quotes to curly quotes.
118
+ * `'text'` becomes `'text'` (U+2018 and U+2019).
119
+ * @default true
120
+ */
121
+ curlySingleQuotes?: boolean;
122
+ /**
123
+ * Convert straight apostrophes to curly apostrophes.
124
+ * `it's` becomes `it's` (U+2019).
125
+ * @default false
126
+ */
127
+ curlyApostrophes?: boolean;
128
+ /**
129
+ * Convert three dots to ellipsis character.
130
+ * `...` becomes `…` (U+2026).
131
+ * @default true
132
+ */
133
+ ellipsis?: boolean;
134
+ /**
135
+ * Convert a pattern to en-dash.
136
+ * Set to a string like `"--"` to enable.
137
+ * The pattern is replaced with `–` (U+2013).
138
+ * @default false
139
+ */
140
+ enDash?: DashSetting;
141
+ /**
142
+ * Convert a pattern to em-dash.
143
+ * Set to `false` to disable, or a string like `"---"` for a different pattern.
144
+ * The pattern is replaced with `—` (U+2014).
145
+ * @default "--"
146
+ */
147
+ emDash?: DashSetting;
148
+ }
149
+ /**
150
+ * A warning generated during formatting.
151
+ */
152
+ interface Warning {
153
+ /**
154
+ * Line number where the warning was generated (1-indexed).
155
+ */
156
+ line: number;
157
+ /**
158
+ * Warning message.
159
+ */
160
+ message: string;
161
+ }
162
+ /**
163
+ * Result of formatting with warnings.
164
+ */
165
+ interface FormatResult {
166
+ /**
167
+ * The formatted Markdown output.
168
+ */
169
+ output: string;
170
+ /**
171
+ * Warnings generated during formatting.
172
+ */
173
+ warnings: Warning[];
174
+ }
175
+ //#endregion
176
+ //#region src/index.d.ts
177
+
178
+ /**
179
+ * Format Markdown according to Hong Minhee's style conventions.
180
+ *
181
+ * This function supports formatting directives embedded in HTML comments:
182
+ *
183
+ * - `<!-- hongdown-disable-file -->` - Disable formatting for the entire file.
184
+ * - `<!-- hongdown-disable-next-line -->` - Disable formatting for the next block.
185
+ * - `<!-- hongdown-disable-next-section -->` - Disable formatting until the next
186
+ * section heading.
187
+ * - `<!-- hongdown-disable -->` - Disable formatting from this point.
188
+ * - `<!-- hongdown-enable -->` - Re-enable formatting.
189
+ *
190
+ * @param input - Markdown source to format
191
+ * @param options - Formatting options (all optional)
192
+ * @returns The formatted Markdown string
193
+ *
194
+ * @example
195
+ * ```typescript
196
+ * import { format } from "@hongdown/wasm";
197
+ *
198
+ * // Basic usage
199
+ * const result = await format("# Hello\nWorld");
200
+ *
201
+ * // With options
202
+ * const result = await format(markdown, {
203
+ * lineWidth: 100,
204
+ * setextH1: false,
205
+ * fenceChar: "`",
206
+ * });
207
+ * ```
208
+ */
209
+ declare function format(input: string, options?: FormatOptions): Promise<string>;
210
+ /**
211
+ * Format Markdown and return both output and warnings.
212
+ *
213
+ * This is similar to {@link format}, but also returns any warnings generated
214
+ * during formatting (e.g., inconsistent table column counts).
215
+ *
216
+ * @param input - Markdown source to format
217
+ * @param options - Formatting options (all optional)
218
+ * @returns Object with formatted output and any warnings
219
+ *
220
+ * @example
221
+ * ```typescript
222
+ * import { formatWithWarnings } from "@hongdown/wasm";
223
+ *
224
+ * const { output, warnings } = await formatWithWarnings(markdown);
225
+ *
226
+ * if (warnings.length > 0) {
227
+ * for (const warning of warnings) {
228
+ * console.warn(`Line ${warning.line}: ${warning.message}`);
229
+ * }
230
+ * }
231
+ * ```
232
+ */
233
+ declare function formatWithWarnings(input: string, options?: FormatOptions): Promise<FormatResult>;
234
+ //#endregion
235
+ export { type DashSetting, type FormatOptions, type FormatResult, type OrderedListPad, type Warning, format, formatWithWarnings };
236
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;AAMA;AAQA;AAOA;;;AAoJW,KAnKC,cAAA,GAmKD,OAAA,GAAA,KAAA;;AAMX;AAeA;;;;AClHsB,KD9DV,WAAA,GCgED,KAAA,GAAA,MACR;AA4BH;;;;;UDtFiB,aAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA6DE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WA+ER;;;;;;;WAQA;;;;;UAMM,OAAA;;;;;;;;;;;;;UAeA,YAAA;;;;;;;;YASL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBC3HU,MAAA,0BAEX,gBACR;;;;;;;;;;;;;;;;;;;;;;;;iBA4BmB,kBAAA,0BAEX,gBACR,QAAQ"}