html-to-notion-blocks
Transform HTML to Notion blocks
Contents
What is this?
A small library that transforms HTML to Notion blocks. It is based on rehype-to-notion.
When should I use this?
You want a simple way to convert HTML to Notion blocks. If you want to control the conversion process, you should use rehype-to-notion instead.
Install
This package is ESM only. In Node.js (version 12.20+, 14.14+, 16.0+, or 18.0+).
pnpm add html-to-notion-blocks
Use
import { htmlToNotion } from 'html-to-notion-blocks'
const html = '<p>Hello world!</p>'
const notionBlocks = htmlToNotion(html)
console.log(notionBlocks)
API
htmlToNotion(html: string, options?: Options): NotionBlock[]
Transform HTML to Notion blocks.
Parameters
html
Type: string
The HTML to transform.
options
Type: Options
Options for the transformation.
See rehype-to-notion for the full list of options.
Security
Use of html-to-notion-blocks
can open you up to a [cross-site scripting (XSS)][xss] attack. If you are processing user input, be sure to use a HTML sanitizer, such as [rehype-sanitize][rehype-sanitize].
Related
- rehype-to-notion
— Transform HTML to Notion blocks
- [rehype-sanitize][rehype-sanitize]
- rehype
— HTML processor powered by plugins part of the unified collective
License
GPL-3.0-or-later © Thomas F. K. Jorna