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: '-'
baseUrl
string - Base URL for resolving relative links
excludeSelectors
string[] - CSS selectors for elements to exclude
includeSelectors
string[] - CSS selectors to force include (overrides excludes)

Supported Elements

Block Elements
Inline Elements