[wp-trac] [WordPress Trac] #61817: wptexturize(): Hyphen may be replaced with ndash
WordPress Trac
noreply at wordpress.org
Sun Aug 4 13:59:03 UTC 2024
#61817: wptexturize(): Hyphen may be replaced with ndash
--------------------------+-----------------------------
Reporter: wildworks | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Formatting | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
This was originally reported as a Gutenberg issue:
https://github.com/WordPress/gutenberg/issues/64237
A strange issue has been reported where applying a text or background
color to hyphens in the content causes the characters to change size as
they are replaced with en-dashes.
I tracked down the problem and found that the characters were being
replaced by the `wptexturize()` function
[https://github.com/WordPress/WordPress/blob/822782a917bf08d2ce89901aba5942de0137127d
/wp-includes/block-template.php#L266 here].
When text is colored in the block editor, it is wrapped in a mark element
like this:
{{{
<p>Lorem<mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-
color has-accent-3-color">–</mark>ipsum</p>
}}}
So I tried adding `mark` to the
[https://github.com/WordPress/WordPress/blob/822782a917bf08d2ce89901aba5942de0137127d
/wp-includes/formatting.php#L106 $default_no_texturize_tags] variable
array and found that this solved the problem.
My guess is that we might need to update this variable so that all
elements used in inline formatting are allowed in it.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61817>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list