Changeset 2015 for trunk/vendor/Text
- Timestamp:
- 07/20/07 09:03:04 (18 months ago)
- Location:
- trunk/vendor/Text
- Files:
-
- 1 added
- 2 removed
- 22 modified
-
Wiki.php (modified) (20 diffs)
-
Wiki/Mediawiki.php (deleted)
-
Wiki/Parse.php (modified) (2 diffs)
-
Wiki/Parse/Default/Blockquote.php (modified) (7 diffs)
-
Wiki/Parse/Default/Code.php (modified) (4 diffs)
-
Wiki/Parse/Default/Freelink.php (modified) (4 diffs)
-
Wiki/Parse/Default/Prefilter.php (modified) (2 diffs)
-
Wiki/Parse/Default/Wikilink.php (modified) (6 diffs)
-
Wiki/Parse/Mediawiki (deleted)
-
Wiki/Render/Latex/Url.php (modified) (3 diffs)
-
Wiki/Render/Plain/Url.php (modified) (1 diff)
-
Wiki/Render/Xhtml/Address.php (added)
-
Wiki/Render/Xhtml/Blockquote.php (modified) (2 diffs)
-
Wiki/Render/Xhtml/Bold.php (modified) (1 diff)
-
Wiki/Render/Xhtml/Box.php (modified) (3 diffs)
-
Wiki/Render/Xhtml/Center.php (modified) (3 diffs)
-
Wiki/Render/Xhtml/Code.php (modified) (4 diffs)
-
Wiki/Render/Xhtml/Image.php (modified) (3 diffs)
-
Wiki/Render/Xhtml/Interwiki.php (modified) (2 diffs)
-
Wiki/Render/Xhtml/Italic.php (modified) (1 diff)
-
Wiki/Render/Xhtml/Phplookup.php (modified) (2 diffs)
-
Wiki/Render/Xhtml/Preformatted.php (modified) (2 diffs)
-
Wiki/Render/Xhtml/Underline.php (modified) (1 diff)
-
Wiki/Render/Xhtml/Url.php (modified) (4 diffs)
-
Wiki/Render/Xhtml/Wikilink.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/vendor/Text/Wiki.php
r1128 r2015 10 10 * @author Paul M. Jones <pmjones@php.net> 11 11 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 12 * @version CVS: $Id: Wiki.php,v 1. 48 2006/10/10 19:34:38justinpatrin Exp $12 * @version CVS: $Id: Wiki.php,v 1.51 2007/06/09 23:17:46 justinpatrin Exp $ 13 13 * @link http://pear.php.net/package/Text_Wiki 14 14 */ … … 34 34 * @author Paul M. Jones <pmjones@php.net> 35 35 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 36 * @version Release: 1.2.0 RC136 * @version Release: 1.2.0 37 37 * @link http://pear.php.net/package/Text_Wiki 38 38 */ … … 257 257 var $source = ''; 258 258 259 /** 260 * The output text 261 * 262 * @var string 263 */ 264 var $output = ''; 265 259 266 260 267 /** … … 338 345 /** 339 346 * Temporary configuration variable 347 * 348 * @var string 340 349 */ 341 350 var $renderingType = 'preg'; 342 351 343 352 /** 353 * Stack of rendering callbacks 354 * 355 * @var Array 356 */ 357 var $_renderCallbacks = array(); 358 359 /** 360 * Current output block 361 * 362 * @var string 363 */ 364 var $_block; 365 366 /** 367 * A stack of blocks 368 * 369 * @param Array 370 */ 371 var $_blocks; 372 373 /** 344 374 * 345 375 * Constructor. … … 357 387 { 358 388 if (is_array($rules)) { 359 $this->rules = $rules; 389 $this->rules = array(); 390 foreach ($rules as $rule) { 391 $this->rules[] = ucfirst($rule); 392 } 360 393 } 361 394 … … 409 442 * @return &object a reference to the Text_Wiki unique instantiation. 410 443 */ 411 function singleton($parser = 'Default', $rules = null)444 function &singleton($parser = 'Default', $rules = null) 412 445 { 413 446 static $only = array(); 414 447 if (!isset($only[$parser])) { 415 $ret = Text_Wiki::factory($parser, $rules);448 $ret = & Text_Wiki::factory($parser, $rules); 416 449 if (Text_Wiki::isError($ret)) { 417 450 return $ret; 418 451 } 419 $only[$parser] = $ret;452 $only[$parser] =& $ret; 420 453 } 421 454 return $only[$parser]; … … 433 466 * @return Text_Wiki a Parser object extended from Text_Wiki 434 467 */ 435 function factory($parser = 'Default', $rules = null)468 function &factory($parser = 'Default', $rules = null) 436 469 { 437 470 $class = 'Text_Wiki_' . $parser; … … 446 479 } 447 480 448 $obj = new $class($rules);481 $obj =& new $class($rules); 449 482 return $obj; 450 483 } … … 921 954 // load may have failed; only parse if 922 955 // an object is in the array now 923 if (is set($this->parseObj[$name]) && is_object($this->parseObj[$name])) {956 if (is_object($this->parseObj[$name])) { 924 957 $this->parseObj[$name]->parse(); 925 958 } … … 949 982 950 983 // the eventual output text 951 $ output = '';984 $this->output = ''; 952 985 953 986 // when passing through the parsed source text, keep track of when … … 966 999 // pre-rendering activity 967 1000 if (is_object($this->formatObj[$format])) { 968 $ output .= $this->formatObj[$format]->pre();1001 $this->output .= $this->formatObj[$format]->pre(); 969 1002 } 970 1003 … … 975 1008 976 1009 if ($this->renderingType == 'preg') { 977 $ output = preg_replace_callback('/'.$this->delim.'(\d+)'.$this->delim.'/',1010 $this->output = preg_replace_callback('/'.$this->delim.'(\d+)'.$this->delim.'/', 978 1011 array(&$this, '_renderToken'), 979 1012 $this->source); 1013 /* 1014 //Damn strtok()! Why does it "skip" empty parts of the string. It's useless now! 1015 } elseif ($this->renderingType == 'strtok') { 1016 echo '<pre>'.htmlentities($this->source).'</pre>'; 1017 $t = strtok($this->source, $this->delim); 1018 $inToken = true; 1019 $i = 0; 1020 while ($t !== false) { 1021 echo 'Token: '.$i.'<pre>"'.htmlentities($t).'"</pre><br/><br/>'; 1022 if ($inToken) { 1023 //$this->output .= $this->renderObj[$this->tokens[$t][0]]->token($this->tokens[$t][1]); 1024 } else { 1025 $this->output .= $t; 1026 } 1027 $inToken = !$inToken; 1028 $t = strtok($this->delim); 1029 ++$i; 1030 } 1031 */ 980 1032 } else { 981 1033 // pass through the parsed source text character by character 1034 $this->_block = ''; 1035 $tokenStack = array(); 982 1036 $k = strlen($this->source); 983 1037 for ($i = 0; $i < $k; $i++) { … … 991 1045 // yes; are we ending the section? 992 1046 if ($char == $this->delim) { 1047 1048 if (count($this->_renderCallbacks) == 0) { 1049 $this->output .= $this->_block; 1050 $this->_block = ''; 1051 } 1052 1053 if (isset($opts['type'])) { 1054 if ($opts['type'] == 'start') { 1055 array_push($tokenStack, $rule); 1056 } elseif ($opts['type'] == 'end') { 1057 if ($tokenStack[count($tokenStack) - 1] != $rule) { 1058 return Text_Wiki::error('Unbalanced tokens, check your syntax'); 1059 } else { 1060 array_pop($tokenStack); 1061 } 1062 } 1063 } 993 1064 994 1065 // yes, get the replacement text for the delimited … … 997 1068 $rule = $this->tokens[$key][0]; 998 1069 $opts = $this->tokens[$key][1]; 999 $ output.= $this->renderObj[$rule]->token($opts);1070 $this->_block .= $this->renderObj[$rule]->token($opts); 1000 1071 $in_delim = false; 1001 1072 1002 1073 } else { 1003 1074 1004 // no, add to the d limited token key number1075 // no, add to the delimited token key number 1005 1076 $key .= $char; 1006 1077 … … 1016 1087 $key = ''; 1017 1088 $in_delim = true; 1089 1018 1090 } else { 1019 1091 // no, add to the output as-is 1020 $ output.= $char;1092 $this->_block .= $char; 1021 1093 } 1022 1094 } … … 1024 1096 } 1025 1097 1098 if (count($this->_renderCallbacks)) { 1099 return $this->error('Render callbacks left over after processing finished'); 1100 } 1101 /* 1102 while (count($this->_renderCallbacks)) { 1103 $this->popRenderCallback(); 1104 } 1105 */ 1106 if (strlen($this->_block)) { 1107 $this->output .= $this->_block; 1108 $this->_block = ''; 1109 } 1110 1026 1111 // post-rendering activity 1027 1112 if (is_object($this->formatObj[$format])) { 1028 $ output .= $this->formatObj[$format]->post();1113 $this->output .= $this->formatObj[$format]->post(); 1029 1114 } 1030 1115 1031 1116 // return the rendered source text. 1032 return $ output;1117 return $this->output; 1033 1118 } 1034 1119 … … 1044 1129 } 1045 1130 1131 function registerRenderCallback($callback) { 1132 $this->_blocks[] = $this->_block; 1133 $this->_block = ''; 1134 $this->_renderCallbacks[] = $callback; 1135 } 1136 1137 function popRenderCallback() { 1138 if (count($this->_renderCallbacks) == 0) { 1139 return Text_Wiki::error('Render callback popped when no render callbacks in stack'); 1140 } else { 1141 $callback = array_pop($this->_renderCallbacks); 1142 $this->_block = call_user_func($callback, $this->_block); 1143 if (count($this->_blocks)) { 1144 $parentBlock = array_pop($this->_blocks); 1145 $this->_block = $parentBlock.$this->_block; 1146 } 1147 if (count($this->_renderCallbacks) == 0) { 1148 $this->output .= $this->_block; 1149 $this->_block = ''; 1150 } 1151 } 1152 } 1046 1153 1047 1154 /** … … 1223 1330 } 1224 1331 1225 $this->parseObj[$rule] = new $class($this);1332 $this->parseObj[$rule] =& new $class($this); 1226 1333 1227 1334 } … … 1259 1366 } 1260 1367 1261 $this->renderObj[$rule] = new $class($this);1368 $this->renderObj[$rule] =& new $class($this); 1262 1369 } 1263 1370 … … 1292 1399 } 1293 1400 1294 $this->formatObj[$format] = new $class($this);1401 $this->formatObj[$format] =& new $class($this); 1295 1402 } 1296 1403 -
trunk/vendor/Text/Wiki/Parse.php
r1162 r2015 234 234 // find the =" sections; 235 235 $tmp = explode('="', trim($text)); 236 $mark = '"';237 238 if (count($tmp) == 1) {239 $tmp = explode("='", trim($text));240 $mark = "'";241 }242 236 243 237 // basic setup … … 258 252 // the part to the left is the value for the last key, 259 253 // the part to the right is the next key name 260 $pos = strrpos($val, $mark);254 $pos = strrpos($val, '"'); 261 255 $attrs[$key] = stripslashes(substr($val, 0, $pos)); 262 256 $key = trim(substr($val, $pos+1)); 263 257 264 258 } 259 265 260 return $attrs; 266 261 -
trunk/vendor/Text/Wiki/Parse/Default/Blockquote.php
r1125 r2015 13 13 * @license LGPL 14 14 * 15 * @version $Id: Blockquote.php,v 1. 3 2005/02/23 17:38:29 pmjonesExp $15 * @version $Id: Blockquote.php,v 1.4 2006/10/21 05:56:28 justinpatrin Exp $ 16 16 * 17 17 */ … … 77 77 { 78 78 // the replacement text we will return to parse() 79 $return = '';79 $return = "\n"; 80 80 81 81 // the list of post-processing matches … … 92 92 ); 93 93 94 // a stack of starts and ends; we keep this so that we know what 95 // indent level we're at. 96 $stack = array(); 97 94 $curLevel = 0; 95 98 96 // loop through each list-item element. 99 97 foreach ($list as $key => $val) { … … 106 104 $level = strlen($val[1]); 107 105 108 // get the text of the line109 $text = $val[2];110 111 106 // add a level to the list? 112 while ($level > count($stack)) { 113 107 while ($level > $curLevel) { 114 108 // the current indent level is greater than the number 115 109 // of stack elements, so we must be starting a new 116 110 // level. push the new level onto the stack with a 117 111 // dummy value (boolean true)... 118 array_push($stack, true);112 ++$curLevel; 119 113 120 $return .= "\n";114 //$return .= "\n"; 121 115 122 116 // ...and add a start token to the return. … … 125 119 array( 126 120 'type' => 'start', 127 'level' => $ level - 1121 'level' => $curLevel 128 122 ) 129 123 ); 130 124 131 $return .= "\n\n";125 //$return .= "\n\n"; 132 126 } 133 127 134 128 // remove a level? 135 while ( count($stack)> $level) {129 while ($curLevel > $level) { 136 130 137 131 // as long as the stack count is greater than the … … 139 133 // continue adding end-list tokens until the stack count 140 134 // and the indent level are the same. 141 array_pop($stack);142 135 143 $return .= "\n\n";136 //$return .= "\n\n"; 144 137 145 138 $return .= $this->wiki->addToken( … … 147 140 array ( 148 141 'type' => 'end', 149 'level' => count($stack)142 'level' => $curLevel 150 143 ) 151 144 ); 152 145 153 $return .= "\n"; 146 //$return .= "\n"; 147 --$curLevel; 154 148 } 155 149 156 150 // add the line text. 157 $return .= $ text;151 $return .= $val[2]; 158 152 } 153 154 // the last char of the matched pattern must be \n but we don't 155 // want this to be inside the tokens 156 $return = substr($return, 0, -1); 159 157 160 158 // the last line may have been indented. go through the stack 161 159 // and create end-tokens until the stack is empty. 162 $return .= "\n"; 163 164 while (count($stack) > 0) { 165 array_pop($stack); 160 //$return .= "\n"; 161 162 while ($curLevel > 0) { 166 163 $return .= $this->wiki->addToken( 167 164 $this->rule, 168 165 array ( 169 166 'type' => 'end', 170 'level' => count($stack)167 'level' => $curLevel 171 168 ) 172 169 ); 170 --$curLevel; 173 171 } 174 172 173 // put back the trailing \n 174 $return .= "\n"; 175 175 176 // we're done! send back the replacement text. 176 return "\n$return\n\n";177 return $return; 177 178 } 178 179 } -
trunk/vendor/Text/Wiki/Parse/Default/Code.php
r1760 r2015 13 13 * @license LGPL 14 14 * 15 * @version $Id: Code.php,v 1.1 0 2006/02/21 14:33:53 togggExp $15 * @version $Id: Code.php,v 1.11 2007/06/09 23:11:25 justinpatrin Exp $ 16 16 * 17 17 */ … … 51 51 52 52 /* var $regex = '/^(\<code( .+)?\>)\n(.+)\n(\<\/code\>)(\s|$)/Umsi';*/ 53 /* var $regex = ';^<code(\s[^>]*)?>((?:(?R)|.)*?)\n</code>(\s|$);msi';*/ 54 var $regex = ';^<code(\s[^>]*)?>\n(.+?)\n</code>(\s|$);msi'; 53 var $regex = ';^<code(\s[^>]*)?>((?:(?R)|.*?)*)\n</code>(\s|$);msi'; 55 54 56 55 /** … … 73 72 // are there additional attribute arguments? 74 73 $args = trim($matches[1]); 75 74 76 75 if ($args == '') { 77 76 $options = array( … … 82 81 // get the attributes... 83 82 $attr = $this->getAttrs($args); 84 83 85 84 // ... and make sure we have a 'type' 86 85 if (! isset($attr['type'])) { -
trunk/vendor/Text/Wiki/Parse/Default/Freelink.php
r1125 r2015 13 13 * @license LGPL 14 14 * 15 * @version $Id: Freelink.php,v 1. 4 2005/10/19 23:43:53 togggExp $15 * @version $Id: Freelink.php,v 1.8 2006/12/08 08:23:51 justinpatrin Exp $ 16 16 * 17 17 */ … … 42 42 class Text_Wiki_Parse_Freelink extends Text_Wiki_Parse { 43 43 44 var $conf = array ( 45 'utf-8' => false 46 ); 44 47 45 48 /** … … 57 60 { 58 61 parent::Text_Wiki_Parse($obj); 59 62 if ($this->getConf('utf-8')) { 63 $any = '\p{L}'; 64 } else { 65 $any = ''; 66 } 60 67 $this->regex = 61 68 '/' . // START regex 62 69 "\\(\\(" . // double open-parens 63 70 "(" . // START freelink page patter 64 "[-A-Za-z0-9 _+\\/.,;:!?'\"\\[\\]\\{\\}& \xc0-\xff]+" . // 1 or more of just about any character71 "[-A-Za-z0-9 _+\\/.,;:!?'\"\\[\\]\\{\\}&".$any."\xc0-\xff]+" . // 1 or more of just about any character 65 72 ")" . // END freelink page pattern 66 73 "(" . // START display-name 67 74 "\|" . // a pipe to start the display name 68 "[-A-Za-z0-9 _+\\/.,;:!?'\"\\[\\]\\{\\}& \xc0-\xff]+" . // 1 or more of just about any character75 "[-A-Za-z0-9 _+\\/.,;:!?'\"\\[\\]\\{\\}&".$any."\xc0-\xff]+" . // 1 or more of just about any character 69 76 ")?" . // END display-name pattern 0 or 1 70 77 "(" . // START pattern for named anchors … … 74 81 ")?" . // END named anchors pattern 0 or 1 75 82 "()\\)\\)" . // double close-parens 76 '/' ;// END regex83 '/'.($this->getConf('utf-8') ? 'u' : ''); // END regex 77 84 } 78 85 -
trunk/vendor/Text/Wiki/Parse/Default/Prefilter.php
r1125 r2015 13 13 * @license LGPL 14 14 * 15 * @version $Id: Prefilter.php,v 1. 3 2005/02/23 17:38:29 pmjonesExp $15 * @version $Id: Prefilter.php,v 1.4 2006/12/08 08:30:37 justinpatrin Exp $ 16 16 * 17 17 */ … … 66 66 // seems to help many rules. 67 67 $this->wiki->source = "\n" . $this->wiki->source . "\n\n"; 68 69 $this->wiki->source = str_replace("\n----\n","\n\n----\n\n", 70 $this->wiki->source); 71 $this->wiki->source = preg_replace("/\n(\\+{1,6})(.*)\n/m", 72 "\n\n\\1 \\2\n\n", 73 $this->wiki->source); 68 74 69 75 // finally, compress all instances of 3 or more newlines -