Changeset 9
- Timestamp:
- 04/23/2003 01:21:54 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/b2-include/b2functions.php
r8 r9 49 49 50 50 /***** Formatting functions *****/ 51 function wptexturize($text) { 52 $textarr = preg_split("/(<.*>)/U", $text, -1, PREG_SPLIT_DELIM_CAPTURE); // capture the tags as well as in between 53 $stop = count($textarr); $next = true; // loop stuff 54 for ($i = 0; $i < $stop; $i++) { 55 $curl = $textarr[$i]; 56 if (!strstr($_SERVER['HTTP_USER_AGENT'], 'Gecko')) { 57 $curl = str_replace('<q>', '“', $curl); 58 $curl = str_replace('</q>', '”', $curl); 59 } 60 if ('<' != $curl{0} && $next) { // If it's not a tag 61 $curl = str_replace('---', '—', $curl); 62 $curl = str_replace('--', '–', $curl); 63 $curl = str_replace("...", '…', $curl); 64 $curl = str_replace('``', '“', $curl); 65 66 // This is a hack, look at this more later. It works pretty well though. 67 $cockney = array("'tain't","'twere","'twas","'tis","'twill","'til","'bout","'nuff","'round"); 68 $cockneyreplace = array("’tain’t","’twere","’twas","’tis","’twill","’til","’bout","’nuff","’round"); 69 $curl = str_replace($cockney, $cockneyreplace, $curl); 70 71 72 $curl = preg_replace("/'s/", "’s", $curl); 73 $curl = preg_replace("/'(\d\d(?:’|')?s)/", "’$1", $curl); 74 $curl = preg_replace('/(\s|\A|")\'/', '$1‘', $curl); 75 $curl = preg_replace("/(\d+)\"/", "$1″", $curl); 76 $curl = preg_replace("/(\d+)'/", "$1′", $curl); 77 $curl = preg_replace("/(\S)'([^'\s])/", "$1’$2", $curl); 78 $curl = preg_replace('/"([\s.]|\Z)/', '”$1', $curl); 79 $curl = preg_replace('/(\s|\A)"/', '$1“', $curl); 80 $curl = preg_replace("/'([\s.]|\Z)/", '’$1', $curl); 81 $curl = preg_replace("/\(tm\)/i", '™', $curl); 82 $curl = preg_replace("/\(c\)/i", '©', $curl); 83 $curl = preg_replace("/\(r\)/i", '®', $curl); 84 85 $curl = str_replace("''", '”', $curl); 86 $curl = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $curl); 87 88 $curl = preg_replace('/(d+)x(\d+)/', "$1×$2", $curl); 89 90 } elseif (strstr($curl, '<code') || strstr($curl, '<pre') || strstr($curl, '<kbd' || strstr($curl, '<style') || strstr($curl, '<script'))) { 91 // strstr is fast 92 $next = false; 93 } else { 94 $next = true; 95 } 96 $output .= $curl; 97 } 98 return $output; 99 } 51 100 52 101 function autobrize($content) {
Note: See TracChangeset
for help on using the changeset viewer.