-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Data Liberation] Add HTML to Blocks converter
Adds a basic WP_HTML_To_Blocks class that accepts HTML and outputs block markup. It only considers the markup and won't consider any visual changes introduced via CSS or JavaScript. A part of #1894 ## Example ```html $html = <<<HTML <meta name="post_title" content="My first post"> <p>Hello <b>world</b>!</p> HTML; $converter = new WP_HTML_To_Blocks( $html ); $converter->convert(); var_dump( $converter->get_all_metadata() ); /* * array( 'post_title' => array( 'My first post' ) ) */ var_dump( $converter->get_block_markup() ); /* * <!-- wp:paragraph --> * <p>Hello <b>world</b>!</p> * <!-- /wp:paragraph --> */ ``` ## Testing instructions This PR mostly adds new code. Just confirm the unit tests pass in CI.
- Loading branch information
Showing
13 changed files
with
10,336 additions
and
3 deletions.
There are no files selected for viewing
Submodule blueprints-library
updated
4 files
+2 −2 | README.md | |
+3 −0 | composer.json | |
+1 −1 | src/WordPress/AsyncHttp/Client.php | |
+0 −10 | src/WordPress/AsyncHttp/Request.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
packages/playground/data-liberation/src/block-markup/WP_Block_Markup_Converter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
interface WP_Block_Markup_Converter { | ||
public function convert(); | ||
public function get_block_markup(); | ||
public function get_all_metadata(); | ||
public function get_meta_value( $key ); | ||
} |
Oops, something went wrong.