Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

6 stars

Watchers

8 watching

Forks

Releases

Packages

Contributors

Languages