1.0.1 • Published 2 months ago

@dpatt/markdown-to-preact-parser v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

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.

1.0.1

2 months ago

1.0.0

2 months ago