Improve the consistency of punctuation matching in `wptexturize()`.
Adds unit tests. Props miqrogroove. Fixes #31886. Built from https://develop.svn.wordpress.org/trunk@32789 git-svn-id: http://core.svn.wordpress.org/trunk@32760 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
7db2c06ab6
commit
2043805da4
|
@ -127,10 +127,10 @@ function wptexturize( $text, $reset = false ) {
|
||||||
|
|
||||||
// '99' and '99" are ambiguous among other patterns; assume it's an abbreviated year at the end of a quotation.
|
// '99' and '99" are ambiguous among other patterns; assume it's an abbreviated year at the end of a quotation.
|
||||||
if ( "'" !== $apos || "'" !== $closing_single_quote ) {
|
if ( "'" !== $apos || "'" !== $closing_single_quote ) {
|
||||||
$dynamic[ '/\'(\d\d)\'(?=\Z|[.,)}\-\]]|>|' . $spaces . ')/' ] = $apos . '$1' . $closing_single_quote;
|
$dynamic[ '/\'(\d\d)\'(?=\Z|[.,:;!?)}\-\]]|>|' . $spaces . ')/' ] = $apos . '$1' . $closing_single_quote;
|
||||||
}
|
}
|
||||||
if ( "'" !== $apos || '"' !== $closing_quote ) {
|
if ( "'" !== $apos || '"' !== $closing_quote ) {
|
||||||
$dynamic[ '/\'(\d\d)"(?=\Z|[.,)}\-\]]|>|' . $spaces . ')/' ] = $apos . '$1' . $closing_quote;
|
$dynamic[ '/\'(\d\d)"(?=\Z|[.,:;!?)}\-\]]|>|' . $spaces . ')/' ] = $apos . '$1' . $closing_quote;
|
||||||
}
|
}
|
||||||
|
|
||||||
// '99 '99s '99's (apostrophe) But never '9 or '99% or '999 or '99.0.
|
// '99 '99s '99's (apostrophe) But never '9 or '99% or '999 or '99.0.
|
||||||
|
@ -150,7 +150,7 @@ function wptexturize( $text, $reset = false ) {
|
||||||
|
|
||||||
// Apostrophe in a word. No spaces, double apostrophes, or other punctuation.
|
// Apostrophe in a word. No spaces, double apostrophes, or other punctuation.
|
||||||
if ( "'" !== $apos ) {
|
if ( "'" !== $apos ) {
|
||||||
$dynamic[ '/(?<!' . $spaces . ')\'(?!\Z|[.,:;"\'(){}[\]\-]|&[lg]t;|' . $spaces . ')/' ] = $apos;
|
$dynamic[ '/(?<!' . $spaces . ')\'(?!\Z|[.,:;!?"\'(){}[\]\-]|&[lg]t;|' . $spaces . ')/' ] = $apos;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 9' (prime)
|
// 9' (prime)
|
||||||
|
@ -160,7 +160,7 @@ function wptexturize( $text, $reset = false ) {
|
||||||
|
|
||||||
// Single quotes followed by spaces or ending punctuation.
|
// Single quotes followed by spaces or ending punctuation.
|
||||||
if ( "'" !== $closing_single_quote ) {
|
if ( "'" !== $closing_single_quote ) {
|
||||||
$dynamic[ '/\'(?=\Z|[.,)}\-\]]|>|' . $spaces . ')/' ] = $closing_single_quote;
|
$dynamic[ '/\'(?=\Z|[.,:;!?)}\-\]]|>|' . $spaces . ')/' ] = $closing_single_quote;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dynamic_characters['apos'] = array_keys( $dynamic );
|
$dynamic_characters['apos'] = array_keys( $dynamic );
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.3-alpha-32788';
|
$wp_version = '4.3-alpha-32789';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue