🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

storyblok-markdown-richtext

Package Overview
Dependencies
Maintainers
7
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

storyblok-markdown-richtext

A library to transform markdown to Richtext data

latest
Source
npmnpm
Version
1.0.3
Version published
Weekly downloads
2.4K
-18.69%
Maintainers
7
Weekly downloads
 
Created
Source

Storyblok Markdown to Richtext converter

Do you need help converting HTML or markdown into Storyblok's richtext format?

Here's how to use it:

Usage

Install the npm module storyblok-markdown-richtext by running:

$ yarn add storyblok-markdown-richtext # npm install storyblok-markdown-richtext

And use the functions where you need:

import { markdownToRichtext } from 'storyblok-markdown-richtext'

const richtextData = markdownToRichtext(`# Hello World`)

// ...

To convert HTML to richtext, you'll also need an HTML to markdown converter. In the example below, we use turndown.

import TurndownService from 'turndown'
import { markdownToRichtext } from 'storyblok-markdown-richtext'

const turndownService = new TurndownService()
const richtextData = markdownToRichtext(
	turndownService.turndown('<h1>Hello world!</h1>')
)

markdownToRichtext

This function transforms your HTML or markdown data into a richtext JSON object. Here's an example:

import { markdownToRichtext } from 'storyblok-markdown-richtext'

const richtextObject = markdownToRichtext(`# Hello World`)

The resulting richtext object will look like this:

{
  type: 'doc',
  content: [
    {
      type: 'heading',
      attrs: {
        level: 1
      },
      content: [
        {
          text: 'Hello World',
          type: 'text'
        }
      ]
    }
  ]
}

Powered by Storyblok

Keywords

storyblok

FAQs

Package last updated on 19 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts