patch submitted by hisham_hm
http://flatpress.org/vanilla2/discussion/1504/patch-bug-in-wptexturize-applying-smart-quotes-when-tags-are-nested#Item_1
This commit is contained in:
parent
7d12b43e16
commit
ebc41cdf8e
@ -9,11 +9,11 @@
|
|||||||
$output = '';
|
$output = '';
|
||||||
// Capture tags and everything inside them
|
// Capture tags and everything inside them
|
||||||
$textarr = preg_split("/(<.*>)/Us", $text, -1, PREG_SPLIT_DELIM_CAPTURE);
|
$textarr = preg_split("/(<.*>)/Us", $text, -1, PREG_SPLIT_DELIM_CAPTURE);
|
||||||
$stop = count($textarr); $next = true; // loop stuff
|
$stop = count($textarr); $skip = 0; // loop stuff
|
||||||
for ($i = 0; $i < $stop; $i++) {
|
for ($i = 0; $i < $stop; $i++) {
|
||||||
$curl = $textarr[$i];
|
$curl = $textarr[$i];
|
||||||
|
|
||||||
if (isset($curl{0}) && '<' != $curl{0} && $next) { // If it's not a tag
|
if (isset($curl{0}) && '<' != $curl{0} && $skip == 0) { // If it's not a tag
|
||||||
$curl = str_replace('---', '—', $curl);
|
$curl = str_replace('---', '—', $curl);
|
||||||
$curl = str_replace(' -- ', ' — ', $curl);
|
$curl = str_replace(' -- ', ' — ', $curl);
|
||||||
$curl = str_replace('--', '–', $curl);
|
$curl = str_replace('--', '–', $curl);
|
||||||
@ -46,12 +46,13 @@
|
|||||||
$curl = str_replace("''", '”', $curl);
|
$curl = str_replace("''", '”', $curl);
|
||||||
|
|
||||||
$curl = preg_replace('/(\d+)x(\d+)/', "$1×$2", $curl);
|
$curl = preg_replace('/(\d+)x(\d+)/', "$1×$2", $curl);
|
||||||
|
} elseif (strstr($curl, '</') || strstr($curl, '/>')) {
|
||||||
|
if ($skip > 0) $skip--;
|
||||||
} elseif (strstr($curl, '<code') || strstr($curl, '<pre') || strstr($curl, '<kbd' || strstr($curl, '<style') || strstr($curl, '<script'))) {
|
} elseif (strstr($curl, '<code') || strstr($curl, '<pre') || strstr($curl, '<kbd' || strstr($curl, '<style') || strstr($curl, '<script'))) {
|
||||||
// strstr is fast
|
// strstr is fast
|
||||||
$next = false;
|
$skip++;
|
||||||
} else {
|
} else {
|
||||||
$next = true;
|
if (isset($curl{0}) && $curl{0} == "<" && $skip > 0) $skip++;
|
||||||
}
|
}
|
||||||
$curl = preg_replace('/&([^#])(?![a-z12]{1,8};)/', '&$1', $curl);
|
$curl = preg_replace('/&([^#])(?![a-z12]{1,8};)/', '&$1', $curl);
|
||||||
$output .= $curl;
|
$output .= $curl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user