Skip to content

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

Merged
westonruter merged 3 commits intomasterfrom
update/php-block-parser-for-empty-blocks
Jun 17, 2017
Merged

Update PHP “parser” to recognize shorthand block syntax#1190
westonruter merged 3 commits intomasterfrom
update/php-block-parser-for-empty-blocks

Conversation

@westonruter
Copy link
Copy Markdown
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

// 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
Copy Markdown
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
Copy Markdown
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