Port HTML-to-Markdown conversion from Oh My Pi's html module using html-to-markdown-rs. Exposes `htmlToMarkdown()` via N-API with options for content cleaning (strip nav/forms/headers/footers) and image skipping. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
24 lines
676 B
TypeScript
24 lines
676 B
TypeScript
/**
|
|
* HTML to Markdown conversion via native Rust bindings.
|
|
*
|
|
* Uses `html-to-markdown-rs` under the hood for high-performance
|
|
* conversion with optional content cleaning (stripping nav, forms, etc.).
|
|
*/
|
|
|
|
import { native } from "../native.js";
|
|
import type { HtmlToMarkdownOptions } from "./types.js";
|
|
|
|
export type { HtmlToMarkdownOptions };
|
|
|
|
/**
|
|
* Convert an HTML string to Markdown.
|
|
*
|
|
* When `cleanContent` is true, boilerplate elements (nav, forms, headers,
|
|
* footers) are stripped before conversion.
|
|
*/
|
|
export function htmlToMarkdown(
|
|
html: string,
|
|
options?: HtmlToMarkdownOptions,
|
|
): string {
|
|
return native.htmlToMarkdown(html, options ?? {}) as string;
|
|
}
|