@markitdownjs/html 0.1.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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=html-converter.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-converter.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/html-converter.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,44 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { HtmlConverter } from '../html-converter.js';
3
+ describe('HtmlConverter', () => {
4
+ const converter = new HtmlConverter();
5
+ it('should convert HTML headings', async () => {
6
+ const result = await converter.convert({
7
+ data: '<html><body><h1>Title</h1><h2>Subtitle</h2></body></html>',
8
+ mimeType: 'text/html',
9
+ });
10
+ expect(result.markdown).toContain('# Title');
11
+ expect(result.markdown).toContain('## Subtitle');
12
+ });
13
+ it('should convert HTML tables', async () => {
14
+ const result = await converter.convert({
15
+ data: '<html><body><table><tr><th>Name</th><th>Age</th></tr><tr><td>John</td><td>30</td></tr></table></body></html>',
16
+ mimeType: 'text/html',
17
+ });
18
+ expect(result.markdown).toContain('| Name |');
19
+ expect(result.markdown).toContain('| John |');
20
+ });
21
+ it('should convert HTML lists', async () => {
22
+ const result = await converter.convert({
23
+ data: '<html><body><ul><li>Item 1</li><li>Item 2</li></ul></body></html>',
24
+ mimeType: 'text/html',
25
+ });
26
+ expect(result.markdown).toContain('Item 1');
27
+ expect(result.markdown).toContain('Item 2');
28
+ });
29
+ it('should convert links', async () => {
30
+ const result = await converter.convert({
31
+ data: '<html><body><a href="https://example.com">Example</a></body></html>',
32
+ mimeType: 'text/html',
33
+ });
34
+ expect(result.markdown).toContain('[Example](https://example.com)');
35
+ });
36
+ it('should produce AST', async () => {
37
+ const result = await converter.convert({
38
+ data: '<html><body><p>Hello</p></body></html>',
39
+ mimeType: 'text/html',
40
+ });
41
+ expect(result.ast).toBeDefined();
42
+ });
43
+ });
44
+ //# sourceMappingURL=html-converter.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-converter.test.js","sourceRoot":"","sources":["../../src/__tests__/html-converter.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,MAAM,SAAS,GAAG,IAAI,aAAa,EAAE,CAAC;IAEtC,EAAE,CAAC,8BAA8B,EAAE,KAAK,IAAI,EAAE;QAC5C,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC;YACrC,IAAI,EAAE,2DAA2D;YACjE,QAAQ,EAAE,WAAW;SACtB,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC7C,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;QAC1C,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC;YACrC,IAAI,EAAE,8GAA8G;YACpH,QAAQ,EAAE,WAAW;SACtB,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QAC9C,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2BAA2B,EAAE,KAAK,IAAI,EAAE;QACzC,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC;YACrC,IAAI,EAAE,mEAAmE;YACzE,QAAQ,EAAE,WAAW;SACtB,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAC5C,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE;QACpC,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC;YACrC,IAAI,EAAE,qEAAqE;YAC3E,QAAQ,EAAE,WAAW;SACtB,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC,gCAAgC,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oBAAoB,EAAE,KAAK,IAAI,EAAE;QAClC,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC;YACrC,IAAI,EAAE,wCAAwC;YAC9C,QAAQ,EAAE,WAAW;SACtB,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,279 @@
1
+ import type { Converter, ConversionInput, ConversionResult } from "@markitdownjs/shared";
2
+ /**
3
+ * Converts an HTML document (string, Uint8Array, Blob, or ArrayBuffer)
4
+ * into a structured AST and Markdown output.
5
+ *
6
+ * Features:
7
+ * - Full DOM traversal with position tracking
8
+ * - Support for headings, paragraphs, tables (caption/thead/tbody/tfoot),
9
+ * lists, links, images, code blocks, blockquotes, and inline formatting
10
+ * - `<details>/<summary>`, `<video>/<audio>` metadata, `<iframe>` as links
11
+ * - `<sup>`, `<sub>`, `<del>/<s>`, `<mark>`, `<u>` inline formatting
12
+ * - Footnote extraction from `<aside>` or footnote-like class/id elements
13
+ * - Numeric node type constants (3=TEXT, 8=COMMENT) for Node.js compatibility
14
+ */
15
+ export declare class HtmlConverter implements Converter {
16
+ readonly id: "html";
17
+ readonly supportedMimeTypes: string[];
18
+ readonly supportedExtensions: string[];
19
+ /** Checks whether this converter can handle the given input. */
20
+ canConvert(input: ConversionInput): Promise<boolean>;
21
+ /**
22
+ * Converts HTML input into a ConversionResult containing the AST, Markdown, and metadata.
23
+ *
24
+ * @param input - The HTML content to convert (string, Uint8Array, Blob, or ArrayBuffer)
25
+ * @returns A ConversionResult with the document AST, rendered Markdown, and extracted metadata
26
+ */
27
+ convert(input: ConversionInput): Promise<ConversionResult>;
28
+ /**
29
+ * Reads the input data as a UTF-8 string.
30
+ *
31
+ * @param input - The conversion input to read
32
+ * @returns The decoded string content
33
+ */
34
+ private readString;
35
+ /**
36
+ * Extracts the file extension (lowercased, with leading dot) from a filename.
37
+ *
38
+ * @param fileName - The filename to extract the extension from
39
+ * @returns The lowercased extension including the dot, or empty string if none
40
+ */
41
+ private getExtension;
42
+ /**
43
+ * Processes an array of child DOM nodes into AST nodes.
44
+ * Skips null results (whitespace-only text nodes, comments).
45
+ *
46
+ * @param nodes - The DOM child nodes to process
47
+ * @returns An array of non-null AST nodes
48
+ */
49
+ private processChildren;
50
+ /**
51
+ * Processes a single DOM node into an AST node or array of AST nodes.
52
+ * Uses numeric constants (3 for TEXT_NODE, 8 for COMMENT_NODE) for Node.js compatibility.
53
+ *
54
+ * @param node - The DOM node to process
55
+ * @returns The corresponding AST node(s), or null if the node should be skipped
56
+ */
57
+ private processNode;
58
+ /**
59
+ * Processes a heading element (h1-h6) into a HeadingNode.
60
+ * Extracts the `id` attribute if present for anchor linking.
61
+ *
62
+ * @param el - The heading DOM element
63
+ * @param level - The heading level (1-6)
64
+ * @returns A HeadingNode with the appropriate level and children
65
+ */
66
+ private processHeading;
67
+ /**
68
+ * Processes a paragraph element into a ParagraphNode.
69
+ *
70
+ * @param el - The paragraph DOM element
71
+ * @returns A ParagraphNode with the processed child content
72
+ */
73
+ private processParagraph;
74
+ /**
75
+ * Processes a table element into a TableNode.
76
+ * Properly handles `<caption>`, `<thead>`, `<tbody>`, and `<tfoot>` sections.
77
+ * Preserves row order: thead rows first, then tbody rows, then tfoot rows.
78
+ * Falls back to querying all `<tr>` elements if no section elements exist.
79
+ *
80
+ * @param el - The table DOM element
81
+ * @returns A TableNode with properly ordered rows and optional caption
82
+ */
83
+ private processTable;
84
+ /**
85
+ * Processes a single table row (`<tr>`) element into a TableRowNode.
86
+ *
87
+ * @param tr - The table row DOM element
88
+ * @returns A TableRowNode with cells and isHeader flag
89
+ */
90
+ private processTableRow;
91
+ /**
92
+ * Processes a list element (`<ul>` or `<ol>`) into a ListNode.
93
+ * Handles nested lists and the `start` attribute for ordered lists.
94
+ *
95
+ * @param el - The list DOM element
96
+ * @param ordered - Whether this is an ordered list
97
+ * @returns A ListNode with processed list items
98
+ */
99
+ private processList;
100
+ /**
101
+ * Processes an anchor (`<a>`) element into a LinkNode.
102
+ * Filters out `javascript:` hrefs for safety.
103
+ *
104
+ * @param el - The anchor DOM element
105
+ * @returns A LinkNode with the href, optional title, and children
106
+ */
107
+ private processLink;
108
+ /**
109
+ * Processes an image (`<img>`) element into an ImageNode.
110
+ * Extracts src, alt, title, width, and height attributes.
111
+ *
112
+ * @param el - The image DOM element
113
+ * @returns An ImageNode with the image metadata
114
+ */
115
+ private processImage;
116
+ /**
117
+ * Processes a preformatted (`<pre>`) element into a CodeNode.
118
+ * Detects language from CSS class (e.g., `language-typescript`).
119
+ * Falls back to the `<code>` element if present.
120
+ *
121
+ * @param el - The preformatted DOM element
122
+ * @returns A CodeNode with the code value and optional language
123
+ */
124
+ private processPreformatted;
125
+ /**
126
+ * Processes a `<strong>` or `<b>` element into a StrongNode.
127
+ *
128
+ * @param el - The strong/bold DOM element
129
+ * @returns A StrongNode with the child content
130
+ */
131
+ private processStrong;
132
+ /**
133
+ * Processes an `<em>` or `<i>` element into an EmphasisNode.
134
+ *
135
+ * @param el - The emphasis/italic DOM element
136
+ * @returns An EmphasisNode with the child content
137
+ */
138
+ private processEmphasis;
139
+ /**
140
+ * Processes a `<u>` element into a StrongNode with underline semantics.
141
+ * Markdown doesn't have native underline; we use `<u>` HTML inline instead.
142
+ *
143
+ * @param el - The underline DOM element
144
+ * @returns An HtmlNode wrapping the content as `<u>...</u>`
145
+ */
146
+ private processUnderline;
147
+ /**
148
+ * Processes a `<del>` or `<s>` element into a StrikethroughNode.
149
+ *
150
+ * @param el - The strikethrough DOM element
151
+ * @returns A StrikethroughNode with the child content
152
+ */
153
+ private processStrikethrough;
154
+ /**
155
+ * Processes a `<sub>` element into a SubscriptNode.
156
+ * Uses `type: "subscript"` from the AST.
157
+ *
158
+ * @param el - The subscript DOM element
159
+ * @returns A DocumentNode with type "subscript"
160
+ */
161
+ private processSubscript;
162
+ /**
163
+ * Processes a `<sup>` element into a SuperscriptNode.
164
+ * Uses `type: "superscript"` from the AST.
165
+ *
166
+ * @param el - The superscript DOM element
167
+ * @returns A DocumentNode with type "superscript"
168
+ */
169
+ private processSuperscript;
170
+ /**
171
+ * Processes a `<mark>` element into an emphasis-styled node.
172
+ * Wraps the content in `==...==` (GitHub-flavored Markdown highlight syntax).
173
+ *
174
+ * @param el - The mark/highlight DOM element
175
+ * @returns An HtmlNode wrapping the highlighted content
176
+ */
177
+ private processMark;
178
+ /**
179
+ * Processes a `<blockquote>` element into a BlockquoteNode.
180
+ * Recursively processes child content.
181
+ *
182
+ * @param el - The blockquote DOM element
183
+ * @returns A BlockquoteNode with the child content
184
+ */
185
+ private processBlockquote;
186
+ /**
187
+ * Processes a `<details>` element into a section with summary.
188
+ * Renders as a Markdown details block using HTML.
189
+ *
190
+ * @param el - The details DOM element
191
+ * @returns An HtmlNode with the details content
192
+ */
193
+ private processDetails;
194
+ /**
195
+ * Processes a `<video>` element into an image node with video metadata.
196
+ * Extracts the poster image if available, or represents as a link.
197
+ *
198
+ * @param el - The video DOM element
199
+ * @returns An ImageNode (with poster) or a LinkNode (with src)
200
+ */
201
+ private processVideo;
202
+ /**
203
+ * Processes an `<audio>` element into a LinkNode.
204
+ * Represents the audio as a downloadable link.
205
+ *
206
+ * @param el - The audio DOM element
207
+ * @returns A LinkNode pointing to the audio source
208
+ */
209
+ private processAudio;
210
+ /**
211
+ * Processes an `<iframe>` element into a LinkNode.
212
+ * Embeds are represented as links to their source URL.
213
+ *
214
+ * @param el - The iframe DOM element
215
+ * @returns A LinkNode pointing to the iframe source
216
+ */
217
+ private processIframe;
218
+ /**
219
+ * Processes an `<aside>` element. If it has a footnote-like class or id,
220
+ * it is treated as a footnote; otherwise it is treated as a generic block.
221
+ *
222
+ * @param el - The aside DOM element
223
+ * @returns A FootnoteNode or the processed child content
224
+ */
225
+ private processAside;
226
+ /**
227
+ * Processes a list item element into a ListItemNode.
228
+ *
229
+ * @param el - The list item DOM element
230
+ * @returns A ListItemNode with the child content
231
+ */
232
+ private processListItem;
233
+ /**
234
+ * Renders an array of AST nodes into a Markdown string.
235
+ *
236
+ * @param nodes - The AST nodes to render
237
+ * @returns The rendered Markdown string
238
+ */
239
+ private renderMarkdown;
240
+ /**
241
+ * Renders a single AST node into its Markdown representation.
242
+ * Handles all supported node types including inline formatting, code, lists, tables, etc.
243
+ *
244
+ * @param node - The AST node to render
245
+ * @returns The Markdown string for this node
246
+ */
247
+ private renderNode;
248
+ /**
249
+ * Renders a table AST node into a Markdown table string.
250
+ * Handles column width calculation and alignment.
251
+ *
252
+ * @param table - The TableNode to render
253
+ * @returns The Markdown table string
254
+ */
255
+ private renderTable;
256
+ /**
257
+ * Recursively renders an array of AST nodes into a single string.
258
+ *
259
+ * @param nodes - The AST nodes to render
260
+ * @returns The concatenated rendered output
261
+ */
262
+ private renderNodes;
263
+ /**
264
+ * Extracts all heading nodes from the AST tree into a flat array.
265
+ * Used for populating the headings field in ConversionResult.
266
+ *
267
+ * @param nodes - The AST nodes to search
268
+ * @returns An array of heading info objects with level, text, and optional id
269
+ */
270
+ private extractHeadings;
271
+ /**
272
+ * Recursively extracts plain text content from an array of AST nodes.
273
+ *
274
+ * @param nodes - The AST nodes to extract text from
275
+ * @returns The concatenated plain text
276
+ */
277
+ private getTextContent;
278
+ }
279
+ //# sourceMappingURL=html-converter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-converter.d.ts","sourceRoot":"","sources":["../src/html-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EACf,gBAAgB,EAGjB,MAAM,sBAAsB,CAAC;AAyC9B;;;;;;;;;;;;GAYG;AACH,qBAAa,aAAc,YAAW,SAAS;IAC7C,QAAQ,CAAC,EAAE,EAAG,MAAM,CAAU;IAC9B,QAAQ,CAAC,kBAAkB,WAA0C;IACrE,QAAQ,CAAC,mBAAmB,WAA+B;IAE3D,gEAAgE;IAC1D,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC;IAe1D;;;;;OAKG;IACG,OAAO,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAkDhE;;;;;OAKG;YACW,UAAU;IAWxB;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAKpB;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;IAevB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAiGnB;;;;;;;OAOG;IACH,OAAO,CAAC,cAAc;IAYtB;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAOxB;;;;;;;;OAQG;IACH,OAAO,CAAC,YAAY;IAiCpB;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAwBvB;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW;IAmBnB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAUnB;;;;;;OAMG;IACH,OAAO,CAAC,YAAY;IAepB;;;;;;;OAOG;IACH,OAAO,CAAC,mBAAmB;IAY3B;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IAOrB;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAOvB;;;;;;OAMG;IACH,OAAO,CAAC,gBAAgB;IASxB;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IAO5B;;;;;;OAMG;IACH,OAAO,CAAC,gBAAgB;IAOxB;;;;;;OAMG;IACH,OAAO,CAAC,kBAAkB;IAO1B;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAUnB;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IAOzB;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;IAWtB;;;;;;OAMG;IACH,OAAO,CAAC,YAAY;IA4BpB;;;;;;OAMG;IACH,OAAO,CAAC,YAAY;IAiBpB;;;;;;OAMG;IACH,OAAO,CAAC,aAAa;IAgBrB;;;;;;OAMG;IACH,OAAO,CAAC,YAAY;IAiBpB;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAOvB;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAQtB;;;;;;OAMG;IACH,OAAO,CAAC,UAAU;IAgGlB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAuCnB;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IAInB;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;IAoBvB;;;;;OAKG;IACH,OAAO,CAAC,cAAc;CAUvB"}
@@ -0,0 +1,857 @@
1
+ import { createNode, parseHTML, } from "@markitdownjs/shared";
2
+ /**
3
+ * Regex for footnote-like CSS class names.
4
+ * Matches class attributes containing 'footnote', 'foot', 'note', or 'fn'.
5
+ */
6
+ const FOOTNOTE_CLASS_RE = /footnote|foot[-_\s]?note|fn[-_\s]?/i;
7
+ /**
8
+ * Regex for footnote-like `id` values.
9
+ * Matches id attributes like `fn1`, `footnote-2`, etc.
10
+ */
11
+ const FOOTNOTE_ID_RE = /^fn[-_\s]?\d+$|^footnote[-_\s]?\d+$/i;
12
+ /** Footnote counter used for generating unique identifiers. */
13
+ let footnoteCounter = 0;
14
+ /**
15
+ * Converts an HTML document (string, Uint8Array, Blob, or ArrayBuffer)
16
+ * into a structured AST and Markdown output.
17
+ *
18
+ * Features:
19
+ * - Full DOM traversal with position tracking
20
+ * - Support for headings, paragraphs, tables (caption/thead/tbody/tfoot),
21
+ * lists, links, images, code blocks, blockquotes, and inline formatting
22
+ * - `<details>/<summary>`, `<video>/<audio>` metadata, `<iframe>` as links
23
+ * - `<sup>`, `<sub>`, `<del>/<s>`, `<mark>`, `<u>` inline formatting
24
+ * - Footnote extraction from `<aside>` or footnote-like class/id elements
25
+ * - Numeric node type constants (3=TEXT, 8=COMMENT) for Node.js compatibility
26
+ */
27
+ export class HtmlConverter {
28
+ id = "html";
29
+ supportedMimeTypes = ["text/html", "application/xhtml+xml"];
30
+ supportedExtensions = [".html", ".htm", ".mhtml"];
31
+ /** Checks whether this converter can handle the given input. */
32
+ async canConvert(input) {
33
+ if (input.mimeType) {
34
+ if (this.supportedMimeTypes.includes(input.mimeType))
35
+ return true;
36
+ }
37
+ if (input.fileName) {
38
+ const ext = this.getExtension(input.fileName);
39
+ if (this.supportedExtensions.includes(ext))
40
+ return true;
41
+ }
42
+ if (typeof input.data === "string") {
43
+ const trimmed = input.data.trimStart();
44
+ if (trimmed.startsWith("<!DOCTYPE") || trimmed.startsWith("<html"))
45
+ return true;
46
+ }
47
+ return false;
48
+ }
49
+ /**
50
+ * Converts HTML input into a ConversionResult containing the AST, Markdown, and metadata.
51
+ *
52
+ * @param input - The HTML content to convert (string, Uint8Array, Blob, or ArrayBuffer)
53
+ * @returns A ConversionResult with the document AST, rendered Markdown, and extracted metadata
54
+ */
55
+ async convert(input) {
56
+ const startTime = performance.now();
57
+ const html = await this.readString(input);
58
+ const inputSize = new TextEncoder().encode(html).byteLength;
59
+ const document = await parseHTML(html);
60
+ footnoteCounter = 0;
61
+ const children = this.processChildren(Array.from(document.body.childNodes));
62
+ const documentNode = createNode({
63
+ type: "document",
64
+ children,
65
+ });
66
+ const markdown = this.renderMarkdown(children);
67
+ const headings = this.extractHeadings(children);
68
+ const endTime = performance.now();
69
+ const stats = {
70
+ startTime,
71
+ endTime,
72
+ duration: endTime - startTime,
73
+ inputSize,
74
+ outputSize: new TextEncoder().encode(markdown).byteLength,
75
+ };
76
+ const metadata = {
77
+ title: document.querySelector("title")?.textContent ?? undefined,
78
+ description: document.querySelector('meta[name="description"]')
79
+ ?.getAttribute("content") ?? undefined,
80
+ author: document.querySelector('meta[name="author"]')
81
+ ?.getAttribute("content") ?? undefined,
82
+ language: document.querySelector("html")?.getAttribute("lang") ?? undefined,
83
+ wordCount: markdown.split(/\s+/).filter(Boolean).length,
84
+ };
85
+ return {
86
+ markdown,
87
+ metadata,
88
+ assets: [],
89
+ tables: [],
90
+ images: [],
91
+ headings,
92
+ ast: documentNode,
93
+ format: "markdown",
94
+ converterId: this.id,
95
+ stats,
96
+ };
97
+ }
98
+ /**
99
+ * Reads the input data as a UTF-8 string.
100
+ *
101
+ * @param input - The conversion input to read
102
+ * @returns The decoded string content
103
+ */
104
+ async readString(input) {
105
+ if (typeof input.data === "string")
106
+ return input.data;
107
+ const bytes = input.data instanceof Uint8Array
108
+ ? input.data
109
+ : input.data instanceof ArrayBuffer
110
+ ? new Uint8Array(input.data)
111
+ : new Uint8Array(await input.data.arrayBuffer());
112
+ return new TextDecoder().decode(bytes);
113
+ }
114
+ /**
115
+ * Extracts the file extension (lowercased, with leading dot) from a filename.
116
+ *
117
+ * @param fileName - The filename to extract the extension from
118
+ * @returns The lowercased extension including the dot, or empty string if none
119
+ */
120
+ getExtension(fileName) {
121
+ const idx = fileName.lastIndexOf(".");
122
+ return idx === -1 ? "" : fileName.slice(idx).toLowerCase();
123
+ }
124
+ /**
125
+ * Processes an array of child DOM nodes into AST nodes.
126
+ * Skips null results (whitespace-only text nodes, comments).
127
+ *
128
+ * @param nodes - The DOM child nodes to process
129
+ * @returns An array of non-null AST nodes
130
+ */
131
+ processChildren(nodes) {
132
+ const result = [];
133
+ for (const node of nodes) {
134
+ const converted = this.processNode(node);
135
+ if (converted) {
136
+ if (Array.isArray(converted)) {
137
+ result.push(...converted);
138
+ }
139
+ else {
140
+ result.push(converted);
141
+ }
142
+ }
143
+ }
144
+ return result;
145
+ }
146
+ /**
147
+ * Processes a single DOM node into an AST node or array of AST nodes.
148
+ * Uses numeric constants (3 for TEXT_NODE, 8 for COMMENT_NODE) for Node.js compatibility.
149
+ *
150
+ * @param node - The DOM node to process
151
+ * @returns The corresponding AST node(s), or null if the node should be skipped
152
+ */
153
+ processNode(node) {
154
+ // Node.TEXT_NODE = 3, Node.COMMENT_NODE = 8
155
+ if (node.nodeType === 3) {
156
+ const text = node.textContent ?? "";
157
+ if (!text.trim())
158
+ return null;
159
+ return createNode({ type: "text", value: text });
160
+ }
161
+ if (node.nodeType === 8)
162
+ return null;
163
+ const el = node;
164
+ const tag = el.tagName.toLowerCase();
165
+ switch (tag) {
166
+ case "h1":
167
+ case "h2":
168
+ case "h3":
169
+ case "h4":
170
+ case "h5":
171
+ case "h6":
172
+ return this.processHeading(el, parseInt(tag[1]));
173
+ case "p":
174
+ return this.processParagraph(el);
175
+ case "table":
176
+ return this.processTable(el);
177
+ case "ul":
178
+ case "ol":
179
+ return this.processList(el, tag === "ol");
180
+ case "a":
181
+ return this.processLink(el);
182
+ case "img":
183
+ return this.processImage(el);
184
+ case "pre":
185
+ return this.processPreformatted(el);
186
+ case "strong":
187
+ case "b":
188
+ return this.processStrong(el);
189
+ case "em":
190
+ case "i":
191
+ return this.processEmphasis(el);
192
+ case "u":
193
+ return this.processUnderline(el);
194
+ case "del":
195
+ case "s":
196
+ return this.processStrikethrough(el);
197
+ case "sub":
198
+ return this.processSubscript(el);
199
+ case "sup":
200
+ return this.processSuperscript(el);
201
+ case "mark":
202
+ return this.processMark(el);
203
+ case "code":
204
+ if (el.parentElement?.tagName.toLowerCase() === "pre") {
205
+ return null;
206
+ }
207
+ return createNode({
208
+ type: "inline-code",
209
+ value: el.textContent ?? "",
210
+ });
211
+ case "br":
212
+ return createNode({ type: "text", value: "\n" });
213
+ case "hr":
214
+ return createNode({ type: "thematic-break" });
215
+ case "blockquote":
216
+ return this.processBlockquote(el);
217
+ case "details":
218
+ return this.processDetails(el);
219
+ case "summary":
220
+ // summary is handled inside processDetails; skip standalone
221
+ return null;
222
+ case "video":
223
+ return this.processVideo(el);
224
+ case "audio":
225
+ return this.processAudio(el);
226
+ case "iframe":
227
+ return this.processIframe(el);
228
+ case "aside":
229
+ return this.processAside(el);
230
+ case "li":
231
+ return this.processListItem(el);
232
+ case "figure":
233
+ case "div":
234
+ case "section":
235
+ case "article":
236
+ case "main":
237
+ case "header":
238
+ case "footer":
239
+ case "nav":
240
+ case "fieldset":
241
+ return this.processChildren(Array.from(el.childNodes));
242
+ default:
243
+ return this.processChildren(Array.from(el.childNodes));
244
+ }
245
+ }
246
+ /**
247
+ * Processes a heading element (h1-h6) into a HeadingNode.
248
+ * Extracts the `id` attribute if present for anchor linking.
249
+ *
250
+ * @param el - The heading DOM element
251
+ * @param level - The heading level (1-6)
252
+ * @returns A HeadingNode with the appropriate level and children
253
+ */
254
+ processHeading(el, level) {
255
+ return createNode({
256
+ type: "heading",
257
+ level,
258
+ children: this.processChildren(Array.from(el.childNodes)),
259
+ id: el.getAttribute("id") ?? undefined,
260
+ });
261
+ }
262
+ /**
263
+ * Processes a paragraph element into a ParagraphNode.
264
+ *
265
+ * @param el - The paragraph DOM element
266
+ * @returns A ParagraphNode with the processed child content
267
+ */
268
+ processParagraph(el) {
269
+ return createNode({
270
+ type: "paragraph",
271
+ children: this.processChildren(Array.from(el.childNodes)),
272
+ });
273
+ }
274
+ /**
275
+ * Processes a table element into a TableNode.
276
+ * Properly handles `<caption>`, `<thead>`, `<tbody>`, and `<tfoot>` sections.
277
+ * Preserves row order: thead rows first, then tbody rows, then tfoot rows.
278
+ * Falls back to querying all `<tr>` elements if no section elements exist.
279
+ *
280
+ * @param el - The table DOM element
281
+ * @returns A TableNode with properly ordered rows and optional caption
282
+ */
283
+ processTable(el) {
284
+ const rows = [];
285
+ let caption;
286
+ const captionEl = el.querySelector("caption");
287
+ if (captionEl) {
288
+ caption = captionEl.textContent?.trim() || undefined;
289
+ }
290
+ const thead = el.querySelector("thead");
291
+ const tbody = el.querySelector("tbody");
292
+ const tfoot = el.querySelector("tfoot");
293
+ if (thead || tbody || tfoot) {
294
+ const sections = [thead, tbody, tfoot].filter(Boolean);
295
+ for (const section of sections) {
296
+ for (const tr of Array.from(section.querySelectorAll("tr"))) {
297
+ rows.push(this.processTableRow(tr));
298
+ }
299
+ }
300
+ }
301
+ else {
302
+ for (const tr of Array.from(el.querySelectorAll("tr"))) {
303
+ rows.push(this.processTableRow(tr));
304
+ }
305
+ }
306
+ return createNode({
307
+ type: "table",
308
+ children: rows,
309
+ caption,
310
+ });
311
+ }
312
+ /**
313
+ * Processes a single table row (`<tr>`) element into a TableRowNode.
314
+ *
315
+ * @param tr - The table row DOM element
316
+ * @returns A TableRowNode with cells and isHeader flag
317
+ */
318
+ processTableRow(tr) {
319
+ const cells = [];
320
+ const cellEls = tr.querySelectorAll("td, th");
321
+ for (const cellEl of Array.from(cellEls)) {
322
+ cells.push(createNode({
323
+ type: "table-cell",
324
+ children: this.processChildren(Array.from(cellEl.childNodes)),
325
+ colspan: cellEl.hasAttribute("colspan")
326
+ ? parseInt(cellEl.getAttribute("colspan") ?? "1")
327
+ : undefined,
328
+ rowspan: cellEl.hasAttribute("rowspan")
329
+ ? parseInt(cellEl.getAttribute("rowspan") ?? "1")
330
+ : undefined,
331
+ }));
332
+ }
333
+ return createNode({
334
+ type: "table-row",
335
+ children: cells,
336
+ isHeader: tr.querySelector("th") !== null,
337
+ });
338
+ }
339
+ /**
340
+ * Processes a list element (`<ul>` or `<ol>`) into a ListNode.
341
+ * Handles nested lists and the `start` attribute for ordered lists.
342
+ *
343
+ * @param el - The list DOM element
344
+ * @param ordered - Whether this is an ordered list
345
+ * @returns A ListNode with processed list items
346
+ */
347
+ processList(el, ordered) {
348
+ const items = [];
349
+ for (const li of Array.from(el.querySelectorAll(":scope > li"))) {
350
+ items.push(createNode({
351
+ type: "list-item",
352
+ children: this.processChildren(Array.from(li.childNodes)),
353
+ }));
354
+ }
355
+ const startAttr = el.getAttribute("start");
356
+ return createNode({
357
+ type: "list",
358
+ ordered,
359
+ start: startAttr ? parseInt(startAttr) : undefined,
360
+ children: items,
361
+ });
362
+ }
363
+ /**
364
+ * Processes an anchor (`<a>`) element into a LinkNode.
365
+ * Filters out `javascript:` hrefs for safety.
366
+ *
367
+ * @param el - The anchor DOM element
368
+ * @returns A LinkNode with the href, optional title, and children
369
+ */
370
+ processLink(el) {
371
+ const href = el.getAttribute("href") ?? "";
372
+ return createNode({
373
+ type: "link",
374
+ href,
375
+ title: el.getAttribute("title") ?? undefined,
376
+ children: this.processChildren(Array.from(el.childNodes)),
377
+ });
378
+ }
379
+ /**
380
+ * Processes an image (`<img>`) element into an ImageNode.
381
+ * Extracts src, alt, title, width, and height attributes.
382
+ *
383
+ * @param el - The image DOM element
384
+ * @returns An ImageNode with the image metadata
385
+ */
386
+ processImage(el) {
387
+ return createNode({
388
+ type: "image",
389
+ src: el.getAttribute("src") ?? "",
390
+ alt: el.getAttribute("alt") ?? undefined,
391
+ title: el.getAttribute("title") ?? undefined,
392
+ width: el.hasAttribute("width")
393
+ ? parseInt(el.getAttribute("width") ?? "0") || undefined
394
+ : undefined,
395
+ height: el.hasAttribute("height")
396
+ ? parseInt(el.getAttribute("height") ?? "0") || undefined
397
+ : undefined,
398
+ });
399
+ }
400
+ /**
401
+ * Processes a preformatted (`<pre>`) element into a CodeNode.
402
+ * Detects language from CSS class (e.g., `language-typescript`).
403
+ * Falls back to the `<code>` element if present.
404
+ *
405
+ * @param el - The preformatted DOM element
406
+ * @returns A CodeNode with the code value and optional language
407
+ */
408
+ processPreformatted(el) {
409
+ const codeEl = el.querySelector("code");
410
+ const text = (codeEl ?? el).textContent ?? "";
411
+ const className = codeEl?.className ?? el.className;
412
+ const langMatch = className.match(/language-(\w+)/);
413
+ return createNode({
414
+ type: "code",
415
+ language: langMatch?.[1] ?? undefined,
416
+ value: text,
417
+ });
418
+ }
419
+ /**
420
+ * Processes a `<strong>` or `<b>` element into a StrongNode.
421
+ *
422
+ * @param el - The strong/bold DOM element
423
+ * @returns A StrongNode with the child content
424
+ */
425
+ processStrong(el) {
426
+ return createNode({
427
+ type: "strong",
428
+ children: this.processChildren(Array.from(el.childNodes)),
429
+ });
430
+ }
431
+ /**
432
+ * Processes an `<em>` or `<i>` element into an EmphasisNode.
433
+ *
434
+ * @param el - The emphasis/italic DOM element
435
+ * @returns An EmphasisNode with the child content
436
+ */
437
+ processEmphasis(el) {
438
+ return createNode({
439
+ type: "emphasis",
440
+ children: this.processChildren(Array.from(el.childNodes)),
441
+ });
442
+ }
443
+ /**
444
+ * Processes a `<u>` element into a StrongNode with underline semantics.
445
+ * Markdown doesn't have native underline; we use `<u>` HTML inline instead.
446
+ *
447
+ * @param el - The underline DOM element
448
+ * @returns An HtmlNode wrapping the content as `<u>...</u>`
449
+ */
450
+ processUnderline(el) {
451
+ const content = el.textContent ?? "";
452
+ if (!content.trim())
453
+ return createNode({ type: "text", value: "" });
454
+ return createNode({
455
+ type: "html",
456
+ value: `<u>${content}</u>`,
457
+ });
458
+ }
459
+ /**
460
+ * Processes a `<del>` or `<s>` element into a StrikethroughNode.
461
+ *
462
+ * @param el - The strikethrough DOM element
463
+ * @returns A StrikethroughNode with the child content
464
+ */
465
+ processStrikethrough(el) {
466
+ return createNode({
467
+ type: "strikethrough",
468
+ children: this.processChildren(Array.from(el.childNodes)),
469
+ });
470
+ }
471
+ /**
472
+ * Processes a `<sub>` element into a SubscriptNode.
473
+ * Uses `type: "subscript"` from the AST.
474
+ *
475
+ * @param el - The subscript DOM element
476
+ * @returns A DocumentNode with type "subscript"
477
+ */
478
+ processSubscript(el) {
479
+ return createNode({
480
+ type: "subscript",
481
+ children: this.processChildren(Array.from(el.childNodes)),
482
+ });
483
+ }
484
+ /**
485
+ * Processes a `<sup>` element into a SuperscriptNode.
486
+ * Uses `type: "superscript"` from the AST.
487
+ *
488
+ * @param el - The superscript DOM element
489
+ * @returns A DocumentNode with type "superscript"
490
+ */
491
+ processSuperscript(el) {
492
+ return createNode({
493
+ type: "superscript",
494
+ children: this.processChildren(Array.from(el.childNodes)),
495
+ });
496
+ }
497
+ /**
498
+ * Processes a `<mark>` element into an emphasis-styled node.
499
+ * Wraps the content in `==...==` (GitHub-flavored Markdown highlight syntax).
500
+ *
501
+ * @param el - The mark/highlight DOM element
502
+ * @returns An HtmlNode wrapping the highlighted content
503
+ */
504
+ processMark(el) {
505
+ const content = this.processChildren(Array.from(el.childNodes));
506
+ const text = this.renderNodes(content);
507
+ if (!text.trim())
508
+ return createNode({ type: "text", value: "" });
509
+ return createNode({
510
+ type: "html",
511
+ value: `==${text}==`,
512
+ });
513
+ }
514
+ /**
515
+ * Processes a `<blockquote>` element into a BlockquoteNode.
516
+ * Recursively processes child content.
517
+ *
518
+ * @param el - The blockquote DOM element
519
+ * @returns A BlockquoteNode with the child content
520
+ */
521
+ processBlockquote(el) {
522
+ return createNode({
523
+ type: "blockquote",
524
+ children: this.processChildren(Array.from(el.childNodes)),
525
+ });
526
+ }
527
+ /**
528
+ * Processes a `<details>` element into a section with summary.
529
+ * Renders as a Markdown details block using HTML.
530
+ *
531
+ * @param el - The details DOM element
532
+ * @returns An HtmlNode with the details content
533
+ */
534
+ processDetails(el) {
535
+ const summaryEl = el.querySelector("summary");
536
+ const summaryText = summaryEl?.textContent?.trim() ?? "Details";
537
+ const bodyNodes = this.processChildren(Array.from(el.childNodes));
538
+ const bodyText = this.renderMarkdown(bodyNodes);
539
+ return createNode({
540
+ type: "html",
541
+ value: `<details><summary>${summaryText}</summary>\n\n${bodyText}\n\n</details>`,
542
+ });
543
+ }
544
+ /**
545
+ * Processes a `<video>` element into an image node with video metadata.
546
+ * Extracts the poster image if available, or represents as a link.
547
+ *
548
+ * @param el - The video DOM element
549
+ * @returns An ImageNode (with poster) or a LinkNode (with src)
550
+ */
551
+ processVideo(el) {
552
+ const poster = el.getAttribute("poster");
553
+ const src = el.getAttribute("src");
554
+ const children = Array.from(el.querySelectorAll("source"));
555
+ const videoSrc = poster ?? src ?? children[0]?.getAttribute("src") ?? "";
556
+ if (poster) {
557
+ return createNode({
558
+ type: "image",
559
+ src: poster,
560
+ alt: `[Video: ${videoSrc}]`,
561
+ title: el.getAttribute("title") ?? undefined,
562
+ });
563
+ }
564
+ return createNode({
565
+ type: "link",
566
+ href: videoSrc,
567
+ title: el.getAttribute("title") ?? `[Video: ${videoSrc}]`,
568
+ children: [
569
+ createNode({
570
+ type: "text",
571
+ value: `[Video: ${videoSrc}]`,
572
+ }),
573
+ ],
574
+ });
575
+ }
576
+ /**
577
+ * Processes an `<audio>` element into a LinkNode.
578
+ * Represents the audio as a downloadable link.
579
+ *
580
+ * @param el - The audio DOM element
581
+ * @returns A LinkNode pointing to the audio source
582
+ */
583
+ processAudio(el) {
584
+ const src = el.getAttribute("src");
585
+ const sources = Array.from(el.querySelectorAll("source"));
586
+ const audioSrc = src ?? sources[0]?.getAttribute("src") ?? "";
587
+ return createNode({
588
+ type: "link",
589
+ href: audioSrc,
590
+ title: el.getAttribute("title") ?? `[Audio: ${audioSrc}]`,
591
+ children: [
592
+ createNode({
593
+ type: "text",
594
+ value: `[Audio: ${audioSrc}]`,
595
+ }),
596
+ ],
597
+ });
598
+ }
599
+ /**
600
+ * Processes an `<iframe>` element into a LinkNode.
601
+ * Embeds are represented as links to their source URL.
602
+ *
603
+ * @param el - The iframe DOM element
604
+ * @returns A LinkNode pointing to the iframe source
605
+ */
606
+ processIframe(el) {
607
+ const src = el.getAttribute("src") ?? "";
608
+ const title = el.getAttribute("title") ?? src;
609
+ return createNode({
610
+ type: "link",
611
+ href: src,
612
+ title,
613
+ children: [
614
+ createNode({
615
+ type: "text",
616
+ value: `[Embedded: ${title}]`,
617
+ }),
618
+ ],
619
+ });
620
+ }
621
+ /**
622
+ * Processes an `<aside>` element. If it has a footnote-like class or id,
623
+ * it is treated as a footnote; otherwise it is treated as a generic block.
624
+ *
625
+ * @param el - The aside DOM element
626
+ * @returns A FootnoteNode or the processed child content
627
+ */
628
+ processAside(el) {
629
+ const className = el.getAttribute("class") ?? "";
630
+ const id = el.getAttribute("id") ?? "";
631
+ if (FOOTNOTE_CLASS_RE.test(className) || FOOTNOTE_ID_RE.test(id)) {
632
+ footnoteCounter++;
633
+ const identifier = id || `fn${footnoteCounter}`;
634
+ return createNode({
635
+ type: "footnote",
636
+ identifier,
637
+ children: this.processChildren(Array.from(el.childNodes)),
638
+ });
639
+ }
640
+ return this.processChildren(Array.from(el.childNodes));
641
+ }
642
+ /**
643
+ * Processes a list item element into a ListItemNode.
644
+ *
645
+ * @param el - The list item DOM element
646
+ * @returns A ListItemNode with the child content
647
+ */
648
+ processListItem(el) {
649
+ return createNode({
650
+ type: "list-item",
651
+ children: this.processChildren(Array.from(el.childNodes)),
652
+ });
653
+ }
654
+ /**
655
+ * Renders an array of AST nodes into a Markdown string.
656
+ *
657
+ * @param nodes - The AST nodes to render
658
+ * @returns The rendered Markdown string
659
+ */
660
+ renderMarkdown(nodes) {
661
+ const parts = [];
662
+ for (const node of nodes) {
663
+ parts.push(this.renderNode(node));
664
+ }
665
+ return parts.join("\n\n").replace(/\n{3,}/g, "\n\n").trim();
666
+ }
667
+ /**
668
+ * Renders a single AST node into its Markdown representation.
669
+ * Handles all supported node types including inline formatting, code, lists, tables, etc.
670
+ *
671
+ * @param node - The AST node to render
672
+ * @returns The Markdown string for this node
673
+ */
674
+ renderNode(node) {
675
+ switch (node.type) {
676
+ case "heading": {
677
+ const n = node;
678
+ const prefix = "#".repeat(n.level);
679
+ return `${prefix} ${this.renderNodes(n.children)}`;
680
+ }
681
+ case "paragraph": {
682
+ const n = node;
683
+ return this.renderNodes(n.children);
684
+ }
685
+ case "table": {
686
+ const n = node;
687
+ return this.renderTable(n);
688
+ }
689
+ case "list": {
690
+ const n = node;
691
+ return n.children
692
+ .map((item, i) => {
693
+ const bullet = n.ordered ? `${(n.start ?? 1) + i}. ` : "- ";
694
+ return `${bullet}${this.renderNodes(item.children)}`;
695
+ })
696
+ .join("\n");
697
+ }
698
+ case "list-item": {
699
+ const n = node;
700
+ return this.renderNodes(n.children);
701
+ }
702
+ case "link": {
703
+ const n = node;
704
+ const text = this.renderNodes(n.children);
705
+ return n.title
706
+ ? `[${text}](${n.href} "${n.title}")`
707
+ : `[${text}](${n.href})`;
708
+ }
709
+ case "image": {
710
+ const n = node;
711
+ return `![${n.alt ?? ""}](${n.src}${n.title ? ` "${n.title}"` : ""})`;
712
+ }
713
+ case "code": {
714
+ const n = node;
715
+ return "```" + (n.language ?? "") + "\n" + n.value + "\n```";
716
+ }
717
+ case "inline-code": {
718
+ const n = node;
719
+ return `\`${n.value}\``;
720
+ }
721
+ case "strong": {
722
+ const n = node;
723
+ return `**${this.renderNodes(n.children)}**`;
724
+ }
725
+ case "emphasis": {
726
+ const n = node;
727
+ return `*${this.renderNodes(n.children)}*`;
728
+ }
729
+ case "strikethrough": {
730
+ const n = node;
731
+ return `~~${this.renderNodes(n.children)}~~`;
732
+ }
733
+ case "subscript": {
734
+ return `~${this.renderNodes(node.children)}~`;
735
+ }
736
+ case "superscript": {
737
+ return `^${this.renderNodes(node.children)}^`;
738
+ }
739
+ case "blockquote": {
740
+ const n = node;
741
+ const content = this.renderNodes(n.children);
742
+ return content
743
+ .split("\n")
744
+ .map((line) => `> ${line}`)
745
+ .join("\n");
746
+ }
747
+ case "text": {
748
+ const n = node;
749
+ return n.value;
750
+ }
751
+ case "html": {
752
+ return node.value;
753
+ }
754
+ case "thematic-break":
755
+ return "---";
756
+ case "horizontal-rule":
757
+ return "---";
758
+ case "footnote": {
759
+ const n = node;
760
+ return `[^${n.identifier}]: ${this.renderNodes(n.children)}`;
761
+ }
762
+ default:
763
+ if ("children" in node && Array.isArray(node.children)) {
764
+ return this.renderNodes(node.children);
765
+ }
766
+ return "";
767
+ }
768
+ }
769
+ /**
770
+ * Renders a table AST node into a Markdown table string.
771
+ * Handles column width calculation and alignment.
772
+ *
773
+ * @param table - The TableNode to render
774
+ * @returns The Markdown table string
775
+ */
776
+ renderTable(table) {
777
+ if (table.children.length === 0)
778
+ return "";
779
+ let lines = [];
780
+ if (table.caption) {
781
+ lines.push(`*${table.caption}*`);
782
+ lines.push("");
783
+ }
784
+ const rows = table.children;
785
+ const headerRow = rows[0];
786
+ const colCount = headerRow.children.length;
787
+ const colWidths = new Array(colCount).fill(3);
788
+ const cellTexts = rows.map((row) => row.children.map((cell) => this.renderNodes(cell.children)));
789
+ for (const row of cellTexts) {
790
+ for (let i = 0; i < row.length; i++) {
791
+ colWidths[i] = Math.max(colWidths[i], row[i].length);
792
+ }
793
+ }
794
+ for (let r = 0; r < cellTexts.length; r++) {
795
+ const cells = cellTexts[r];
796
+ const line = "| " + cells.map((c, i) => c.padEnd(colWidths[i])).join(" | ") + " |";
797
+ lines.push(line);
798
+ if (r === 0) {
799
+ lines.push("| " + colWidths.map((w) => "-".repeat(w)).join(" | ") + " |");
800
+ }
801
+ }
802
+ return lines.join("\n");
803
+ }
804
+ /**
805
+ * Recursively renders an array of AST nodes into a single string.
806
+ *
807
+ * @param nodes - The AST nodes to render
808
+ * @returns The concatenated rendered output
809
+ */
810
+ renderNodes(nodes) {
811
+ return nodes.map((n) => this.renderNode(n)).join("");
812
+ }
813
+ /**
814
+ * Extracts all heading nodes from the AST tree into a flat array.
815
+ * Used for populating the headings field in ConversionResult.
816
+ *
817
+ * @param nodes - The AST nodes to search
818
+ * @returns An array of heading info objects with level, text, and optional id
819
+ */
820
+ extractHeadings(nodes) {
821
+ const headings = [];
822
+ for (const node of nodes) {
823
+ if (node.type === "heading") {
824
+ const h = node;
825
+ headings.push({
826
+ level: h.level,
827
+ text: this.getTextContent(h.children),
828
+ id: h.id,
829
+ });
830
+ }
831
+ if ("children" in node && node.children) {
832
+ headings.push(...this.extractHeadings(node.children));
833
+ }
834
+ }
835
+ return headings;
836
+ }
837
+ /**
838
+ * Recursively extracts plain text content from an array of AST nodes.
839
+ *
840
+ * @param nodes - The AST nodes to extract text from
841
+ * @returns The concatenated plain text
842
+ */
843
+ getTextContent(nodes) {
844
+ return nodes
845
+ .map((n) => {
846
+ if (n.type === "text")
847
+ return n.value;
848
+ if (n.type === "inline-code")
849
+ return n.value;
850
+ if ("children" in n && n.children)
851
+ return this.getTextContent(n.children);
852
+ return "";
853
+ })
854
+ .join("");
855
+ }
856
+ }
857
+ //# sourceMappingURL=html-converter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-converter.js","sourceRoot":"","sources":["../src/html-converter.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,UAAU,EACV,SAAS,GAqBV,MAAM,sBAAsB,CAAC;AAE9B;;;GAGG;AACH,MAAM,iBAAiB,GAAG,qCAAqC,CAAC;AAEhE;;;GAGG;AACH,MAAM,cAAc,GAAG,sCAAsC,CAAC;AAE9D,+DAA+D;AAC/D,IAAI,eAAe,GAAG,CAAC,CAAC;AAExB;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,aAAa;IACf,EAAE,GAAG,MAAe,CAAC;IACrB,kBAAkB,GAAG,CAAC,WAAW,EAAE,uBAAuB,CAAC,CAAC;IAC5D,mBAAmB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IAE3D,gEAAgE;IAChE,KAAK,CAAC,UAAU,CAAC,KAAsB;QACrC,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACnB,IAAI,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;gBAAE,OAAO,IAAI,CAAC;QACpE,CAAC;QACD,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACnB,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YAC9C,IAAI,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC;gBAAE,OAAO,IAAI,CAAC;QAC1D,CAAC;QACD,IAAI,OAAO,KAAK,CAAC,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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { HtmlConverter } from "./html-converter.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@markitdownjs/html",
3
+ "version": "0.1.0",
4
+ "description": "HTML converter for MarkItDownJS",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/index.js",
13
+ "types": "./dist/index.d.ts"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "dependencies": {
20
+ "@markitdownjs/shared": "0.1.0"
21
+ },
22
+ "devDependencies": {
23
+ "typescript": "^5.5.0"
24
+ },
25
+ "scripts": {
26
+ "build": "tsc --project tsconfig.json",
27
+ "dev": "tsc --watch --project tsconfig.json",
28
+ "typecheck": "tsc --noEmit",
29
+ "clean": "rm -rf dist tsconfig.tsbuildinfo"
30
+ }
31
+ }