WordPress.org

Make WordPress Core

Ticket #7056: texturize-deep-pre.diff

File texturize-deep-pre.diff, 1.4 KB (added by nbachiyski, 10 years ago)
  • wp-includes/formatting.php

     
    33function wptexturize($text) {
    44        global $wp_cockneyreplace;
    55        $next = true;
     6        $has_pre_parent = false;
    67        $output = '';
    78        $curl = '';
    89        $textarr = preg_split('/(<.*>|\[.*\])/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
     
    2627        for ( $i = 0; $i < $stop; $i++ ) {
    2728                $curl = $textarr[$i];
    2829
    29                 if (isset($curl{0}) && '<' != $curl{0} && '[' != $curl{0} && $next) { // If it's not a tag
     30                if (isset($curl{0}) && '<' != $curl{0} && '[' != $curl{0} && $next && !$has_pre_parent) { // If it's not a tag
    3031                        // static strings
    3132                        $curl = str_replace($static_characters, $static_replacements, $curl);
    3233                        // regular expressions
    3334                        $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);
    34                 } elseif (strpos($curl, '<code') !== false || strpos($curl, '<pre') !== false || strpos($curl, '<kbd') !== false || strpos($curl, '<style') !== false || strpos($curl, '<script') !== false) {
     35                } elseif (strpos($curl, '<code') !== false || strpos($curl, '<kbd') !== false || strpos($curl, '<style') !== false || strpos($curl, '<script') !== false) {
    3536                        $next = false;
     37                } elseif (strpos($curl, '<pre') !== false) {
     38                        $has_pre_parent = true;
     39                } elseif (strpos($curl, '</pre>') !== false) {
     40                        $has_pre_parent = false;
    3641                } else {
    3742                        $next = true;
    3843