☣️ The severity of the problem is high because the resulting templates/patterns are broken because the plugin is producing invalid markup.
How?
This PR improves the approach around escaping block strings for translation. It avoids the substring problem by just considering the HTML content block by block.
The new implementation consist of:
Parse the template markup with the core's function parse_blocks().
In the blocks that can contain text, use regex to update the HTML content of the block 'innetContent' property with the escaped text.
Serialize the template blocks to markup again using core's serialize_blocks() function.
What?
Fix template texts localizing/escaping.
Fixes: https://github.com/WordPress/create-block-theme/issues/632
Why?
The current implementation consisting of:
This approach is flawed because it fails, for example, when there are substrings. The problem is explained in this comment: https://github.com/WordPress/create-block-theme/issues/632#issuecomment-2112602045
☣️ The severity of the problem is high because the resulting templates/patterns are broken because the plugin is producing invalid markup.
How?
This PR improves the approach around escaping block strings for translation. It avoids the substring problem by just considering the HTML content block by block. The new implementation consist of:
parse_blocks().
serialize_blocks()
function.