markdown-to-preact
Convert markdown to Preact components.
Installation
npm install markdown-to-preact
Usage
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 is false
.
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.