Skip to content

kaliberjs/html-to-portable-text

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kaliber HTML to portableText plugin

A plugin for converting html to portableText

Usage

htmlToPortableText(html, overrides = {})

const htmlToPortableText = require('@kaliber/html-to-portable-text')

const portableText = processHTML('<p><h1>This</strong><em>is HTML</em></p>')

function processHTML(html) {
  return removeUndefinedValues(htmlToPortableText(html, { h1: 'heading', h2: 'subheading' }))
}

function removeUndefinedValues(o) {
  return JSON.parse(JSON.stringify(o))
}

Development

> yarn
> yarn link
> yarn watch
yarn link @kaliber/html-to-portable-text

Publish

yarn publish
git push
git push --tags

Disclaimer

This library is intended for internal use, we provide no support, use at your own risk. It does not import React, but expects it to be provided, which @kaliber/build can handle for you.

This library is not transpiled.