gutenberg-converter

1.0.1 • Public • Published

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>');

Readme

Keywords

none

Package Sidebar

Install

npm i gutenberg-converter

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

11 MB

Total Files

6

Last publish

Collaborators

  • marcofernandes