Parser: Apply raw transforms to fallback content #2617
Closed
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.
Closes #2454
Closes #1728
This pull request seeks to extend raw transforms used in paste handling to fallback post content (freeform). This could be used to upgrade legacy content to compatible blocks, including images, paragraphs, and even shortcodes (providing a transition path for plugin authors and their existing shortcodes).
Implementation notes:
This pull request is a work-in-progress, and has encountered a number of hurdles:
removep
-delimited content (removep
replaces paragraphs with two subsequent line breaks). The implementation here appliesautop
to freeform content, assuming it to be from legacy posts (an open question as to whether this is a fair assumption).autop
, the paragraph block will now match a<p>[gallery]</p>
node, despite this being better suited as a gallery block. In the meantime, I have had to temporarily disable the paragraph block transform.As an alternative implementation, we could consider limiting these upgrades to either (a) specific string patterns and/or (b) shortcode detection.
Testing instructions:
Noting that this is still a work in progress, you can test the behavior by saving a post in the current post editor's HTML mode as such:
When reopening this post in Gutenberg, you should note that the gallery shortcode is replaced with a gallery block (currently best observed in Text mode, noting issues above about gallery block initializing only from IDs).