Fix abbreviations mixed with quotes, example: '99% of people'
.
Add/alter unit tests. Props miqrogroove. Fixes #26850. git-svn-id: https://develop.svn.wordpress.org/trunk@28765 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
1f4d925102
commit
b11edb94d9
@ -111,17 +111,17 @@ function wptexturize($text, $reset = false) {
|
||||
$dynamic[ '/\'(\d\d)"(?=\Z|[.,)}>\-\]]|' . $spaces . ')/' ] = $apos . '$1' . $closing_quote;
|
||||
}
|
||||
|
||||
// '99 '99s '99's (apostrophe) But never '9 or '999 or '99.0.
|
||||
// '99 '99s '99's (apostrophe) But never '9 or '99% or '999 or '99.0.
|
||||
if ( "'" !== $apos ) {
|
||||
$dynamic[ '/\'(?=\d\d(?:\Z|(?!\d|[.,]\d)))/' ] = $apos;
|
||||
$dynamic[ '/\'(?=\d\d(?:\Z|(?![%\d]|[.,]\d)))/' ] = $apos;
|
||||
}
|
||||
|
||||
// Quoted Numbers like "42" or '42.00'
|
||||
if ( '"' !== $opening_quote && '"' !== $closing_quote ) {
|
||||
$dynamic[ '/(?<=\A|' . $spaces . ')"(\d[\d\.\,]*)"/' ] = $opening_quote . '$1' . $closing_quote;
|
||||
$dynamic[ '/(?<=\A|' . $spaces . ')"(\d[.,\d]*)"/' ] = $opening_quote . '$1' . $closing_quote;
|
||||
}
|
||||
if ( "'" !== $opening_single_quote && "'" !== $closing_single_quote ) {
|
||||
$dynamic[ '/(?<=\A|' . $spaces . ')\'(\d[\d\.\,]*)\'/' ] = $opening_single_quote . '$1' . $closing_single_quote;
|
||||
$dynamic[ '/(?<=\A|' . $spaces . ')\'(\d[.,\d]*)\'/' ] = $opening_single_quote . '$1' . $closing_single_quote;
|
||||
}
|
||||
|
||||
// Single quote at start, or preceded by (, {, <, [, ", -, or spaces.
|
||||
|
@ -313,8 +313,8 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase {
|
||||
"word ’99’s word",
|
||||
),
|
||||
array(
|
||||
"according to our source, '33% of all students scored less than 50' on the test.", // Apostrophes and primes have priority over quotes
|
||||
"according to our source, ’33% of all students scored less than 50′ on the test.",
|
||||
"according to our source, '33 students scored less than 50' on the test.", // Apostrophes and primes have priority over quotes
|
||||
"according to our source, ’33 students scored less than 50′ on the test.",
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -1060,12 +1060,12 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase {
|
||||
'word “4,242.00” word',
|
||||
),
|
||||
array(
|
||||
"word '99's word", // Is this correct?
|
||||
"word ‘99’s word",
|
||||
"word '99's word",
|
||||
"word ’99’s word",
|
||||
),
|
||||
array(
|
||||
"word '99'samsonite",
|
||||
"word ‘99’samsonite",
|
||||
"word ’99’samsonite",
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -1340,6 +1340,10 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase {
|
||||
"word '999 word", // Does not match the apos pattern, should be opening quote.
|
||||
"word ‘999 word",
|
||||
),
|
||||
array(
|
||||
"word '99% word",
|
||||
"word ‘99% word",
|
||||
),
|
||||
array(
|
||||
"word '9 word",
|
||||
"word ‘9 word",
|
||||
|
Loading…
Reference in New Issue
Block a user