@dpatt/markdown-to-preact-parser
v1.0.1
Published
Convert markdown content to an array of Preact components.
Readme
markdown-to-preact
Convert markdown to Preact components.
Installation
npm install markdown-to-preactUsage
markdownToPreact
Convert markdown content to an array of Preact components.
import { markdownToPreact } from 'markdown-to-preact';
const markdownContent = '# Hello, world!';
const components = markdownToPreact(markdownContent);
// Use `components` with Preact render function or other rendering methods.Options
allowDangerousHtml: (Optional) Allow dangerous HTML in the markdown. Default isfalse.
parseToPreact
Convert a DOM node to a Preact component.
import { parseToPreact } from 'markdown-to-preact';
const node = document.createElement('div');
const component = parseToPreact(node);
// Use `component` with Preact render function or other rendering methods.Examples
Convert Markdown to Preact
import { markdownToPreact } from 'markdown-to-preact';
const markdownContent = '# Hello, world!';
const components = markdownToPreact(markdownContent);
// Use `components` with Preact render function or other rendering methods.Convert DOM Node to Preact
import { parseToPreact } from 'markdown-to-preact';
const node = document.createElement('div');
const component = parseToPreact(node);
// Use `component` with Preact render function or other rendering methods.License
This project is licensed under the MIT License - see the LICENSE file for details.
