Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update PHP “parser” to recognize shorthand block syntax #1190

Merged
merged 3 commits into from
Jun 17, 2017

Conversation

westonruter
Copy link
Member

I noticed that the Latest Posts block failed to render on the frontend at all. This is due to the block using the void syntax from #1134, which was not likewise implemented in PHP.

This change will be irrelevant once there is a proper PHP parser (see #1152 and #1086).

@westonruter westonruter requested a review from nylen June 15, 2017 11:41
@westonruter westonruter changed the title Update PHP parser to recognize shorthand block syntax Update PHP “parser” to recognize shorthand block syntax Jun 15, 2017
lib/blocks.php Outdated
@@ -102,7 +102,7 @@ function do_blocks( $content ) {
global $wp_registered_blocks;

// Extract the blocks from the post content.
$open_matcher = '/<!--\s*wp:([a-z](?:[a-z0-9\/]+)*)\s+((?:(?!-->).)*)-->.*?<!--\s*\/wp:\g1\s+-->/';
$open_matcher = '/<!--\s*wp:([a-z](?:[a-z0-9\/]+)*)\s+((?:(?!-->).)*)\s*\/?-->(?:.*?<!--\s*\/wp:\g1\s+-->)?/';
Copy link
Member

@aduth aduth Jun 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rename this variable since it's not necessarily applying to openings only?

Also, this could match (or fail to match) some interesting variations: https://regex101.com/r/8hi4ds/2

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it can match or fail to match some variations but this is more due to the fundamental problem of there not being a proper grammar being implemented in PHP. For that see #1086 and #1152.

@westonruter westonruter merged commit 0579d08 into master Jun 17, 2017
@westonruter westonruter deleted the update/php-block-parser-for-empty-blocks branch June 17, 2017 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants