Skip to content

CLI to convert HTML into Gutenberg blocks formatted HTML or JSON.

Notifications You must be signed in to change notification settings

front/gutenberg-converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gutenberg Converter

CLI to convert HTML into Gutenberg blocks formatted HTML or JSON.

Usage

Using the command line

Outputting a Gutenberg blocks formatted HTML string:

$ npx gutenberg-converter '<p>Some HTML</p>'

Result:

<!-- wp:paragraph -->
<p>Some HTML</p>
<!-- /wp:paragraph -->

Outputting a JSON string:

$ npx gutenber-converter '<p>some html</p>' --json

Result:

[
  {
    "clientId": "907a8493-3c91-4983-ae52-ccdce3fa14d8",
    "name": "core/paragraph",
    "isValid": true,
    "attributes": { "content": "Some HTML", "dropCap": false },
    "innerBlocks": []
  }
]

Using in a script

const { parse, parseToJSON } = require('gutenberg-converter');

const result = parse(`<p>Some HTML</p>`);

// or, if you want to output a JSON string.
const resultJson = parseToJSON('<p>Some HTML</p>');

About

CLI to convert HTML into Gutenberg blocks formatted HTML or JSON.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published