| 1 | *** C:\Documents and Settings\Elliott Back\My Documents\Website\wos_1.1.2\www\test2\wp-includes\functions-formatting.php Fri May 26 17:27:34 2006 |
|---|
| 2 | --- C:\Documents and Settings\Elliott Back\My Documents\Website\wos_1.1.2\www\test\wp-includes\functions-formatting.php Thu Jul 27 11:06:17 2006 |
|---|
| 3 | *************** |
|---|
| 4 | *** 1,49 **** |
|---|
| 5 | <?php |
|---|
| 6 | |
|---|
| 7 | function wptexturize($text) { |
|---|
| 8 | $output = ''; |
|---|
| 9 | ! // Capture tags and everything inside them |
|---|
| 10 | ! $textarr = preg_split("/(<.*>)/Us", $text, -1, PREG_SPLIT_DELIM_CAPTURE); |
|---|
| 11 | ! $stop = count($textarr); $next = true; // loop stuff |
|---|
| 12 | ! for ($i = 0; $i < $stop; $i++) { |
|---|
| 13 | $curl = $textarr[$i]; |
|---|
| 14 | ! |
|---|
| 15 | ! if (isset($curl{0}) && '<' != $curl{0} && $next) { // If it's not a tag |
|---|
| 16 | ! $curl = str_replace('---', '—', $curl); |
|---|
| 17 | ! $curl = str_replace(' -- ', ' — ', $curl); |
|---|
| 18 | ! $curl = str_replace('--', '–', $curl); |
|---|
| 19 | ! $curl = str_replace('xn–', 'xn--', $curl); |
|---|
| 20 | ! $curl = str_replace('...', '…', $curl); |
|---|
| 21 | ! $curl = str_replace('``', '“', $curl); |
|---|
| 22 | ! |
|---|
| 23 | ! // This is a hack, look at this more later. It works pretty well though. |
|---|
| 24 | ! $cockney = array("'tain't","'twere","'twas","'tis","'twill","'til","'bout","'nuff","'round","'cause"); |
|---|
| 25 | ! $cockneyreplace = array("’tain’t","’twere","’twas","’tis","’twill","’til","’bout","’nuff","’round","’cause"); |
|---|
| 26 | ! $curl = str_replace($cockney, $cockneyreplace, $curl); |
|---|
| 27 | ! |
|---|
| 28 | ! $curl = preg_replace("/'s/", '’s', $curl); |
|---|
| 29 | ! $curl = preg_replace("/'(\d\d(?:’|')?s)/", "’$1", $curl); |
|---|
| 30 | ! $curl = preg_replace('/(\s|\A|")\'/', '$1‘', $curl); |
|---|
| 31 | ! $curl = preg_replace('/(\d+)"/', '$1″', $curl); |
|---|
| 32 | ! $curl = preg_replace("/(\d+)'/", '$1′', $curl); |
|---|
| 33 | ! $curl = preg_replace("/(\S)'([^'\s])/", "$1’$2", $curl); |
|---|
| 34 | ! $curl = preg_replace('/(\s|\A)"(?!\s)/', '$1“$2', $curl); |
|---|
| 35 | ! $curl = preg_replace('/"(\s|\S|\Z)/', '”$1', $curl); |
|---|
| 36 | ! $curl = preg_replace("/'([\s.]|\Z)/", '’$1', $curl); |
|---|
| 37 | ! $curl = preg_replace("/ \(tm\)/i", ' ™', $curl); |
|---|
| 38 | ! $curl = str_replace("''", '”', $curl); |
|---|
| 39 | ! |
|---|
| 40 | ! $curl = preg_replace('/(\d+)x(\d+)/', "$1×$2", $curl); |
|---|
| 41 | ! |
|---|
| 42 | ! } elseif (strstr($curl, '<code') || strstr($curl, '<pre') || strstr($curl, '<kbd' || strstr($curl, '<style') || strstr($curl, '<script'))) { |
|---|
| 43 | ! // strstr is fast |
|---|
| 44 | ! $next = false; |
|---|
| 45 | ! } else { |
|---|
| 46 | ! $next = true; |
|---|
| 47 | ! } |
|---|
| 48 | ! $curl = preg_replace('/&([^#])(?![a-zA-Z1-4]{1,8};)/', '&$1', $curl); |
|---|
| 49 | ! $output .= $curl; |
|---|
| 50 | } |
|---|
| 51 | return $output; |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | --- 1,36 ---- |
|---|
| 55 | <?php |
|---|
| 56 | |
|---|
| 57 | function wptexturize($text) { |
|---|
| 58 | + $next = true; |
|---|
| 59 | $output = ''; |
|---|
| 60 | ! $curl = ''; |
|---|
| 61 | ! $textarr = preg_split('/(<.*>)/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE); |
|---|
| 62 | ! $stop = count($textarr); |
|---|
| 63 | ! |
|---|
| 64 | ! for($i = 0; $i < $stop; $i++){ |
|---|
| 65 | $curl = $textarr[$i]; |
|---|
| 66 | ! |
|---|
| 67 | ! if (isset($curl{0}) && '<' != $curl{0} && $next) { // If it's not a tag |
|---|
| 68 | ! // static strings |
|---|
| 69 | ! $static_characters = array('—', ' — ', '–', 'xn--', '…', '“', '\'tain\'t', '\'twere', '\'twas', '\'tis', '\'twill', '\'til', '\'bout', '\'nuff', '\'round', '\'cause', '\'s', '\'\'', ' (tm)'); |
|---|
| 70 | ! $static_replacements = array('---', ' -- ', '--', 'xn–', '...', '``', '’tain’t', '’twere', '’twas', '’tis', '’twill', '’til', '’bout', '’nuff', '’round', '’cause', '’s', '”', ' ™'); |
|---|
| 71 | ! $curl = str_replace($static_characters, $static_replacements, $curl); |
|---|
| 72 | ! |
|---|
| 73 | ! // regular expressions |
|---|
| 74 | ! $dynamic_characters = array('/\'(\d\d(?:’|\')?s)/', '/(\s|\A|")\'/', '/(\d+)"/', '/(\d+)\'/', '/(\S)\'([^\'\s])/', '/(\s|\A)"(?!\s)/', '/"(\s|\S|\Z)/', '/\'([\s.]|\Z)/', '/(\d+)x(\d+)/'); |
|---|
| 75 | ! $dynamic_replacements = array('’$1','$1‘', '$1″', '$1′', '$1’$2', '$1“$2', '”$1', '’$1', '$1×$2'); |
|---|
| 76 | ! $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl); |
|---|
| 77 | ! } elseif (strstr($curl, '<code') || strstr($curl, '<pre') || strstr($curl, '<kbd' || strstr($curl, '<style') || strstr($curl, '<script'))) { |
|---|
| 78 | ! // strstr is fast |
|---|
| 79 | ! $next = false; |
|---|
| 80 | ! } else { |
|---|
| 81 | ! $next = true; |
|---|
| 82 | ! } |
|---|
| 83 | ! |
|---|
| 84 | ! $curl = preg_replace('/&([^#])(?![a-zA-Z1-4]{1,8};)/', '&$1', $curl); |
|---|
| 85 | ! $output .= $curl; |
|---|
| 86 | } |
|---|
| 87 | + |
|---|
| 88 | return $output; |
|---|
| 89 | } |
|---|
| 90 | |
|---|