happyprime / wphtml-converter

Converts WPHTML (WordPress block markup) to its JS/JSON or PHP forms.

Home Page:https://happyprime.github.io/wphtml-converter/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for text / content (html children)

DamChtlv opened this issue · comments

Thank you

To begin, awesome tool!
Really useful, thanks for that :)

Issue

Is it possible to add support for text / content attributes?
For example, a paragraph block contains this:

<!-- wp:paragraph {"fontSize":"texte-1"} -->
<p class="has-texte-1-font-size"><strong>Description. Lorem ipsum dolor sit amet consectetur. Faucibus sagittis varius at mattis malesuada venenatis. Facilisis id consequat nulla eget fusce tristique aenean tellus.</strong></p>
<!-- /wp:paragraph -->

Solution

It can be converted in PHP like so:

array(
    'core/paragraph',
    array(
        'fontSize' => 'texte-1',
        'content' => '<strong>Description. Lorem ipsum dolor sit amet consectetur. Faucibus sagittis varius at mattis malesuada venenatis. Facilisis id consequat nulla eget fusce tristique aenean tellus.</strong>',
    ),
    array()
),

Added a fix in this pull request: #6
Hope the owner sees it :)