htmlToMarkdown
Official
Converts HTML to a Markdown string.
Import:
import { htmlToMarkdown } from 'obsidian';Example:
console.log(htmlToMarkdown('<h1>foo</h1>')); // # fooconst el = createDiv();el.createEl('h2', { text: 'bar' });console.log(htmlToMarkdown(el)); // ## barconst fragment = createFragment();fragment.createEl('h3', { text: 'baz' });console.log(htmlToMarkdown(fragment)); // ### bazSignature:
function htmlToMarkdown(html: string | Document | DocumentFragment | HTMLElement): stringParameters:
| Parameter | Type | Description |
|---|---|---|
html | string | Document | DocumentFragment | HTMLElement |
Returns: string
Example:
console.log(htmlToMarkdown('<h1>foo</h1>')); // # fooconst el = createDiv();el.createEl('h2', { text: 'bar' });console.log(htmlToMarkdown(el)); // ## barconst fragment = createFragment();fragment.createEl('h3', { text: 'baz' });console.log(htmlToMarkdown(fragment)); // ### baz