mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-03 15:08:10 +01:00
Revert changes to wptexturize() until test cases pass. Reverts [16280], [16378]. see #4539 and #15241.
git-svn-id: http://svn.automattic.com/wordpress/trunk@16409 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
200f550862
commit
3f5b442306
@ -56,25 +56,9 @@ function wptexturize($text) {
|
|||||||
$static_characters = array_merge(array('---', ' -- ', '--', ' - ', 'xn–', '...', '``', '\'\'', ' (tm)'), $cockney);
|
$static_characters = array_merge(array('---', ' -- ', '--', ' - ', 'xn–', '...', '``', '\'\'', ' (tm)'), $cockney);
|
||||||
$static_replacements = array_merge(array('—', ' — ', '–', ' – ', 'xn--', '…', $opening_quote, $closing_quote, ' ™'), $cockneyreplace);
|
$static_replacements = array_merge(array('—', ' — ', '–', ' – ', 'xn--', '…', $opening_quote, $closing_quote, ' ™'), $cockneyreplace);
|
||||||
|
|
||||||
$dynamic_map = array(
|
$dynamic_characters = array('/\'(\d\d(?:’|\')?s)/', '/\'(\d)/', '/(\s|\A|[([{<]|")\'/', '/(\d)"/', '/(\d)\'/', '/(\S)\'([^\'\s])/', '/(\s|\A|[([{<])"(?!\s)/', '/"(\s|\S|\Z)/', '/\'([\s.]|\Z)/', '/\b(\d+)x(\d+)\b/');
|
||||||
'/\'(\d)/' => '’$1', // '99
|
$dynamic_replacements = array('’$1','’$1', '$1‘', '$1″', '$1′', '$1’$2', '$1' . $opening_quote . '$2', $closing_quote . '$1', '’$1', '$1×$2');
|
||||||
|
|
||||||
'/\'([^\']*)\'([^\']*)\'/' => '‘$1’$2’', // 'test's'
|
|
||||||
|
|
||||||
'/(\w)\'(\w)/' => '$1’$2', // test's
|
|
||||||
|
|
||||||
'/\'([^\']*)\'/' => '‘$1’', // 'asd'
|
|
||||||
'/"([^"]*)"/' => $opening_quote . '$1' . $closing_quote, // "qwe"
|
|
||||||
|
|
||||||
'/(\d)"/' => '$1″', // 9" -> 9″
|
|
||||||
'/(\d)\'/' => '$1′', // 9' -> 9′
|
|
||||||
|
|
||||||
'/\b(\d+)x(\d+)\b/' => '$1×$2' // 10. 97x34 => 97×34
|
|
||||||
);
|
|
||||||
|
|
||||||
$dynamic_characters = array_keys($dynamic_map);
|
|
||||||
$dynamic_replacements = array_values($dynamic_map);
|
|
||||||
|
|
||||||
$static_setup = true;
|
$static_setup = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,9 +69,6 @@ function wptexturize($text) {
|
|||||||
|
|
||||||
$no_texturize_tags_stack = array();
|
$no_texturize_tags_stack = array();
|
||||||
$no_texturize_shortcodes_stack = array();
|
$no_texturize_shortcodes_stack = array();
|
||||||
|
|
||||||
$single_quote_state = '‘';
|
|
||||||
$double_quote_state = $opening_quote;
|
|
||||||
|
|
||||||
for ( $i = 0; $i < $stop; $i++ ) {
|
for ( $i = 0; $i < $stop; $i++ ) {
|
||||||
$curl = $textarr[$i];
|
$curl = $textarr[$i];
|
||||||
@ -99,15 +80,6 @@ function wptexturize($text) {
|
|||||||
$curl = str_replace($static_characters, $static_replacements, $curl);
|
$curl = str_replace($static_characters, $static_replacements, $curl);
|
||||||
// regular expressions
|
// regular expressions
|
||||||
$curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);
|
$curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);
|
||||||
// quotes that span multiple tags & shortcodes
|
|
||||||
while (($pos = strpos($curl, '\'')) !== FALSE) {
|
|
||||||
$curl = preg_replace('/\'/', $single_quote_state, $curl);
|
|
||||||
$single_quote_state = (($single_quote_state == '‘') ? '’' : '‘');
|
|
||||||
}
|
|
||||||
while (($pos = strpos($curl, '"')) !== FALSE) {
|
|
||||||
$curl = preg_replace('/"/', $double_quote_state, $curl);
|
|
||||||
$double_quote_state = (($double_quote_state == $opening_quote) ? $closing_quote : $opening_quote);
|
|
||||||
}
|
|
||||||
} elseif (!empty($curl)) {
|
} elseif (!empty($curl)) {
|
||||||
/*
|
/*
|
||||||
* Only call _wptexturize_pushpop_element if first char is correct
|
* Only call _wptexturize_pushpop_element if first char is correct
|
||||||
|
Loading…
Reference in New Issue
Block a user