Hands off pre tags. Props nbachiyski. fixes #7056
git-svn-id: http://svn.automattic.com/wordpress/trunk@8298 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0283fc3717
commit
0cd103e2a2
|
@ -3,6 +3,7 @@
|
||||||
function wptexturize($text) {
|
function wptexturize($text) {
|
||||||
global $wp_cockneyreplace;
|
global $wp_cockneyreplace;
|
||||||
$next = true;
|
$next = true;
|
||||||
|
$has_pre_parent = false;
|
||||||
$output = '';
|
$output = '';
|
||||||
$curl = '';
|
$curl = '';
|
||||||
$textarr = preg_split('/(<.*>|\[.*\])/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
|
$textarr = preg_split('/(<.*>|\[.*\])/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
|
||||||
|
@ -26,13 +27,17 @@ function wptexturize($text) {
|
||||||
for ( $i = 0; $i < $stop; $i++ ) {
|
for ( $i = 0; $i < $stop; $i++ ) {
|
||||||
$curl = $textarr[$i];
|
$curl = $textarr[$i];
|
||||||
|
|
||||||
if (isset($curl{0}) && '<' != $curl{0} && '[' != $curl{0} && $next) { // If it's not a tag
|
if (isset($curl{0}) && '<' != $curl{0} && '[' != $curl{0} && $next && !$has_pre_parent) { // If it's not a tag
|
||||||
// static strings
|
// static strings
|
||||||
$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);
|
||||||
} elseif (strpos($curl, '<code') !== false || strpos($curl, '<pre') !== false || strpos($curl, '<kbd') !== false || strpos($curl, '<style') !== false || strpos($curl, '<script') !== false) {
|
} elseif (strpos($curl, '<code') !== false || strpos($curl, '<kbd') !== false || strpos($curl, '<style') !== false || strpos($curl, '<script') !== false) {
|
||||||
$next = false;
|
$next = false;
|
||||||
|
} elseif (strpos($curl, '<pre') !== false) {
|
||||||
|
$has_pre_parent = true;
|
||||||
|
} elseif (strpos($curl, '</pre>') !== false) {
|
||||||
|
$has_pre_parent = false;
|
||||||
} else {
|
} else {
|
||||||
$next = true;
|
$next = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue