@kreuzberg/html-to-markdown-node 2.30.0 → 3.0.1

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.
Files changed (4) hide show
  1. package/README.md +103 -116
  2. package/index.d.ts +60 -236
  3. package/index.js +52 -67
  4. package/package.json +2 -2
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Native Node.js and Bun bindings for html-to-markdown using NAPI-RS v3.
7
7
 
8
- Built on the shared Rust engine that powers the Python wheels, Ruby gem, PHP extension, WebAssembly package, and CLI ensuring identical Markdown output across every language target.
8
+ Built on the shared Rust engine that powers the Python wheels, Ruby gem, PHP extension, WebAssembly package, and CLI -- ensuring identical Markdown output across every language target.
9
9
 
10
10
  High-performance HTML to Markdown conversion using native Rust code compiled to platform-specific binaries.
11
11
 
@@ -17,45 +17,9 @@ High-performance HTML to Markdown conversion using native Rust code compiled to
17
17
  [![RubyGems](https://badge.fury.io/rb/html-to-markdown.svg)](https://rubygems.org/gems/html-to-markdown)
18
18
  [![NuGet](https://img.shields.io/nuget/v/KreuzbergDev.HtmlToMarkdown.svg)](https://www.nuget.org/packages/KreuzbergDev.HtmlToMarkdown/)
19
19
  [![Maven Central](https://img.shields.io/maven-central/v/dev.kreuzberg/html-to-markdown.svg)](https://central.sonatype.com/artifact/dev.kreuzberg/html-to-markdown)
20
- [![Go Reference](https://pkg.go.dev/badge/github.com/kreuzberg-dev/html-to-markdown/packages/go/v2/htmltomarkdown.svg)](https://pkg.go.dev/github.com/kreuzberg-dev/html-to-markdown/packages/go/v2/htmltomarkdown)
20
+ [![Go Reference](https://pkg.go.dev/badge/github.com/kreuzberg-dev/html-to-markdown/packages/go/v3/htmltomarkdown.svg)](https://pkg.go.dev/github.com/kreuzberg-dev/html-to-markdown/packages/go/v3/htmltomarkdown)
21
21
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/kreuzberg-dev/html-to-markdown/blob/main/LICENSE)
22
22
 
23
- ## Migration Guide (v2.18.x → v2.19.0)
24
-
25
- > **⚠️ BREAKING CHANGE: Package Namespace Update**
26
- >
27
- > In v2.19.0, the npm package namespace changed from `html-to-markdown-node` to `@kreuzberg/html-to-markdown-node` to reflect the new Kreuzberg.dev organization.
28
-
29
- ### Install Updated Package
30
-
31
- **Before (v2.18.x):**
32
- ```bash
33
- npm install html-to-markdown-node
34
- ```
35
-
36
- **After (v2.19.0+):**
37
- ```bash
38
- npm install @kreuzberg/html-to-markdown-node
39
- ```
40
-
41
- ### Update Import Statements
42
-
43
- **Before:**
44
- ```typescript
45
- import { convert } from 'html-to-markdown-node';
46
- ```
47
-
48
- **After:**
49
- ```typescript
50
- import { convert } from '@kreuzberg/html-to-markdown-node';
51
- ```
52
-
53
- ### Summary of Changes
54
-
55
- - Package renamed from `html-to-markdown-node` to `@kreuzberg/html-to-markdown-node`
56
- - All APIs remain identical
57
- - Full backward compatibility after updating package name and imports
58
-
59
23
  ---
60
24
 
61
25
  ## Performance
@@ -78,8 +42,8 @@ Native NAPI-RS bindings deliver **the fastest HTML to Markdown conversion** avai
78
42
 
79
43
  ### Comparison
80
44
 
81
- - **vs WASM**: ~1.17× faster (native has zero startup time, direct memory access)
82
- - **vs Python**: ~7. faster (avoids FFI overhead)
45
+ - **vs WASM**: ~1.17x faster (native has zero startup time, direct memory access)
46
+ - **vs Python**: ~7.4x faster (avoids FFI overhead)
83
47
  - **Best for**: Node.js and Bun server-side applications requiring maximum throughput
84
48
 
85
49
  ### Benchmark Fixtures (Apple M4)
@@ -125,19 +89,37 @@ bun add @kreuzberg/html-to-markdown-node
125
89
  import { convert } from '@kreuzberg/html-to-markdown-node';
126
90
 
127
91
  const html = '<h1>Hello World</h1><p>This is <strong>fast</strong>!</p>';
128
- const markdown = convert(html);
129
- console.log(markdown);
92
+ const result = convert(html);
93
+
94
+ console.log(result.content);
130
95
  // # Hello World
131
96
  //
132
97
  // This is **fast**!
133
98
  ```
134
99
 
100
+ ### ConversionResult Fields
101
+
102
+ Every call to `convert()` returns a `ConversionResult` object with six fields:
103
+
104
+ ```typescript
105
+ import { convert } from '@kreuzberg/html-to-markdown-node';
106
+
107
+ const result = convert(html);
108
+
109
+ result.content; // string | null -- converted Markdown (or djot/plain text)
110
+ result.document; // string | null -- structured document tree as JSON
111
+ result.metadata; // string | null -- extracted HTML metadata as JSON
112
+ result.tables; // Array -- all tables found in document order
113
+ result.images; // Array -- extracted inline images (data URIs, SVGs)
114
+ result.warnings; // Array -- non-fatal processing warnings
115
+ ```
116
+
135
117
  ### With Options
136
118
 
137
119
  ```typescript
138
120
  import { convert } from '@kreuzberg/html-to-markdown-node';
139
121
 
140
- const markdown = convert(html, {
122
+ const result = convert(html, {
141
123
  headingStyle: 'Atx',
142
124
  codeBlockStyle: 'Backticks',
143
125
  listIndentWidth: 2,
@@ -145,9 +127,11 @@ const markdown = convert(html, {
145
127
  wrap: true,
146
128
  wrapWidth: 80
147
129
  });
130
+
131
+ console.log(result.content);
148
132
  ```
149
133
 
150
- ### Preserve Complex HTML (NEW in v2.5)
134
+ ### Preserve Complex HTML
151
135
 
152
136
  ```typescript
153
137
  import { convert } from '@kreuzberg/html-to-markdown-node';
@@ -160,9 +144,11 @@ const html = `
160
144
  </table>
161
145
  `;
162
146
 
163
- const markdown = convert(html, {
147
+ const result = convert(html, {
164
148
  preserveTags: ['table'] // Keep tables as HTML
165
149
  });
150
+
151
+ console.log(result.content);
166
152
  // # Report
167
153
  //
168
154
  // <table>
@@ -176,7 +162,7 @@ const markdown = convert(html, {
176
162
  Full TypeScript definitions included:
177
163
 
178
164
  ```typescript
179
- import { convert, convertWithInlineImages, type JsConversionOptions } from '@kreuzberg/html-to-markdown-node';
165
+ import { convert, type JsConversionOptions } from '@kreuzberg/html-to-markdown-node';
180
166
 
181
167
  const options: JsConversionOptions = {
182
168
  headingStyle: 'Atx',
@@ -187,71 +173,66 @@ const options: JsConversionOptions = {
187
173
  wrapWidth: 80
188
174
  };
189
175
 
190
- const markdown = convert('<h1>Hello</h1>', options);
176
+ const result = convert('<h1>Hello</h1>', options);
177
+ console.log(result.content);
191
178
  ```
192
179
 
193
- ### Reusing Parsed Options
194
-
195
- Avoid re-parsing the same options object on every call (benchmarks, tight render loops) by creating a reusable handle:
180
+ ## Metadata and Tables
196
181
 
197
- ```ts
198
- import {
199
- createConversionOptionsHandle,
200
- convertWithOptionsHandle,
201
- } from '@kreuzberg/html-to-markdown-node';
182
+ Extract metadata and structured tables from the conversion result:
202
183
 
203
- const handle = createConversionOptionsHandle({ hocrSpatialTables: false });
204
- const markdown = convertWithOptionsHandle('<h1>Handles</h1>', handle);
205
- ```
206
-
207
- ### Zero-Copy Buffer Input
208
-
209
- Skip the intermediate UTF-16 string allocation by feeding `Buffer`/`Uint8Array` inputs directly—handy for benchmark harnesses or when you already have raw bytes:
184
+ ```typescript
185
+ import { convert } from '@kreuzberg/html-to-markdown-node';
210
186
 
211
- ```ts
212
- import {
213
- convertBuffer,
214
- convertInlineImagesBuffer,
215
- convertBufferWithOptionsHandle,
216
- createConversionOptionsHandle,
217
- } from '@kreuzberg/html-to-markdown-node';
218
- import { readFileSync } from 'node:fs';
187
+ const html = `
188
+ <html lang="en">
189
+ <head><title>My Article</title></head>
190
+ <body>
191
+ <h1>Main Title</h1>
192
+ <p>Content with <a href="https://example.com">a link</a></p>
193
+ <table>
194
+ <tr><th>Name</th><th>Value</th></tr>
195
+ <tr><td>Foo</td><td>42</td></tr>
196
+ </table>
197
+ </body>
198
+ </html>
199
+ `;
219
200
 
220
- const html = readFileSync('fixtures/lists.html'); // Buffer
221
- const markdown = convertBuffer(html);
201
+ const result = convert(html, {
202
+ extractMetadata: true,
203
+ });
222
204
 
223
- const handle = createConversionOptionsHandle({ headingStyle: 'Atx' });
224
- const markdownFromHandle = convertBufferWithOptionsHandle(html, handle);
205
+ console.log(result.content); // Markdown output
206
+ console.log(result.metadata); // JSON string with title, links, headers, etc.
207
+ console.log(result.tables.length); // Number of tables found
208
+ console.log(result.warnings); // Any processing warnings
225
209
 
226
- // Inline images work too:
227
- const extraction = convertInlineImagesBuffer(html, null, {
228
- maxDecodedSizeBytes: 5 * 1024 * 1024,
229
- });
210
+ for (const table of result.tables) {
211
+ console.log(table.markdown); // Table as Markdown
212
+ console.log(table.grid.rows); // Number of rows
213
+ console.log(table.grid.cols); // Number of columns
214
+ console.log(table.grid.cells); // Cell-level data
215
+ }
230
216
  ```
231
217
 
232
218
  ## Inline Images
233
219
 
234
- Extract and decode inline images (data URIs, SVG):
220
+ Inline images (data URIs, SVGs) are automatically extracted and available on the result:
235
221
 
236
222
  ```typescript
237
- import { convertWithInlineImages } from '@kreuzberg/html-to-markdown-node';
223
+ import { convert } from '@kreuzberg/html-to-markdown-node';
224
+ import { writeFileSync } from 'node:fs';
238
225
 
239
226
  const html = '<img src="data:image/png;base64,iVBORw0..." alt="Logo">';
240
227
 
241
- const result = convertWithInlineImages(html, null, {
242
- maxDecodedSizeBytes: 5 * 1024 * 1024, // 5MB
243
- inferDimensions: true,
244
- filenamePrefix: 'img_',
245
- captureSvg: true
246
- });
228
+ const result = convert(html);
247
229
 
248
- console.log(result.markdown);
249
- console.log(`Extracted ${result.inlineImages.length} images`);
230
+ console.log(result.content);
231
+ console.log(`Extracted ${result.images.length} images`);
250
232
 
251
- for (const img of result.inlineImages) {
233
+ for (const img of result.images) {
252
234
  console.log(`${img.filename}: ${img.format}, ${img.data.length} bytes`);
253
- // Save image data to disk
254
- require('fs').writeFileSync(img.filename, img.data);
235
+ writeFileSync(img.filename, img.data);
255
236
  }
256
237
  ```
257
238
 
@@ -267,31 +248,31 @@ Pre-built native binaries are provided for:
267
248
 
268
249
  ### Runtime Compatibility
269
250
 
270
- **Node.js** 18+ (LTS)
271
- **Bun** 1.0+ (full NAPI-RS support)
272
- **Deno** (use [@kreuzberg/html-to-markdown-wasm](https://www.npmjs.com/package/@kreuzberg/html-to-markdown-wasm) instead)
251
+ - **Node.js** 18+ (LTS)
252
+ - **Bun** 1.0+ (full NAPI-RS support)
253
+ - **Deno** -- use [@kreuzberg/html-to-markdown-wasm](https://www.npmjs.com/package/@kreuzberg/html-to-markdown-wasm) instead
273
254
 
274
255
  ## When to Use
275
256
 
276
257
  Choose `@kreuzberg/html-to-markdown-node` when:
277
258
 
278
- - Running in Node.js or Bun
279
- - Maximum performance is required
280
- - Server-side conversion at scale
259
+ - Running in Node.js or Bun
260
+ - Maximum performance is required
261
+ - Server-side conversion at scale
281
262
 
282
- Use [`html-to-markdown-wasm`](https://www.npmjs.com/package/html-to-markdown-wasm) for:
263
+ Use [`@kreuzberg/html-to-markdown-wasm`](https://www.npmjs.com/package/@kreuzberg/html-to-markdown-wasm) for:
283
264
 
284
- - 🌐 Browser/client-side conversion
285
- - 🦕 Deno runtime
286
- - ☁️ Edge runtimes (Cloudflare Workers, Deno Deploy)
287
- - 📦 Universal packages
265
+ - Browser/client-side conversion
266
+ - Deno runtime
267
+ - Edge runtimes (Cloudflare Workers, Deno Deploy)
268
+ - Universal packages
288
269
 
289
270
  Other runtimes:
290
271
 
291
- - 🐍 Python: [`html-to-markdown`](https://pypi.org/project/html-to-markdown/)
292
- - 💎 Ruby: [`html-to-markdown`](https://rubygems.org/gems/html-to-markdown)
293
- - 🐘 PHP: [`kreuzberg-dev/html-to-markdown`](https://packagist.org/packages/kreuzberg-dev/html-to-markdown)
294
- - 🌐 WebAssembly: [`html-to-markdown-wasm`](https://www.npmjs.com/package/html-to-markdown-wasm)
272
+ - Python: [`html-to-markdown`](https://pypi.org/project/html-to-markdown/)
273
+ - Ruby: [`html-to-markdown`](https://rubygems.org/gems/html-to-markdown)
274
+ - PHP: [`kreuzberg-dev/html-to-markdown`](https://packagist.org/packages/kreuzberg-dev/html-to-markdown)
275
+ - WebAssembly: [`@kreuzberg/html-to-markdown-wasm`](https://www.npmjs.com/package/@kreuzberg/html-to-markdown-wasm)
295
276
 
296
277
  ## Configuration Options
297
278
 
@@ -303,6 +284,7 @@ See [ConversionOptions](https://github.com/kreuzberg-dev/html-to-markdown/tree/m
303
284
  - Text escaping and formatting
304
285
  - Tag preservation (`preserveTags`) and stripping (`stripTags`)
305
286
  - Preprocessing for web scraping
287
+ - Metadata extraction (`extractMetadata`)
306
288
  - hOCR table extraction
307
289
  - And more...
308
290
 
@@ -324,18 +306,18 @@ const html = `
324
306
  <p>After table</p>
325
307
  `;
326
308
 
327
- const markdown = convert(html, {
309
+ const result = convert(html, {
328
310
  preserveTags: ['table']
329
311
  });
330
312
 
331
- // Result includes the table as HTML:
313
+ console.log(result.content);
332
314
  // "Before table\n\n<table class=\"data\">...</table>\n\nAfter table\n"
333
315
  ```
334
316
 
335
317
  Combine with `stripTags` for fine-grained control:
336
318
 
337
319
  ```typescript
338
- const markdown = convert(html, {
320
+ const result = convert(html, {
339
321
  preserveTags: ['table', 'form'], // Keep these as HTML
340
322
  stripTags: ['script', 'style'] // Remove these entirely
341
323
  });
@@ -344,11 +326,11 @@ const markdown = convert(html, {
344
326
  ### Web Scraping
345
327
 
346
328
  ```javascript
347
- const { convert } = require('@kreuzberg/html-to-markdown-node');
329
+ import { convert } from '@kreuzberg/html-to-markdown-node';
348
330
 
349
331
  const scrapedHtml = await fetch('https://example.com').then(r => r.text());
350
332
 
351
- const markdown = convert(scrapedHtml, {
333
+ const result = convert(scrapedHtml, {
352
334
  preprocessing: {
353
335
  enabled: true,
354
336
  preset: 'Aggressive',
@@ -358,28 +340,33 @@ const markdown = convert(scrapedHtml, {
358
340
  headingStyle: 'Atx',
359
341
  codeBlockStyle: 'Backticks'
360
342
  });
343
+
344
+ console.log(result.content);
361
345
  ```
362
346
 
363
347
  ### hOCR Document Processing
364
348
 
365
349
  ```javascript
366
- const { convert } = require('@kreuzberg/html-to-markdown-node');
367
- const fs = require('fs');
350
+ import { convert } from '@kreuzberg/html-to-markdown-node';
351
+ import { readFileSync } from 'node:fs';
368
352
 
369
353
  // OCR output from Tesseract in hOCR format
370
- const hocrHtml = fs.readFileSync('scan.hocr', 'utf8');
354
+ const hocrHtml = readFileSync('scan.hocr', 'utf8');
371
355
 
372
356
  // Automatically detects hOCR and reconstructs tables
373
- const markdown = convert(hocrHtml, {
357
+ const result = convert(hocrHtml, {
374
358
  hocrSpatialTables: true // Enable spatial table reconstruction
375
359
  });
360
+
361
+ console.log(result.content);
362
+ console.log(`Found ${result.tables.length} tables`);
376
363
  ```
377
364
 
378
365
  ## Links
379
366
 
380
367
  - [GitHub Repository](https://github.com/kreuzberg-dev/html-to-markdown)
381
368
  - [Full Documentation](https://github.com/kreuzberg-dev/html-to-markdown/blob/main/README.md)
382
- - [WASM Package](https://www.npmjs.com/package/html-to-markdown-wasm)
369
+ - [WASM Package](https://www.npmjs.com/package/@kreuzberg/html-to-markdown-wasm)
383
370
  - [Python Package](https://pypi.org/project/html-to-markdown/)
384
371
  - [Rust Crate](https://crates.io/crates/html-to-markdown-rs)
385
372
 
package/index.d.ts CHANGED
@@ -1,122 +1,26 @@
1
1
  /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
-
4
- export declare class ExternalObject<T> {
5
- readonly '': {
6
- readonly '': unique symbol
7
- [K: symbol]: T
8
- }
9
- }
10
3
  /**
11
- * const { convert } = require('html-to-markdown');
4
+ * Convert HTML to Markdown, returning structured content, metadata, tables, and warnings.
12
5
  *
13
- * const html = '<h1>Hello World</h1>';
14
- * const markdown = convert(html);
15
- * console.log(markdown); // # Hello World
16
- * ```
17
- */
18
- export declare function convert(html: string, options?: JsConversionOptions | undefined | null, visitor?: object | undefined | null): string
19
-
20
- /** Convert HTML to Markdown from a Buffer/Uint8Array without creating intermediate JS strings. */
21
- export declare function convertBuffer(html: Buffer, options?: JsConversionOptions | undefined | null): string
22
-
23
- /** Convert HTML Buffer data using a previously-created `ConversionOptions` handle. */
24
- export declare function convertBufferWithOptionsHandle(html: Buffer, options: ExternalObject<RustConversionOptions>): string
25
-
26
- /** Convert inline images from Buffer/Uint8Array input without an intermediate string allocation. */
27
- export declare function convertInlineImagesBuffer(html: Buffer, options?: JsConversionOptions | undefined | null, imageConfig?: JsInlineImageConfig | undefined | null): JsHtmlExtraction
28
-
29
- /** Convert inline images from Buffer/Uint8Array input using a pre-created options handle. */
30
- export declare function convertInlineImagesBufferWithOptionsHandle(html: Buffer, options: ExternalObject<RustConversionOptions>, imageConfig?: JsInlineImageConfig | undefined | null): JsHtmlExtraction
31
-
32
- /**
33
- * Convert HTML to Markdown while collecting inline images
34
- *
35
- * # Arguments
36
- *
37
- * * `html` - The HTML string to convert
38
- * * `options` - Optional conversion options
39
- * * `image_config` - Configuration for inline image extraction
40
- * * `visitor` - Optional visitor object (when visitor feature is enabled)
41
- */
42
- export declare function convertWithInlineImages(html: string, options?: JsConversionOptions | undefined | null, imageConfig?: JsInlineImageConfig | undefined | null, visitor?: object | undefined | null): JsHtmlExtraction
43
-
44
- /** Convert HTML to Markdown while collecting inline images using a pre-created options handle. */
45
- export declare function convertWithInlineImagesHandle(html: string, options: ExternalObject<RustConversionOptions>, imageConfig?: JsInlineImageConfig | undefined | null): JsHtmlExtraction
46
-
47
- /**
48
- * Convert HTML to Markdown with metadata extraction.
49
- *
50
- * # Arguments
51
- *
52
- * * `html` - The HTML string to convert
53
- * * `options` - Optional conversion options
54
- * * `metadata_config` - Optional metadata extraction configuration
55
- * * `visitor` - Optional visitor object (when visitor feature is enabled)
6
+ * This is the primary API entry point. Returns a `JsConversionResult` object with
7
+ * `content`, `document`, `metadata`, `tables`, and `warnings` fields.
56
8
  *
57
9
  * # Example
58
10
  *
59
11
  * ```javascript
60
- * const { convertWithMetadata } = require('html-to-markdown');
12
+ * const { convert } = require('html-to-markdown');
61
13
  *
62
- * const html = '<html lang="en"><head><title>Test</title></head><body><h1>Hello</h1></body></html>';
63
- * const config = { extractHeaders: true, extractLinks: true };
64
- * const result = convertWithMetadata(html, undefined, config);
65
- * console.log(result.markdown);
66
- * console.log(result.metadata.document.title);
67
- * ```
68
- */
69
- export declare function convertWithMetadata(html: string, options?: JsConversionOptions | undefined | null, metadataConfig?: JsMetadataConfig | undefined | null, visitor?: object | undefined | null): JsMetadataExtraction
70
-
71
- /** Convert HTML from Buffer/Uint8Array with metadata extraction without intermediate string allocation. */
72
- export declare function convertWithMetadataBuffer(html: Buffer, options?: JsConversionOptions | undefined | null, metadataConfig?: JsMetadataConfig | undefined | null): JsMetadataExtraction
73
-
74
- /** Convert HTML from Buffer/Uint8Array with metadata extraction using a metadata handle. */
75
- export declare function convertWithMetadataBufferWithMetadataHandle(html: Buffer, metadataConfig: ExternalObject<RustMetadataConfig>): JsMetadataExtraction
76
-
77
- /** Convert HTML from Buffer/Uint8Array with metadata extraction using options + metadata handles. */
78
- export declare function convertWithMetadataBufferWithOptionsAndMetadataHandle(html: Buffer, options: ExternalObject<RustConversionOptions>, metadataConfig: ExternalObject<RustMetadataConfig>): JsMetadataExtraction
79
-
80
- /** Convert HTML from Buffer/Uint8Array with metadata extraction using a pre-created options handle. */
81
- export declare function convertWithMetadataBufferWithOptionsHandle(html: Buffer, options: ExternalObject<RustConversionOptions>, metadataConfig?: JsMetadataConfig | undefined | null): JsMetadataExtraction
14
+ * const html = '<h1>Hello</h1><p>World</p>';
15
+ * const result = convert(html);
16
+ * console.log(result.content); // '# Hello
82
17
 
83
- /** Convert HTML to Markdown with metadata extraction using a pre-created options handle. */
84
- export declare function convertWithMetadataHandle(html: string, options: ExternalObject<RustConversionOptions>, metadataConfig?: JsMetadataConfig | undefined | null): JsMetadataExtraction
85
-
86
- /** Convert HTML using a previously-created `ConversionOptions` handle. */
87
- export declare function convertWithOptionsHandle(html: string, options: ExternalObject<RustConversionOptions>): string
88
-
89
- /**
90
- * Convert HTML to Markdown with structured table extraction.
91
- *
92
- * Returns converted content alongside all tables found in the HTML.
93
- * When the metadata feature is enabled, metadata extraction is also performed.
94
- *
95
- * # Arguments
96
- *
97
- * * `html` - The HTML string to convert
98
- * * `options` - Optional conversion options
99
- * * `metadata_config` - Optional metadata extraction configuration (when metadata feature is enabled)
100
- *
101
- * # Example
102
- *
103
- * ```javascript
104
- * const { convertWithTables } = require('html-to-markdown');
105
- *
106
- * const html = '<table><tr><th>Name</th></tr><tr><td>Alice</td></tr></table>';
107
- * const result = convertWithTables(html);
108
- * console.log(result.tables[0].cells);
18
+ World'
19
+ * console.log(result.tables); // []
20
+ * console.log(result.warnings); // []
109
21
  * ```
110
22
  */
111
- export declare function convertWithTables(html: string, options?: JsConversionOptions | undefined | null, metadataConfig?: JsMetadataConfig | undefined | null): JsTableExtraction
112
-
113
- export declare function convertWithVisitor(html: string, options: JsConversionOptions | undefined | null, visitor: object): Promise<string>
114
-
115
- /** Create a reusable `ConversionOptions` handle. */
116
- export declare function createConversionOptionsHandle(options?: JsConversionOptions | undefined | null): ExternalObject<RustConversionOptions>
117
-
118
- /** Create a reusable `MetadataConfig` handle. */
119
- export declare function createMetadataConfigHandle(metadataConfig?: JsMetadataConfig | undefined | null): ExternalObject<RustMetadataConfig>
23
+ export declare function convert(html: string, options?: JsConversionOptions | undefined | null): JsConversionResult
120
24
 
121
25
  /** Code block style */
122
26
  export declare const enum JsCodeBlockStyle {
@@ -156,8 +60,6 @@ export interface JsConversionOptions {
156
60
  defaultTitle?: boolean
157
61
  /** Use <br> in tables instead of spaces */
158
62
  brInTables?: boolean
159
- /** Enable spatial table reconstruction in hOCR documents */
160
- hocrSpatialTables?: boolean
161
63
  /** Highlight style for <mark> elements */
162
64
  highlightStyle?: JsHighlightStyle
163
65
  /** Extract metadata from HTML */
@@ -196,39 +98,56 @@ export interface JsConversionOptions {
196
98
  skipImages?: boolean
197
99
  /** Output format for conversion */
198
100
  outputFormat?: JsOutputFormat
101
+ /** Include structured document tree in result */
102
+ includeDocumentStructure?: boolean
103
+ /** Extract inline images from data URIs and SVGs */
104
+ extractImages?: boolean
105
+ /** Maximum decoded image size in bytes */
106
+ maxImageSize?: bigint
107
+ /** Capture SVG elements as images */
108
+ captureSvg?: boolean
109
+ /** Infer image dimensions from data */
110
+ inferDimensions?: boolean
199
111
  }
200
112
 
201
- /** Document-level metadata */
202
- export interface JsDocumentMetadata {
203
- title?: string
204
- description?: string
205
- keywords: Array<string>
206
- author?: string
207
- canonical_url?: string
208
- base_href?: string
209
- language?: string
210
- text_direction?: string
211
- open_graph: Record<string, string>
212
- twitter_card: Record<string, string>
213
- meta_tags: Record<string, string>
113
+ /** Result of the v3 `convert()` API. */
114
+ export interface JsConversionResult {
115
+ /** Converted text output (markdown, djot, or plain text). Null when output is suppressed. */
116
+ content?: string
117
+ /** Structured document tree serialized as a JSON string, or null. */
118
+ document?: string
119
+ /** Extracted HTML metadata serialized as a JSON string, or null. */
120
+ metadata?: string
121
+ /** All tables found in the HTML, in document order. */
122
+ tables: Array<JsConversionTable>
123
+ /** Extracted inline images (data URIs and SVGs). */
124
+ images: Array<JsInlineImage>
125
+ /** Non-fatal processing warnings. */
126
+ warnings: Array<JsConversionWarning>
127
+ }
128
+
129
+ /** A table extracted by the v3 `convert()` API. */
130
+ export interface JsConversionTable {
131
+ grid: JsTableGrid
132
+ markdown: string
214
133
  }
215
134
 
216
- /** Complete extracted metadata */
217
- export interface JsExtendedMetadata {
218
- document: JsDocumentMetadata
219
- headers: Array<JsHeaderMetadata>
220
- links: Array<JsLinkMetadata>
221
- images: Array<JsImageMetadata>
222
- structuredData: Array<JsStructuredData>
135
+ /** Non-fatal warning emitted during conversion. */
136
+ export interface JsConversionWarning {
137
+ /** Human-readable warning message. */
138
+ message: string
139
+ /** Warning kind identifier. */
140
+ kind: string
223
141
  }
224
142
 
225
- /** Header element metadata */
226
- export interface JsHeaderMetadata {
227
- level: number
228
- text: string
229
- id?: string
230
- depth: number
231
- html_offset: number
143
+ /** A single cell in a structured table grid. */
144
+ export interface JsGridCell {
145
+ content: string
146
+ row: number
147
+ col: number
148
+ rowSpan: number
149
+ colSpan: number
150
+ isHeader: boolean
232
151
  }
233
152
 
234
153
  /** Heading style options */
@@ -253,26 +172,6 @@ export declare const enum JsHighlightStyle {
253
172
  None = 'None'
254
173
  }
255
174
 
256
- /** Result of HTML extraction with inline images */
257
- export interface JsHtmlExtraction {
258
- /** Converted markdown */
259
- markdown: string
260
- /** Extracted inline images */
261
- inlineImages: Array<JsInlineImage>
262
- /** Warnings encountered during extraction */
263
- warnings: Array<JsInlineImageWarning>
264
- }
265
-
266
- /** Image metadata */
267
- export interface JsImageMetadata {
268
- src: string
269
- alt?: string
270
- title?: string
271
- dimensions?: Array<number>
272
- image_type: string
273
- attributes: Record<string, string>
274
- }
275
-
276
175
  /** Inline image data */
277
176
  export interface JsInlineImage {
278
177
  /** Raw image data */
@@ -303,46 +202,12 @@ export interface JsInlineImageConfig {
303
202
  inferDimensions?: boolean
304
203
  }
305
204
 
306
- /** Warning about inline image processing */
307
- export interface JsInlineImageWarning {
308
- /** Index of the image that caused the warning */
309
- index: number
310
- /** Warning message */
311
- message: string
312
- }
313
-
314
- /** Hyperlink metadata */
315
- export interface JsLinkMetadata {
316
- href: string
317
- text: string
318
- title?: string
319
- link_type: string
320
- rel: Array<string>
321
- attributes: Record<string, string>
322
- }
323
-
324
205
  /** List indentation type */
325
206
  export declare const enum JsListIndentType {
326
207
  Spaces = 'Spaces',
327
208
  Tabs = 'Tabs'
328
209
  }
329
210
 
330
- /** Metadata extraction configuration */
331
- export interface JsMetadataConfig {
332
- extract_document?: boolean
333
- extract_headers?: boolean
334
- extract_links?: boolean
335
- extract_images?: boolean
336
- extract_structured_data?: boolean
337
- max_structured_data_size?: number
338
- }
339
-
340
- /** Result of conversion with metadata extraction */
341
- export interface JsMetadataExtraction {
342
- markdown: string
343
- metadata: JsExtendedMetadata
344
- }
345
-
346
211
  /** Newline style */
347
212
  export declare const enum JsNewlineStyle {
348
213
  /** Two spaces at end of line */
@@ -351,17 +216,6 @@ export declare const enum JsNewlineStyle {
351
216
  Backslash = 'Backslash'
352
217
  }
353
218
 
354
- /** Node context for visitor callbacks */
355
- export interface JsNodeContext {
356
- nodeType: string
357
- tagName: string
358
- attributes: Record<string, string>
359
- depth: number
360
- indexInParent: number
361
- parentTag?: string
362
- isInline: boolean
363
- }
364
-
365
219
  /** Output format for conversion */
366
220
  export declare const enum JsOutputFormat {
367
221
  /** Standard Markdown (CommonMark compatible) */
@@ -391,37 +245,11 @@ export declare const enum JsPreprocessingPreset {
391
245
  Aggressive = 'Aggressive'
392
246
  }
393
247
 
394
- /** Structured data (JSON-LD, Microdata, `RDFa`) */
395
- export interface JsStructuredData {
396
- data_type: string
397
- raw_json: string
398
- schema_type?: string
399
- }
400
-
401
- /** Extracted data from a single HTML `<table>` element. */
402
- export interface JsTableData {
403
- /** Table cells organized as rows x columns. */
404
- cells: Array<Array<string>>
405
- /** Complete rendered table in the target output format. */
406
- markdown: string
407
- /** Per-row flag indicating whether the row was inside `<thead>`. */
408
- isHeaderRow: Array<boolean>
409
- }
410
-
411
- /** Result of HTML-to-Markdown conversion with extracted table data. */
412
- export interface JsTableExtraction {
413
- /** Converted markdown/djot/plain text content. */
414
- content: string
415
- /** Extended metadata (present when metadata extraction was requested). */
416
- metadata?: JsExtendedMetadata
417
- /** All tables found in the HTML, in document order. */
418
- tables: Array<JsTableData>
419
- }
420
-
421
- /** Result of visitor callback */
422
- export interface JsVisitResult {
423
- type: string
424
- output?: string
248
+ /** Structured table grid with cell-level data. */
249
+ export interface JsTableGrid {
250
+ rows: number
251
+ cols: number
252
+ cells: Array<JsGridCell>
425
253
  }
426
254
 
427
255
  /** Whitespace handling mode */
@@ -429,7 +257,3 @@ export declare const enum JsWhitespaceMode {
429
257
  Normalized = 'Normalized',
430
258
  Strict = 'Strict'
431
259
  }
432
-
433
- export declare function startProfiling(outputPath: string, frequency?: number | undefined | null): void
434
-
435
- export declare function stopProfiling(): void
package/index.js CHANGED
@@ -77,8 +77,8 @@ function requireNative() {
77
77
  try {
78
78
  const binding = require('@kreuzberg/html-to-markdown-node-android-arm64')
79
79
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-android-arm64/package.json').version
80
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
80
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
82
82
  }
83
83
  return binding
84
84
  } catch (e) {
@@ -93,8 +93,8 @@ function requireNative() {
93
93
  try {
94
94
  const binding = require('@kreuzberg/html-to-markdown-node-android-arm-eabi')
95
95
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-android-arm-eabi/package.json').version
96
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
96
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
98
98
  }
99
99
  return binding
100
100
  } catch (e) {
@@ -114,8 +114,8 @@ function requireNative() {
114
114
  try {
115
115
  const binding = require('@kreuzberg/html-to-markdown-node-win32-x64-gnu')
116
116
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-win32-x64-gnu/package.json').version
117
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
117
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
119
119
  }
120
120
  return binding
121
121
  } catch (e) {
@@ -130,8 +130,8 @@ function requireNative() {
130
130
  try {
131
131
  const binding = require('@kreuzberg/html-to-markdown-node-win32-x64-msvc')
132
132
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-win32-x64-msvc/package.json').version
133
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
133
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
135
135
  }
136
136
  return binding
137
137
  } catch (e) {
@@ -147,8 +147,8 @@ function requireNative() {
147
147
  try {
148
148
  const binding = require('@kreuzberg/html-to-markdown-node-win32-ia32-msvc')
149
149
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-win32-ia32-msvc/package.json').version
150
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
150
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
152
152
  }
153
153
  return binding
154
154
  } catch (e) {
@@ -163,8 +163,8 @@ function requireNative() {
163
163
  try {
164
164
  const binding = require('@kreuzberg/html-to-markdown-node-win32-arm64-msvc')
165
165
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-win32-arm64-msvc/package.json').version
166
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
166
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
168
168
  }
169
169
  return binding
170
170
  } catch (e) {
@@ -182,8 +182,8 @@ function requireNative() {
182
182
  try {
183
183
  const binding = require('@kreuzberg/html-to-markdown-node-darwin-universal')
184
184
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-darwin-universal/package.json').version
185
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
185
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
187
187
  }
188
188
  return binding
189
189
  } catch (e) {
@@ -198,8 +198,8 @@ function requireNative() {
198
198
  try {
199
199
  const binding = require('@kreuzberg/html-to-markdown-node-darwin-x64')
200
200
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-darwin-x64/package.json').version
201
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
201
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
203
203
  }
204
204
  return binding
205
205
  } catch (e) {
@@ -214,8 +214,8 @@ function requireNative() {
214
214
  try {
215
215
  const binding = require('@kreuzberg/html-to-markdown-node-darwin-arm64')
216
216
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-darwin-arm64/package.json').version
217
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
217
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
219
219
  }
220
220
  return binding
221
221
  } catch (e) {
@@ -234,8 +234,8 @@ function requireNative() {
234
234
  try {
235
235
  const binding = require('@kreuzberg/html-to-markdown-node-freebsd-x64')
236
236
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-freebsd-x64/package.json').version
237
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
237
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
239
239
  }
240
240
  return binding
241
241
  } catch (e) {
@@ -250,8 +250,8 @@ function requireNative() {
250
250
  try {
251
251
  const binding = require('@kreuzberg/html-to-markdown-node-freebsd-arm64')
252
252
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-freebsd-arm64/package.json').version
253
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
253
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
255
255
  }
256
256
  return binding
257
257
  } catch (e) {
@@ -271,8 +271,8 @@ function requireNative() {
271
271
  try {
272
272
  const binding = require('@kreuzberg/html-to-markdown-node-linux-x64-musl')
273
273
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-linux-x64-musl/package.json').version
274
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
274
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
276
276
  }
277
277
  return binding
278
278
  } catch (e) {
@@ -287,8 +287,8 @@ function requireNative() {
287
287
  try {
288
288
  const binding = require('@kreuzberg/html-to-markdown-node-linux-x64-gnu')
289
289
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-linux-x64-gnu/package.json').version
290
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
290
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
292
292
  }
293
293
  return binding
294
294
  } catch (e) {
@@ -305,8 +305,8 @@ function requireNative() {
305
305
  try {
306
306
  const binding = require('@kreuzberg/html-to-markdown-node-linux-arm64-musl')
307
307
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-linux-arm64-musl/package.json').version
308
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
308
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
310
310
  }
311
311
  return binding
312
312
  } catch (e) {
@@ -321,8 +321,8 @@ function requireNative() {
321
321
  try {
322
322
  const binding = require('@kreuzberg/html-to-markdown-node-linux-arm64-gnu')
323
323
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-linux-arm64-gnu/package.json').version
324
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
324
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
326
326
  }
327
327
  return binding
328
328
  } catch (e) {
@@ -339,8 +339,8 @@ function requireNative() {
339
339
  try {
340
340
  const binding = require('@kreuzberg/html-to-markdown-node-linux-arm-musleabihf')
341
341
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-linux-arm-musleabihf/package.json').version
342
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
342
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
344
344
  }
345
345
  return binding
346
346
  } catch (e) {
@@ -355,8 +355,8 @@ function requireNative() {
355
355
  try {
356
356
  const binding = require('@kreuzberg/html-to-markdown-node-linux-arm-gnueabihf')
357
357
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-linux-arm-gnueabihf/package.json').version
358
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
358
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
360
360
  }
361
361
  return binding
362
362
  } catch (e) {
@@ -373,8 +373,8 @@ function requireNative() {
373
373
  try {
374
374
  const binding = require('@kreuzberg/html-to-markdown-node-linux-loong64-musl')
375
375
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-linux-loong64-musl/package.json').version
376
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
376
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
378
378
  }
379
379
  return binding
380
380
  } catch (e) {
@@ -389,8 +389,8 @@ function requireNative() {
389
389
  try {
390
390
  const binding = require('@kreuzberg/html-to-markdown-node-linux-loong64-gnu')
391
391
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-linux-loong64-gnu/package.json').version
392
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
392
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
394
394
  }
395
395
  return binding
396
396
  } catch (e) {
@@ -407,8 +407,8 @@ function requireNative() {
407
407
  try {
408
408
  const binding = require('@kreuzberg/html-to-markdown-node-linux-riscv64-musl')
409
409
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-linux-riscv64-musl/package.json').version
410
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
410
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
412
  }
413
413
  return binding
414
414
  } catch (e) {
@@ -423,8 +423,8 @@ function requireNative() {
423
423
  try {
424
424
  const binding = require('@kreuzberg/html-to-markdown-node-linux-riscv64-gnu')
425
425
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-linux-riscv64-gnu/package.json').version
426
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
426
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
428
428
  }
429
429
  return binding
430
430
  } catch (e) {
@@ -440,8 +440,8 @@ function requireNative() {
440
440
  try {
441
441
  const binding = require('@kreuzberg/html-to-markdown-node-linux-ppc64-gnu')
442
442
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-linux-ppc64-gnu/package.json').version
443
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
445
445
  }
446
446
  return binding
447
447
  } catch (e) {
@@ -456,8 +456,8 @@ function requireNative() {
456
456
  try {
457
457
  const binding = require('@kreuzberg/html-to-markdown-node-linux-s390x-gnu')
458
458
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-linux-s390x-gnu/package.json').version
459
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
459
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
461
461
  }
462
462
  return binding
463
463
  } catch (e) {
@@ -476,8 +476,8 @@ function requireNative() {
476
476
  try {
477
477
  const binding = require('@kreuzberg/html-to-markdown-node-openharmony-arm64')
478
478
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-openharmony-arm64/package.json').version
479
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
479
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
481
481
  }
482
482
  return binding
483
483
  } catch (e) {
@@ -492,8 +492,8 @@ function requireNative() {
492
492
  try {
493
493
  const binding = require('@kreuzberg/html-to-markdown-node-openharmony-x64')
494
494
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-openharmony-x64/package.json').version
495
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
495
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
497
497
  }
498
498
  return binding
499
499
  } catch (e) {
@@ -508,8 +508,8 @@ function requireNative() {
508
508
  try {
509
509
  const binding = require('@kreuzberg/html-to-markdown-node-openharmony-arm')
510
510
  const bindingPackageVersion = require('@kreuzberg/html-to-markdown-node-openharmony-arm/package.json').version
511
- if (bindingPackageVersion !== '2.30.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
- throw new Error(`Native binding package version mismatch, expected 2.30.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
511
+ if (bindingPackageVersion !== '3.0.0-rc.1' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
+ throw new Error(`Native binding package version mismatch, expected 3.0.0-rc.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
513
513
  }
514
514
  return binding
515
515
  } catch (e) {
@@ -579,21 +579,8 @@ module.exports = nativeBinding
579
579
  module.exports.convert = nativeBinding.convert
580
580
  module.exports.convertBuffer = nativeBinding.convertBuffer
581
581
  module.exports.convertBufferWithOptionsHandle = nativeBinding.convertBufferWithOptionsHandle
582
- module.exports.convertInlineImagesBuffer = nativeBinding.convertInlineImagesBuffer
583
- module.exports.convertInlineImagesBufferWithOptionsHandle = nativeBinding.convertInlineImagesBufferWithOptionsHandle
584
- module.exports.convertWithInlineImages = nativeBinding.convertWithInlineImages
585
- module.exports.convertWithInlineImagesHandle = nativeBinding.convertWithInlineImagesHandle
586
- module.exports.convertWithMetadata = nativeBinding.convertWithMetadata
587
- module.exports.convertWithMetadataBuffer = nativeBinding.convertWithMetadataBuffer
588
- module.exports.convertWithMetadataBufferWithMetadataHandle = nativeBinding.convertWithMetadataBufferWithMetadataHandle
589
- module.exports.convertWithMetadataBufferWithOptionsAndMetadataHandle = nativeBinding.convertWithMetadataBufferWithOptionsAndMetadataHandle
590
- module.exports.convertWithMetadataBufferWithOptionsHandle = nativeBinding.convertWithMetadataBufferWithOptionsHandle
591
- module.exports.convertWithMetadataHandle = nativeBinding.convertWithMetadataHandle
592
582
  module.exports.convertWithOptionsHandle = nativeBinding.convertWithOptionsHandle
593
- module.exports.convertWithTables = nativeBinding.convertWithTables
594
- module.exports.convertWithVisitor = nativeBinding.convertWithVisitor
595
583
  module.exports.createConversionOptionsHandle = nativeBinding.createConversionOptionsHandle
596
- module.exports.createMetadataConfigHandle = nativeBinding.createMetadataConfigHandle
597
584
  module.exports.JsCodeBlockStyle = nativeBinding.JsCodeBlockStyle
598
585
  module.exports.JsHeadingStyle = nativeBinding.JsHeadingStyle
599
586
  module.exports.JsHighlightStyle = nativeBinding.JsHighlightStyle
@@ -602,5 +589,3 @@ module.exports.JsNewlineStyle = nativeBinding.JsNewlineStyle
602
589
  module.exports.JsOutputFormat = nativeBinding.JsOutputFormat
603
590
  module.exports.JsPreprocessingPreset = nativeBinding.JsPreprocessingPreset
604
591
  module.exports.JsWhitespaceMode = nativeBinding.JsWhitespaceMode
605
- module.exports.startProfiling = nativeBinding.startProfiling
606
- module.exports.stopProfiling = nativeBinding.stopProfiling
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kreuzberg/html-to-markdown-node",
3
- "version": "2.30.0",
3
+ "version": "3.0.1",
4
4
  "description": "High-performance HTML to Markdown converter - Node.js native bindings",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -58,7 +58,7 @@
58
58
  "clean": "rm -rf dist node_modules *.node"
59
59
  },
60
60
  "devDependencies": {
61
- "@napi-rs/cli": "^3.5.1",
61
+ "@napi-rs/cli": "^3.6.0",
62
62
  "@types/node": "^25.5.0",
63
63
  "tsx": "^4.21.0",
64
64
  "vitest": "^4.1.2"