API Reference
This document describes the public API of supermarkdown.
Functions
convert(html, options?)
Converts HTML to Markdown synchronously.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
html |
string |
Yes | The HTML string to convert |
options |
ConvertOptions |
No | Conversion options |
Returns
string - The converted Markdown
Example
import { convert } from '@vakra-dev/supermarkdown';
const markdown = convert('<h1>Hello</h1>');
console.log(markdown); // # Hello
convertAsync(html, options?)
Converts HTML to Markdown asynchronously. Use this for large documents to avoid blocking the main thread.
Parameters
Same as convert().
Returns
Promise<string> - A promise that resolves to the converted Markdown
Types
ConvertOptions
headingStyle'atx' | 'setext'- Style for headings. Default:'atx'linkStyle'inline' | 'referenced'- Style for links. Default:'inline'codeFence'`' | '~'- Character for code fences. Default:'`'bulletMarker'-' | '*' | '+'- Character for list bullets. Default:'-'baseUrlstring- Base URL for resolving relative linksexcludeSelectorsstring[]- CSS selectors for elements to excludeincludeSelectorsstring[]- CSS selectors to force include (overrides excludes)
Supported Elements
Block Elements
- Headings (
<h1>-<h6>) - Paragraphs (
<p>) - Lists (
<ul>,<ol>) - Code blocks (
<pre><code>) - Blockquotes (
<blockquote>) - Tables (
<table>)
Inline Elements
- Links (
<a>) - Images (
<img>) - Bold (
<strong>,<b>) - Italic (
<em>,<i>) - Code (
<code>) - Strikethrough (
<del>,<s>)