[Data Liberation] Block markup consumers and producers#2121
Merged
Conversation
Introduces a standardized API for converting between static data formats and blocks+metadata. * The `data format -> blocks+metadata` operation is represented by the WP_Data_Format_Consumer interface * The `blocks+metadata -> data format` operation is represented by the WP_Data_Format_Producer interface This PR also ships a few initial consumers and producers: * WP_Annotated_Block_Markup_Consumer – for consuming static block markup with `<meta>` tags. * WP_Markup_Processor_Consumer – for consuming an HTML/XHTML markup processor instance. It handles just the regular HTML/XHTML markup, not block markup. * WP_Annotated_Block_Markup_Producer – for serializing block markup + metadata array as block markup with `<meta>` tags This PR also ships the block parser from WordPress core to enable running unit tests – we need to call `parse_blocks()` now. ## Testing The code isn't used anywhere yet – just rely on the CI.
This was referenced Jan 10, 2025
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A part of #1894
Introduces a standardized API for converting between static data formats and blocks+metadata.
data format -> blocks+metadataoperation is represented by the WP_Data_Format_Consumer interfaceblocks+metadata -> data formatoperation is represented by the WP_Data_Format_Producer interfaceThis PR also ships a few initial consumers and producers:
WP_Annotated_Block_Markup_Consumer– for consuming static block markup with<meta>tags.WP_Markup_Processor_Consumer– for consuming an HTML/XHTML markup processor instance. It handles just the regular HTML/XHTML markup, not block markup.WP_Annotated_Block_Markup_Producer– for serializing block markup + metadata array as block markup with<meta>tagsExample
The two-way conversion pipeline shipped in this PR goes between this:
And this:
Other changes
This PR also ships the block parser from WordPress core to enable running unit tests – we need to call
parse_blocks()now.Testing
The code isn't used anywhere yet – just rely on the CI.