wphtml-converter icon indicating copy to clipboard operation
wphtml-converter copied to clipboard

Feature: add inner text / html support

Open DamChtlv opened this issue 2 years ago • 3 comments

Feature

This adds support for content & text attribute used by most low-level blocks (like heading, paragraph, button...) and so it keeps content inside them (some html tags are filtered, like RichText component does it).

It fixes this issue: #5 , it lacks some features still (like button link...) but still better than nothing

Test

Used this HTML gutenberg code to test the feature:

<!-- wp:heading -->
<h2 class="wp-block-heading">Default title</h2>
<!-- /wp:heading -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">H3 title</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Paragraph text</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><strong>Bold paragraph text</strong></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><em>Italic text</em></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><s>Strikethrough text</s></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><code>Code text</code></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><sup>Superscript text</sup></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><sub>Subscript text</sub></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><mark style="background-color:var(--wp--custom--color--primary--vert-macif)" class="has-inline-color has-contrast-color">Highlight text</mark></p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p><a href="#link">Link text</a></p>
<!-- /wp:paragraph -->

<!-- wp:buttons -->
<div class="wp-block-buttons"><!-- wp:button -->
<div class="wp-block-button"><a class="wp-block-button__link wp-element-button" href="#button-link">Button text</a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons -->

Result

Works for both PHP formatting and JS formatting:

Before:

happyprime github io_wphtml-converter_

After:

127 0 0 1_5500_index html

DamChtlv avatar Mar 29 '24 14:03 DamChtlv

Actually, i still need to work on it to add some html support (because text formatting wont be saved, like tags: <strong>, <em>...)

DamChtlv avatar Mar 29 '24 15:03 DamChtlv

Updated screenshots + description, should be good now

DamChtlv avatar Mar 29 '24 15:03 DamChtlv

Thanks @DamChtlv - I'm hoping to take a look at this soon. We've had a wild couple months. :)

jeremyfelt avatar Apr 24 '24 16:04 jeremyfelt