Fix texturization of quotes when enclosed by angle brackets.
props miqrogroove. fixes #28718. git-svn-id: https://develop.svn.wordpress.org/trunk@28971 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
09efb2dab9
commit
ff3644a220
|
@ -104,11 +104,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.
|
||||
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 ) {
|
||||
$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.
|
||||
|
@ -126,12 +125,12 @@ function wptexturize($text, $reset = false) {
|
|||
|
||||
// Single quote at start, or preceded by (, {, <, [, ", -, or spaces.
|
||||
if ( "'" !== $opening_single_quote ) {
|
||||
$dynamic[ '/(?<=\A|[([{<"\-]|' . $spaces . ')\'/' ] = $opening_single_quote;
|
||||
$dynamic[ '/(?<=\A|[([{"\-]|<|' . $spaces . ')\'/' ] = $opening_single_quote;
|
||||
}
|
||||
|
||||
// Apostrophe in a word. No spaces, double apostrophes, or other punctuation.
|
||||
if ( "'" !== $apos ) {
|
||||
$dynamic[ '/(?<!' . $spaces . ')\'(?!\Z|[.,:;"\'(){}<>[\]\-]|' . $spaces . ')/' ] = $apos;
|
||||
$dynamic[ '/(?<!' . $spaces . ')\'(?!\Z|[.,:;"\'(){}[\]\-]|&[lg]t;|' . $spaces . ')/' ] = $apos;
|
||||
}
|
||||
|
||||
// 9" (double prime)
|
||||
|
@ -146,7 +145,7 @@ function wptexturize($text, $reset = false) {
|
|||
|
||||
// Double quote at start, or preceded by (, {, <, [, -, or spaces, and not followed by spaces.
|
||||
if ( '"' !== $opening_quote ) {
|
||||
$dynamic[ '/(?<=\A|[([{<\-]|' . $spaces . ')"(?!' . $spaces . ')/' ] = $opening_quote;
|
||||
$dynamic[ '/(?<=\A|[([{\-]|<|' . $spaces . ')"(?!' . $spaces . ')/' ] = $opening_quote;
|
||||
}
|
||||
|
||||
// Any remaining double quotes.
|
||||
|
@ -156,7 +155,7 @@ function wptexturize($text, $reset = false) {
|
|||
|
||||
// Single quotes followed by spaces or ending punctuation.
|
||||
if ( "'" !== $closing_single_quote ) {
|
||||
$dynamic[ '/\'(?=\Z|[.,)}>\-\]]|' . $spaces . ')/' ] = $closing_single_quote;
|
||||
$dynamic[ '/\'(?=\Z|[.,)}\-\]]|>|' . $spaces . ')/' ] = $closing_single_quote;
|
||||
}
|
||||
|
||||
// Dashes and spaces
|
||||
|
|
|
@ -117,6 +117,9 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase {
|
|||
$this->assertEquals('‘Class of ’99’s’', wptexturize("'Class of '99’s'"));
|
||||
//$this->assertEquals('“Class of 99”', wptexturize("\"Class of 99\""));
|
||||
$this->assertEquals('“Class of ’99”', wptexturize("\"Class of '99\""));
|
||||
$this->assertEquals('{“Class of ’99”}', wptexturize("{\"Class of '99\"}"));
|
||||
$this->assertEquals(' “Class of ’99” ', wptexturize(" \"Class of '99\" "));
|
||||
$this->assertEquals('}”Class of ’99″{', wptexturize("}\"Class of '99\"{")); // Not a quotation, may be between two other quotations.
|
||||
}
|
||||
|
||||
function test_quotes_after_numbers() {
|
||||
|
@ -346,12 +349,12 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase {
|
|||
"word [‘word word",
|
||||
),
|
||||
array(
|
||||
"word <'word word", // Invalid HTML input?
|
||||
"word <‘word word",
|
||||
"word <'word word", // Invalid HTML input triggers the apos in a word pattern.
|
||||
"word <’word word",
|
||||
),
|
||||
array(
|
||||
"word <'word word", // Valid HTML input triggers the apos in a word pattern
|
||||
"word <’word word",
|
||||
"word <'word word", // Valid HTML input makes curly quotes.
|
||||
"word <‘word word",
|
||||
),
|
||||
array(
|
||||
"word {'word word",
|
||||
|
@ -375,11 +378,11 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase {
|
|||
),
|
||||
array(
|
||||
"word<'word word",
|
||||
"word<‘word word",
|
||||
"word<’word word",
|
||||
),
|
||||
array(
|
||||
"word<'word word",
|
||||
"word<’word word",
|
||||
"word<‘word word",
|
||||
),
|
||||
array(
|
||||
"word{'word word",
|
||||
|
@ -402,12 +405,12 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase {
|
|||
"word [‘ word word",
|
||||
),
|
||||
array(
|
||||
"word <' word word", // Invalid HTML input?
|
||||
"word <‘ word word",
|
||||
"word <' word word",
|
||||
"word <’ word word",
|
||||
),
|
||||
array(
|
||||
"word <' word word", // Valid HTML input triggers the closing single quote here
|
||||
"word <’ word word",
|
||||
"word <' word word",
|
||||
"word <‘ word word",
|
||||
),
|
||||
array(
|
||||
"word {' word word",
|
||||
|
@ -431,11 +434,11 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase {
|
|||
),
|
||||
array(
|
||||
"word<' word word",
|
||||
"word<‘ word word",
|
||||
"word<’ word word",
|
||||
),
|
||||
array(
|
||||
"word<' word word",
|
||||
"word<’ word word",
|
||||
"word<‘ word word",
|
||||
),
|
||||
array(
|
||||
"word{' word word",
|
||||
|
@ -533,34 +536,30 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase {
|
|||
"word word’s word",
|
||||
),
|
||||
array(
|
||||
"word word'. word", // Quotes with outside punctuation could end with apostrophes instead of closing quotes (may affect i18n)
|
||||
"word word’. word",
|
||||
"word'[ word", // Apostrophes are never followed by opening punctuation.
|
||||
"word'[ word",
|
||||
),
|
||||
array(
|
||||
"word ]'. word",
|
||||
"word ]’. word",
|
||||
"word'( word",
|
||||
"word'( word",
|
||||
),
|
||||
array(
|
||||
"word )'. word",
|
||||
"word )’. word",
|
||||
"word'{ word",
|
||||
"word'{ word",
|
||||
),
|
||||
array(
|
||||
"word }'. word",
|
||||
"word }’. word",
|
||||
"word'< word",
|
||||
"word'< word",
|
||||
),
|
||||
array(
|
||||
"word >'. word", // Not tested
|
||||
"word >’. word",
|
||||
),
|
||||
array(
|
||||
"word >'. word",
|
||||
"word >’. word",
|
||||
"word'< word", // Invalid HTML input does trigger the apos pattern.
|
||||
"word’< word",
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Double quote after a space or ([{< becomes “ (opening_quote) if not followed by spaces
|
||||
* Double quote after a space or ([-{< becomes “ (opening_quote) if not followed by spaces
|
||||
*
|
||||
* Checks all baseline patterns. If anything ever changes in wptexturize(), these tests may fail.
|
||||
*
|
||||
|
@ -586,17 +585,25 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase {
|
|||
'word [“word word',
|
||||
),
|
||||
array(
|
||||
'word <"word word', // Invalid HTML input?
|
||||
'word <“word word',
|
||||
'word <"word word', // Invalid HTML input triggers the closing quote pattern.
|
||||
'word <”word word',
|
||||
),
|
||||
array(
|
||||
'word <"word word', // Valid HTML input triggers the closing quote pattern
|
||||
'word <”word word',
|
||||
'word <"word word',
|
||||
'word <“word word',
|
||||
),
|
||||
array(
|
||||
'word {"word word',
|
||||
'word {“word word',
|
||||
),
|
||||
array(
|
||||
'word -"word word',
|
||||
'word -“word word',
|
||||
),
|
||||
array(
|
||||
'word-"word word',
|
||||
'word-“word word',
|
||||
),
|
||||
array(
|
||||
'"word word',
|
||||
'“word word',
|
||||
|
@ -610,12 +617,12 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase {
|
|||
'word[“word word',
|
||||
),
|
||||
array(
|
||||
'word<"word word', // Invalid HTML input?
|
||||
'word<“word word',
|
||||
'word<"word word',
|
||||
'word<”word word',
|
||||
),
|
||||
array(
|
||||
'word<"word word', // Valid HTML input triggers the closing quote pattern
|
||||
'word<”word word',
|
||||
'word<"word word',
|
||||
'word<“word word',
|
||||
),
|
||||
array(
|
||||
'word{"word word',
|
||||
|
@ -698,7 +705,7 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test that single quotes followed by a space or a period become ’ (closing_single_quote)
|
||||
* Test that single quotes followed by a space or .,-)}]> become ’ (closing_single_quote)
|
||||
*
|
||||
* Checks all baseline patterns. If anything ever changes in wptexturize(), these tests may fail.
|
||||
*
|
||||
|
@ -727,6 +734,26 @@ class Tests_Formatting_WPTexturize extends WP_UnitTestCase {
|
|||
"word word', she said",
|
||||
"word word’, she said",
|
||||
),
|
||||
array(
|
||||
"word word'- word",
|
||||
"word word’- word",
|
||||
),
|
||||
array(
|
||||
"word word') word",
|
||||
"word word’) word",
|
||||
),
|
||||
array(
|
||||
"word word'} word",
|
||||
"word word’} word",
|
||||
),
|
||||
array(
|
||||
"word word'] word",
|
||||
"word word’] word",
|
||||
),
|
||||
array(
|
||||
"word word'> word",
|
||||
"word word’> word",
|
||||
),
|
||||
array(
|
||||
"word word'",
|
||||
"word word’",
|
||||
|
|
Loading…
Reference in New Issue