bustle / mobiledoc-kit

A toolkit for building WYSIWYG editors with Mobiledoc
https://bustle.github.io/mobiledoc-kit/demo/
MIT License
1.55k stars 156 forks source link

Export modules useful for HTML processing #758

Closed claytongentry closed 2 years ago

claytongentry commented 2 years ago

Very similar to https://github.com/bustle/mobiledoc-kit/pull/755, but I thought Renderer is perhaps more in keeping with the pattern of these exports.

With these three modules working together, I can process HTML to Mobiledoc with the following pattern:

import { DOMParser, PostNodeBuilder as Builder, Renderer } from 'mobiledoc-kit'
import { JSDOM } from 'jsdom'

const html = "<h1>Hello, world</h1>"
const dom = new JSDOM(html)
const parser = new DOMParser(new Builder())
const post = parser.parse(dom.window.document.body)
Renderer.render(post, '0.3.2')