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.
In #4591 we build a custom parser for Gutenberg blocks whose intent was to skip building the entire parse tree and to replace dynamic blocks with their server-rendered output. This custom parser is designed to be faster than the full parse.
This custom parser has served well thanks to the work @aduth put into it but it diverges from one of the project goals, which is to have a clear semantic for how
post_content
translates in the editor and in page views.This PR is an attempt to "internalize" or "build natively" that same parser into the existing post grammar. Since the grammar defines concepts shared among the different parser productions we can overlap their code and keep the two in sync more easily when we remove that duplication. The PEG is also a bit more declarative and in my opinion easier to follow intent.
The main distinctions in these new rules and the main method of parsing follow:
Although my instinct tells me that this should be considerably faster than the default parser I don't have any measurements. That's being worked on thankfully in #6030 and other efforts right now to polish the flexibility of the parse system.
Currently this doesn't replace dynamic blocks with server-generated content but rather with the string
dynamic
. It would be helpful to me if someone could point me to an efficient way to find the right render callback and feed in the block attributes to it.