3 * All of the functions to clean up and handle the long description
\r
4 * of a DocBlock are in this file.
\r
6 * The primary functionality is based on Parser and WordParser, and modified to recognize
\r
7 * only the tokens defined in the PHPDOCUMENTOR_PDP_* constants
\r
9 * phpDocumentor :: automatic documentation generator
\r
11 * PHP versions 4 and 5
\r
13 * Copyright (c) 2002-2006 Gregory Beaver
\r
17 * This library is free software; you can redistribute it
\r
18 * and/or modify it under the terms of the GNU Lesser General
\r
19 * Public License as published by the Free Software Foundation;
\r
20 * either version 2.1 of the License, or (at your option) any
\r
23 * This library is distributed in the hope that it will be useful,
\r
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
26 * Lesser General Public License for more details.
\r
28 * You should have received a copy of the GNU Lesser General Public
\r
29 * License along with this library; if not, write to the Free Software
\r
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
32 * @package phpDocumentor
\r
33 * @subpackage Parsers
\r
34 * @author Gregory Beaver <cellog@php.net>
\r
35 * @copyright 2002-2006 Gregory Beaver
\r
36 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
\r
37 * @version CVS: $Id: ParserDescCleanup.inc,v 1.13 2007/12/13 02:56:45 ashnazg Exp $
\r
38 * @link http://www.phpdoc.org
\r
39 * @link http://pear.php.net/PhpDocumentor
\r
40 * @see Parser, WordParser
\r
45 * {@link parserDescParser} token constants
\r
47 /** when <<code>> is found in a desc */
\r
48 define('PHPDOCUMENTOR_PDP_EVENT_CODE', 600);
\r
49 /** when <<code>> is found in a desc */
\r
50 define('PHPDOCUMENTOR_PDP_STATE_CODE', 700);
\r
51 /** when <<p>> is found in a desc */
\r
52 define('PHPDOCUMENTOR_PDP_EVENT_P', 601);
\r
53 /** when <<p>> is found in a desc */
\r
54 define('PHPDOCUMENTOR_PDP_STATE_P', 701);
\r
55 /** when \n\n is found in a desc */
\r
56 define('PHPDOCUMENTOR_PDP_EVENT_DOUBLECR', 602);
\r
57 /** when \n\n is found in a desc */
\r
58 define('PHPDOCUMENTOR_PDP_STATE_DOUBLECR', 702);
\r
59 /** when <<pre>> is found in a desc */
\r
60 define('PHPDOCUMENTOR_PDP_EVENT_PRE', 603);
\r
61 /** when <<pre>> is found in a desc */
\r
62 define('PHPDOCUMENTOR_PDP_STATE_PRE', 703);
\r
63 /** when <<ul>>/<<ol>> is found in a desc */
\r
64 define('PHPDOCUMENTOR_PDP_EVENT_LIST', 604);
\r
65 /** when <<ul>>/<<ol>> is found in a desc */
\r
66 define('PHPDOCUMENTOR_PDP_STATE_LIST', 704);
\r
67 /** when <<b>> is found in a desc */
\r
68 define('PHPDOCUMENTOR_PDP_EVENT_B', 605);
\r
69 /** when <<b>> is found in a desc */
\r
70 define('PHPDOCUMENTOR_PDP_STATE_B', 705);
\r
71 /** when <<i>> is found in a desc */
\r
72 define('PHPDOCUMENTOR_PDP_EVENT_I', 606);
\r
73 /** when <<i>> is found in a desc */
\r
74 define('PHPDOCUMENTOR_PDP_STATE_I', 706);
\r
75 /** when <<br>> is found in a desc */
\r
76 define('PHPDOCUMENTOR_PDP_EVENT_BR', 607);
\r
77 /** when <<br>> is found in a desc */
\r
78 define('PHPDOCUMENTOR_PDP_STATE_BR', 707);
\r
79 /** when the << potential escape for tags is found in a desc */
\r
80 define('PHPDOCUMENTOR_PDP_EVENT_ESCAPE',608);
\r
81 /** when the << potential escape for tags is found in a desc */
\r
82 define('PHPDOCUMENTOR_PDP_STATE_ESCAPE',708);
\r
83 /** when << /pre>> is found in a <<pre>><</pre>> section */
\r
84 define('PHPDOCUMENTOR_PDP_EVENT_ESCAPE_PRE',609);
\r
85 /** when << /pre>> is found in a <<pre>><</pre>> section */
\r
86 define('PHPDOCUMENTOR_PDP_STATE_ESCAPE_PRE',709);
\r
87 /** when << /code>> is found in a <<code>><</code>> section */
\r
88 define('PHPDOCUMENTOR_PDP_EVENT_ESCAPE_CODE',610);
\r
89 /** when << /code>> is found in a <<code>><</code>> section */
\r
90 define('PHPDOCUMENTOR_PDP_STATE_ESCAPE_CODE',710);
\r
91 /** when <<var>> is found in a desc */
\r
92 define('PHPDOCUMENTOR_PDP_EVENT_VAR',611);
\r
93 /** when <<var>> is found in a desc */
\r
94 define('PHPDOCUMENTOR_PDP_STATE_VAR',711);
\r
95 /** when <<samp>> is found in a desc */
\r
96 define('PHPDOCUMENTOR_PDP_EVENT_SAMP',612);
\r
97 /** when <<samp>> is found in a desc */
\r
98 define('PHPDOCUMENTOR_PDP_STATE_SAMP',712);
\r
99 /** when <<kbd>> is found in a desc */
\r
100 define('PHPDOCUMENTOR_PDP_EVENT_KBD',613);
\r
101 /** when <<kbd>> is found in a desc */
\r
102 define('PHPDOCUMENTOR_PDP_STATE_KBD',713);
\r
103 /** when a simple list is found in a desc
\r
111 define('PHPDOCUMENTOR_PDP_EVENT_SIMLIST',614);
\r
112 /** when a simple list is found in a desc
\r
120 define('PHPDOCUMENTOR_PDP_STATE_SIMLIST',714);
\r
123 * Like WordParser but designed to handle an array with strings and
\r
124 * {@link parserInlineTag}s
\r
125 * @package phpDocumentor
\r
126 * @subpackage WordParsers
\r
127 * @author Greg Beaver <cellog@php.net>
\r
130 class ObjectWordParser extends WordParser
\r
133 * Determines whether text searching is case-sensitive or not
\r
136 var $_casesensitive = false;
\r
138 function ObjectWordParser($casesensitive = false)
\r
140 $this->_casesensitive = $casesensitive;
\r
144 * Set the word parser to go.
\r
146 * @param array {@link parserStringWithInlineTags::$value} style-array, with
\r
147 * alternating text and inline tags
\r
149 function setup(&$input)
\r
151 // if (is_string($input[0])) $input[0] = ltrim($input[0]);
\r
152 $this->data = & $input;
\r
154 $this->linenum = 0;
\r
155 $this->linenumpos = 0;
\r
156 $this->cache = array();
\r
157 reset($this->data);
\r
158 list($this->index,) = each($this->data);
\r
159 if (!is_object($this->data[$this->index]))
\r
160 $this->size = strlen($this->data[$this->index]);
\r
161 else $this->size = 0;
\r
163 //$this->word = WORD_PARSER_RET_WORD;
\r
168 if (!isset($this->data[$this->index])) return false;
\r
169 // return any inline tags unchanged
\r
170 if (is_object($this->data[$this->index]))
\r
172 $index = $this->index;
\r
173 list($this->index,) = each($this->data);
\r
177 if (!is_object($this->data[$this->index]))
\r
178 $this->size = strlen($this->data[$this->index]);
\r
179 else $this->size = 0;
\r
180 $this->cache = array();
\r
181 return $this->data[$index];
\r
187 //$st = $this->mtime();
\r
188 if ($this->size == $this->pos)
\r
190 // cycle to next line in the array
\r
191 list($this->index,) = each($this->data);
\r
192 if (!$this->index) return false;
\r
194 if (!is_object($this->data[$this->index]))
\r
195 $this->size = strlen($this->data[$this->index]);
\r
196 else $this->size = 0;
\r
197 $this->cache = array();
\r
198 return $this->getWord();
\r
201 $npos = $this->size;
\r
202 if (is_array($this->wordseperators))
\r
204 //$this->wordseperators = array();
\r
205 foreach($this->wordseperators as $sep)
\r
207 if (isset($this->cache[$sep]))
\r
208 $tpos = $this->cache[$sep];
\r
211 if ($tpos < $this->pos || !is_int($tpos))
\r
213 if ($this->_casesensitive)
\r
214 $tpos = strpos($this->data[$this->index],$sep,$this->pos);
\r
216 $tpos = strpos(strtolower($this->data[$this->index]),$sep,$this->pos);
\r
219 if ( ($tpos < $npos) && !($tpos === false))
\r
221 //echo trim($sep) . "=$tpos\n";
\r
223 $seplen = strlen($sep);
\r
225 else if (!($tpos === false))
\r
227 $this->cache[$sep] = $tpos;
\r
231 // its time to cycle
\r
235 $len = $npos - $this->pos;
\r
241 //$st3 = $this->mtime();
\r
242 $word = substr($this->data[$this->index],$this->pos,$len);
\r
244 // Change random other os newlines to the unix one
\r
245 if ($word == "\r" || $word == "\r\n")
\r
250 if ($this->linenumpos <= $this->pos)
\r
252 $this->linenumpos = $this->pos + $len;
\r
253 $this->linenum += count(explode("\n",$word)) - 1;
\r
256 if ($this->getsource)
\r
258 $this->source .= $word;
\r
260 $this->pos = $this->pos + $len;
\r
261 //$this->word = WORD_PARSER_RET_SEP;
\r
263 // Things like // commenats rely on the newline to find their end so im going to have to return them
\r
264 // never return worthless white space /t ' '
\r
265 if ($this->returnWhiteSpace == false)
\r
267 if (strlen(trim($word)) == 0 && $word != "\n")
\r
269 $word = $this->getWord();
\r
272 //$this->time3 = $this->time3 + ($this->mtime() - $st3);
\r
273 //$this->time = $this->time + ($this->mtime() - $st);
\r
278 * Determine if the next word is an inline tag
\r
281 function nextIsObjectOrNonNL()
\r
283 return (($this->size == $this->pos) && isset($this->data[$this->index + 1])
\r
284 && is_object($this->data[$this->index + 1])) ||
\r
285 (($this->size > $this->pos) && !in_array($this->data[$this->index]{$this->pos}, array("\n", "\r")));
\r
290 * Parses a DocBlock description to retrieve abstract representations of
\r
291 * <<pre>>,<<code>>,<<p>>,<<ul>>,<<ol>>,<<li>>,<<b>>,<<i>>
\r
292 * @tutorial phpDocumentor.howto.pkg#basics.desc
\r
293 * @package phpDocumentor
\r
294 * @subpackage Parsers
\r
295 * @author Greg Beaver <cellog@php.net>
\r
298 class parserDescParser extends Parser
\r
306 var $eventHandlers = array(PHPDOCUMENTOR_PDP_EVENT_CODE => 'handleCode',
\r
307 PHPDOCUMENTOR_PDP_EVENT_PRE => 'handlePre',
\r
308 PHPDOCUMENTOR_PDP_EVENT_P => 'handleP',
\r
309 PHPDOCUMENTOR_PDP_EVENT_DOUBLECR => 'handleDoubleCR',
\r
310 PHPDOCUMENTOR_PDP_EVENT_LIST => 'handleList',
\r
311 PHPDOCUMENTOR_PDP_EVENT_B => 'handleB',
\r
312 PHPDOCUMENTOR_PDP_EVENT_I => 'handleI',
\r
313 PHPDOCUMENTOR_PDP_EVENT_VAR => 'handleVar',
\r
314 PHPDOCUMENTOR_PDP_EVENT_KBD => 'handleKbd',
\r
315 PHPDOCUMENTOR_PDP_EVENT_SAMP => 'handleSamp',
\r
316 PHPDOCUMENTOR_PDP_EVENT_BR => 'handleBr',
\r
317 PHPDOCUMENTOR_PDP_EVENT_ESCAPE => 'handleEscape',
\r
318 PHPDOCUMENTOR_PDP_EVENT_ESCAPE_CODE => 'handleEscapeCode',
\r
319 PHPDOCUMENTOR_PDP_EVENT_ESCAPE_PRE => 'handleEscapePre',
\r
320 PHPDOCUMENTOR_PDP_EVENT_SIMLIST => 'handleSimpleList',
\r
321 PARSER_EVENT_NOEVENTS => 'defaultHandler',
\r
327 var $pars = array();
\r
329 * Determines whether parsing of <p> tags will occur, or double CR will
\r
337 * Values can be 'normal', or any tag container like 'my_i', 'my_b'. This
\r
338 * is used to determine which tag text or nested tags should be added to
\r
341 var $_context = array('normal');
\r
345 * sets $wp to be a {@link ObjectWordParser}
\r
347 * $wp is the word parser that retrieves tokens
\r
349 function parserDescParser()
\r
351 $this->wp = new ObjectWordParser;
\r
355 * Parse a long or short description for tags
\r
357 * @param array array of strings or {@link parserInlineTag}s
\r
358 * @param boolean true if the description is a short description. (only 1 paragraph allowed in short desc)
\r
359 * @param string name of the class to instantiate for each paragraph. parserDesc for desc/sdesc,
\r
360 * parserStringWithInlineTags for tag data
\r
361 * @staticvar integer used for recursion limiting if a handler for an event is not found
\r
363 function parse (&$parse_data,$sdesc = false,$ind_type = 'parserDesc')
\r
365 static $endrecur = 0;
\r
366 global $_phpDocumentor_setting;
\r
367 if (!is_array($parse_data) || count($parse_data) == 0)
\r
371 $this->p_vars['indtype'] = $ind_type;
\r
372 $this->setupStates($sdesc);
\r
373 if (isset($_phpDocumentor_setting['javadocdesc']) && $_phpDocumentor_setting['javadocdesc'] == 'on')
\r
374 $this->parse_Ps = true;
\r
376 // initialize variables so E_ALL error_reporting doesn't complain
\r
379 $this->p_vars['curpar'] = 0;
\r
380 $this->pars = array();
\r
381 $this->p_vars['start'] = true;
\r
382 $this->p_vars['event_stack'] = new EventStack;
\r
384 $this->wp->setup($parse_data,$sdesc);
\r
385 $this->wp->setWhitespace(true);
\r
386 $this->p_vars['list_count'] = 0;
\r
387 if ($sdesc) $this->p_vars['start'] = false;
\r
389 // beware of infinite loops
\r
390 $infiniteLoopCatcher = 0;
\r
393 $infiniteLoopCatcher++;
\r
394 if (!isset($this->pars[$this->p_vars['curpar']])) $this->pars[$this->p_vars['curpar']] = new $ind_type;
\r
395 $lpevent = $pevent;
\r
396 $pevent = $this->p_vars['event_stack']->getEvent();
\r
397 if ($lpevent != $pevent)
\r
399 $this->p_vars['last_pevent'] = $lpevent;
\r
402 if ($this->p_vars['last_pevent'] != $pevent)
\r
404 // its a new event so the word parser needs to be reconfigured
\r
405 $this->configWordParser($pevent);
\r
409 $this->p_vars['last_word'] = $word;
\r
410 $word = $this->wp->getWord();
\r
412 if (PHPDOCUMENTOR_DEBUG == true)
\r
414 echo "----------------\n";
\r
415 echo "LAST: |" . htmlentities($this->p_vars['last_word']) . "|\n";
\r
416 // echo "INDEX: ".$this->p_vars['curpar']."\n";
\r
417 echo "PEVENT: " . $this->getParserEventName($pevent) . "\n";
\r
418 echo "LASTPEVENT: " . $this->getParserEventName($this->p_vars['last_pevent']) . "\n";
\r
419 echo $this->wp->getPos() . " WORD: |".htmlentities($word)."|\n\n";
\r
420 var_dump($this->_context);
\r
422 if (isset($this->eventHandlers[$pevent]))
\r
424 $handle = $this->eventHandlers[$pevent];
\r
425 if ($word !== false) $this->$handle($word, $pevent);
\r
428 if (!count($this->pars[$this->p_vars['curpar']]->value)) unset($this->pars[$this->p_vars['curpar']]);
\r
432 debug('WARNING: possible error, no ParserDescParser handler for event number '.$pevent);
\r
433 if ($endrecur++ == 25)
\r
435 addErrorDie(PDERROR_LOOP_RECURSION_LIMIT_REACHED);
\r
438 if (is_object($word) || trim($word) != '')
\r
440 $this->p_vars['start'] = false;
\r
443 if ($infiniteLoopCatcher > 10000) {
\r
444 echo PHP_EOL . "FATAL ERROR: Somehow we got into an infinite loop in parserDescCleanup->parse()'s do-while loop...";
\r
445 echo PHP_EOL . " The line being parsed was: " . $word . PHP_EOL . PHP_EOL;
\r
446 addErrorDie(PDERROR_LOOP_RECURSION_LIMIT_REACHED);
\r
448 } while (is_object($word) || !($word === false) && $word != '');
\r
449 $context = $this->getContext();
\r
450 if ($context != 'normal')
\r
452 if ($context == 'list' && $this->p_flags['simplelist'])
\r
454 $this->p_vars['lists'][0]->addItem($this->p_vars['list_item'][0]);
\r
455 unset($this->p_vars['list_item'][0]);
\r
456 $this->setContext('normal');
\r
457 $this->addText($this->p_vars['lists'][0]);
\r
458 } else addError(PDERROR_UNCLOSED_TAG,str_replace('my_','',$context));
\r
460 if ($this->p_vars['list_count'] > 0) addError(PDERROR_UNMATCHED_LIST_TAG);
\r
462 $this->publishEvent(2,$this->pars);
\r
464 $this->publishEvent(1,$this->pars);
\r
466 /**#@+ @access private */
\r
470 * This function checks to see if the first thing in
\r
471 * a description is the <p> tag. If so, it will switch
\r
472 * into a mode of parsing out paragraphs by <p> instead
\r
473 * of a double line-break
\r
475 * It also removes extra whitespace
\r
476 * @uses doSimpleList()
\r
478 function defaultHandler($word, $pevent)
\r
480 $context = $this->getContext();
\r
481 if ($context != 'normal') $this->setContext('normal');
\r
482 if ($this->p_vars['start'] && is_string($word) && strtolower($word) == '<p>')
\r
484 $this->parse_Ps = true;
\r
486 if (is_string($word) && $this->checkEventPush($word, $pevent)) return;
\r
487 // if (!isset($this->parse_Ps) || !$this->parse_Ps)
\r
489 if (is_string($word) && is_string($this->p_vars['last_word']) &&
\r
490 ($word == ' ' && $this->p_vars['last_word'] == ' ')) return;
\r
491 if ($pevent == PARSER_EVENT_NOEVENTS)
\r
493 if ($this->doSimpleList($word)) return;
\r
495 $this->addText($word);
\r
500 * Retrieve the current top-level tag to add text into
\r
503 function getContext()
\r
505 array_push($this->_context,$a = array_pop($this->_context));
\r
510 * Pop a context off of the context stack
\r
513 function dropContext()
\r
515 array_pop($this->_context);
\r
516 if (count($this->_context) == 0)
\r
517 $this->_context = array('normal');
\r
522 * @param string context name
\r
524 function setContext($context)
\r
526 array_push($this->_context,$context);
\r
530 * add input as text to the current paragraph or list
\r
531 * @param string|parserInlineTag
\r
533 function addText($text)
\r
535 $context = $this->getContext();
\r
536 if ($context == 'list')
\r
538 // debug('aded to '.$context);
\r
539 if (!is_object($this->p_vars['list_item'][$this->p_vars['list_count']])) {
\r
540 addErrorDie(PDERROR_UL_IN_UL);
\r
542 $this->p_vars['list_item'][$this->p_vars['list_count']]->add($text);
\r
543 } elseif ($context != 'normal')
\r
545 // debug('added to '.$context);
\r
546 $this->p_vars[$context]->add($text);
\r
549 // debug('added to normal ');
\r
550 $indtype = $this->p_vars['indtype'];
\r
551 if (!isset($this->pars[$this->p_vars['curpar']]))
\r
552 $this->pars[$this->p_vars['curpar']] = new $indtype;
\r
553 $this->pars[$this->p_vars['curpar']]->add($text);
\r
560 * @param string|parserInlineTag token from the ObjectWordParser
\r
561 * @param integer parser event from {@link ParserDescCleanup.inc}
\r
564 * Handles special case where a description needs the text "<tag>" and tag
\r
565 * is one of code, b, i, pre, var, or any other valid in-DocBlock html tag.
\r
567 * the text <<<code>>> in a DocBlock will parse out as <<code>>, instead
\r
568 * of being parsed as markup.
\r
570 function handleEscape($word, $pevent)
\r
572 $this->p_vars['event_stack']->popEvent();
\r
573 if (!in_array($word, $this->tokens[PHPDOCUMENTOR_PDP_STATE_ESCAPE]))
\r
577 $this->addText($word);
\r
578 $this->wp->backupPos($word.$word);
\r
580 $this->wp->backupPos($word);
\r
583 $this->addText('<'.str_replace('>>','>',$word));
\r
587 * Just like {@link handleEscape}, except the only valid escape is
\r
590 function handleEscapePre($word, $pevent)
\r
592 $this->p_vars['event_stack']->popEvent();
\r
593 $this->addText('</pre>');
\r
597 * Just like {@link handleEscape}, except the only valid escape is
\r
600 function handleEscapeCode($word, $pevent)
\r
602 $this->p_vars['event_stack']->popEvent();
\r
603 $this->addText('</code>');
\r
608 * Add a new {@link parserBr}
\r
611 function handleBr($word, $pevent)
\r
613 if (is_string($word) && $this->checkEventPop($word, $pevent))
\r
615 $this->addText(new parserBr);
\r
620 * Handles simple lists
\r
622 * phpEdit has an ingenious facility to handle simple lists used in a
\r
623 * DocBlock like this:
\r
635 * This function converts these simple lists into the parserList class
\r
636 * @param boolean true if this is the first list item in the list
\r
638 function handleSimpleList($word, $pevent, $start = false)
\r
640 if (is_object($word) && $this->p_flags['in_item'])
\r
642 $this->p_vars['list_item'][0]->add($word);
\r
645 if (is_string($word) && $this->checkEventPush($word, $pevent))
\r
647 $this->p_flags['in_event'] = true;
\r
650 $ltrimword = @substr($word, @strpos($word, ltrim($word)));
\r
652 if (strlen(trim($word)) == 0)
\r
654 if ($this->wp->nextIsObjectOrNonNL())
\r
659 if ($word == "\n" && is_string($this->p_vars['last_word'])
\r
660 && $this->p_vars['last_word']{strlen($this->p_vars['last_word']) - 1}
\r
663 if ($this->p_flags['in_item'])
\r
665 $this->p_vars['lists'][0]->addItem($this->p_vars['list_item'][0]);
\r
666 unset($this->p_vars['list_item'][0]);
\r
667 $this->setContext('normal');
\r
668 $this->p_flags['simplelist'] = false;
\r
669 $this->addText($this->p_vars['lists'][0]);
\r
670 unset($this->p_vars['lists']);
\r
671 unset($this->p_vars['last_list']);
\r
672 $this->wp->backuppos($word);
\r
673 $this->p_vars['event_stack']->popEvent();
\r
674 $this->p_flags['in_item'] = false;
\r
675 // debug('end of list 3');
\r
679 $this->wp->backuppos($word);
\r
680 $this->p_vars['event_stack']->popEvent();
\r
681 $this->p_flags['in_item'] = false;
\r
682 // debug('not a list 2');
\r
686 $start_list = $this->getStartList($word);
\r
687 if (substr($ltrimword,0,strlen($start_list)) != $start_list
\r
688 || $this->p_flags['in_event'] || is_object($this->p_vars['last_word']))
\r
690 if (((strlen($this->p_vars['whitespace']) + 1) < strlen(substr($word,0,strpos($word, $ltrimword))))
\r
693 || $this->p_flags['in_event']
\r
694 || (is_object($this->p_vars['last_word']) && $this->p_flags['in_item']))
\r
696 $this->p_vars['list_item'][0]->add($word);
\r
697 $this->resetStartList($start_list);
\r
698 $this->p_flags['in_event'] = false;
\r
699 // debug('middle of list');
\r
702 if ($this->p_flags['in_item'])
\r
704 $this->p_vars['lists'][0]->addItem($this->p_vars['list_item'][0]);
\r
705 unset($this->p_vars['list_item'][0]);
\r
706 $this->setContext('normal');
\r
707 $this->p_flags['simplelist'] = false;
\r
708 $this->addText($this->p_vars['lists'][0]);
\r
709 unset($this->p_vars['lists']);
\r
710 unset($this->p_vars['last_list']);
\r
711 $this->wp->backuppos($word);
\r
712 $this->p_vars['event_stack']->popEvent();
\r
713 $this->p_flags['in_item'] = false;
\r
714 // debug('end of list 1');
\r
718 $this->wp->backuppos($word);
\r
719 $this->p_vars['event_stack']->popEvent();
\r
720 $this->p_flags['in_item'] = false;
\r
721 // debug('not a list');
\r
727 if ($this->p_vars['whitespace'] != substr($word,0,strpos($word, $start_list)))
\r
728 { // if the whitespace is greater than that preceding the list
\r
729 // delimiter, it's a multi-line list item
\r
730 $this->setContext('normal');
\r
731 $this->p_flags['simplelist'] = false;
\r
732 $this->addText($this->p_vars['lists'][0]);
\r
733 unset($this->p_vars['lists']);
\r
734 $this->wp->backuppos($word);
\r
735 $this->p_vars['event_stack']->popEvent();
\r
736 unset($this->p_vars['last_list']);
\r
737 $this->p_flags['in_item'] = false;
\r
738 // debug('end of list 2');
\r
742 if ($this->p_flags['in_item'])
\r
744 // end of a list item, add it to the list
\r
745 $this->p_vars['lists'][0]->addItem($this->p_vars['list_item'][0]);
\r
746 unset($this->p_vars['list_item'][0]);
\r
748 // debug('next list item');
\r
749 $this->p_vars['list_item'][0] = new parserStringWithInlineTags;
\r
750 $this->p_vars['list_item'][0]->add(ltrim(substr($ltrimword,strlen($start_list))));
\r
751 $this->p_flags['in_item'] = true;
\r
757 * Get the next list marker
\r
759 * In unordered lists, this will be something like "o", "-"
\r
761 * In ordered lists, this will be either the number "3", "5" or "3.", "5."
\r
762 * @return string text of the next list marker to look for
\r
763 * @param string current word from the parser
\r
766 function getStartList($word)
\r
768 // unordered, return the first marker found
\r
769 if (!$this->p_flags['orderedlist']) return $this->p_vars['start_list'];
\r
770 if (isset($this->p_vars['last_list']))
\r
772 $this->p_vars['save_list'] = $this->p_vars['last_list'];
\r
773 $next = $this->p_vars['last_list'];
\r
774 // increment to next list number, convert to string
\r
775 if (substr($this->p_vars['start_list'], strlen($this->p_vars['start_list']) - 1) == '.')
\r
776 $next = (substr($next, 0, strpos($next,'.')) + 1) . '.';
\r
778 $next = ($next + 1) . '';
\r
779 // debug("next is '$next'");
\r
780 if ($this->p_vars['whitespace'] == substr($word,0,strpos($word, $next)))
\r
781 return $this->p_vars['last_list'] = $next;
\r
782 // the next number is not in this word, so return but don't save
\r
786 $this->p_vars['last_list'] = $this->p_vars['start_list'];
\r
787 return $this->p_vars['start_list'];
\r
792 * Set the next list marker to the current list marker
\r
794 * In ordered lists, this will ensure that the next number returned is the
\r
796 * @param string token for next list marker
\r
799 function resetStartList($start)
\r
801 if (!isset($this->p_vars['save_list'])) return false;
\r
802 $this->p_vars['last_list'] = $this->p_vars['save_list'];
\r
807 * @param string|parserInlineTag token from the ObjectWordParser
\r
808 * @param integer parser event from {@link ParserDescCleanup.inc}
\r
811 * Handles <<ol>>,<<li>>,<<ul>>
\r
813 * This allows parsing of lists nested to any level. Using
\r
814 * the lists and list_item temporary variables and using
\r
815 * list_count to control nesting, the method creates a {@link parserList}
\r
816 * for each <<ol>> or <<ul>> tag, and a
\r
817 * standard {@link parserStringWithInlineTags} for all the text, adding
\r
818 * in nested lists as if they were inline tags (the conversion interface
\r
819 * is the same for both object types)
\r
821 function handleList($word, $pevent)
\r
823 if (is_string($word) && $this->checkEventPush($word, $pevent))
\r
828 if (!is_object($this->p_vars['last_word']) && strtolower($this->p_vars['last_word']) == '<ol>')
\r
833 // start a new list
\r
834 if (!is_object($this->p_vars['last_word']) && (strtolower($this->p_vars['last_word']) == '<ol>' || strtolower($this->p_vars['last_word']) == '<ul>'))
\r
836 $this->p_flags['in_item'] = false;
\r
837 $this->setContext('list');
\r
838 $this->p_vars['lists'][++$this->p_vars['list_count']] = new parserList($ordered);
\r
840 if (!is_object($word) && strtolower($word) == '<li>')
\r
842 if ($this->p_flags['in_item'])
\r
844 // end of a list item (no end tag), add it to the list
\r
845 $this->p_vars['lists'][$this->p_vars['list_count']]->addItem($this->p_vars['list_item'][$this->p_vars['list_count']]);
\r
846 unset($this->p_vars['list_item'][$this->p_vars['list_count']]);
\r
848 // start a new list item
\r
849 $this->p_vars['list_item'][$this->p_vars['list_count']] = new parserStringWithInlineTags;
\r
850 $this->p_flags['in_item'] = true;
\r
853 if (is_object($word) || (strtolower($word) != '</li>'))
\r
855 if (is_object($word) || (strtolower($word) != '</ul>' && strtolower($word) != '</ol>'))
\r
858 if (isset($this->p_vars['list_item'][$this->p_vars['list_count']]))
\r
860 if (is_string($word) && $word == ' ' &&
\r
861 $this->p_vars['last_word'] == ' ') return;
\r
862 $this->p_vars['list_item'][$this->p_vars['list_count']]->add($word);
\r
866 if ($this->p_flags['in_item'])
\r
868 // end the current list item before ending a list
\r
869 $this->p_vars['lists'][$this->p_vars['list_count']]->addItem($this->p_vars['list_item'][$this->p_vars['list_count']]);
\r
870 unset($this->p_vars['list_item'][$this->p_vars['list_count']]);
\r
871 $this->p_flags['in_item'] = false;
\r
873 if (is_string($word) && $this->checkEventPop($word, $pevent))
\r
875 if ($this->p_vars['list_count'] > 1)
\r
877 // this is a sublist, add it to the list item of the parent list
\r
878 if (!isset($this->p_vars['list_item'][$this->p_vars['list_count'] - 1])) {
\r
879 addErrorDie(PDERROR_UL_IN_UL);
\r
881 $this->p_vars['list_item'][$this->p_vars['list_count'] - 1]->add($this->p_vars['lists'][$this->p_vars['list_count']]);
\r
882 // remove the sublist item and sublist, drop to parent list
\r
883 unset($this->p_vars['lists'][$this->p_vars['list_count']]);
\r
884 unset($this->p_vars['lists'][$this->p_vars['list_count']]);
\r
885 $this->p_vars['list_count']--;
\r
886 $this->p_flags['in_item'] = true;
\r
889 // this is a primary list and it has concluded
\r
890 $this->pars[$this->p_vars['curpar']]->add($this->p_vars['lists'][$this->p_vars['list_count']]);
\r
891 unset($this->p_vars['lists']);
\r
892 unset($this->p_vars['list_item']);
\r
893 $this->p_vars['list_count'] = 0;
\r
894 $this->dropContext();
\r
900 // check to make sure our list item is not unclosed
\r
901 if (!$this->p_flags['in_item'])
\r
903 addError(PDERROR_TEXT_OUTSIDE_LI);
\r
906 // end of a list item, add it to the list
\r
907 $this->p_vars['lists'][$this->p_vars['list_count']]->addItem($this->p_vars['list_item'][$this->p_vars['list_count']]);
\r
908 unset($this->p_vars['list_item'][$this->p_vars['list_count']]);
\r
909 $this->p_flags['in_item'] = false;
\r
916 * Handles <<code>><</code>> blocks
\r
918 function handleCode($word, $pevent)
\r
920 if (!isset($this->p_vars['my_code']))
\r
922 $this->setContext('my_code');
\r
923 $this->p_vars['my_code'] = new parserCode;
\r
925 if (is_string($word) && $this->checkEventPush($word, $pevent)) return;
\r
926 if (is_object($word) || strtolower($word) != '</code>') $this->p_vars['my_code']->add($word);
\r
927 if (is_string($word))
\r
929 if ($this->checkEventPop($word,$pevent))
\r
931 $this->dropContext();
\r
932 $this->addText($this->p_vars['my_code']);
\r
933 unset($this->p_vars['my_code']);
\r
939 * Handles <<pre>><</pre>> blocks
\r
941 function handlePre($word, $pevent)
\r
943 if (!isset($this->p_vars['my_pre']))
\r
945 $this->setContext('my_pre');
\r
946 $this->p_vars['my_pre'] = new parserPre;
\r
948 if (is_string($word) && $this->checkEventPush($word, $pevent)) return;
\r
949 if (is_object($word) || strtolower($word) != '</pre>') $this->p_vars['my_pre']->add($word);
\r
950 if (is_string($word))
\r
952 if ($this->checkEventPop($word,$pevent))
\r
954 $this->dropContext();
\r
955 $this->addText($this->p_vars['my_pre']);
\r
956 unset($this->p_vars['my_pre']);
\r
962 * Handles <<b>><</b>> blocks
\r
964 function handleB($word, $pevent)
\r
966 if (!isset($this->p_vars['my_b']))
\r
968 $this->setContext('my_b');
\r
969 $this->p_vars['my_b'] = new parserB;
\r
971 if (is_string($word))
\r
973 if ($this->checkEventPop($word,$pevent))
\r
975 $this->dropContext();
\r
976 $this->addText($this->p_vars['my_b']);
\r
977 unset($this->p_vars['my_b']);
\r
980 $this->p_vars['my_b']->add($word);
\r
982 } else $this->p_vars['my_b']->add($word);
\r
986 * Handles <<i>><</i>> blocks
\r
988 function handleI($word, $pevent)
\r
990 if (!isset($this->p_vars['my_i']))
\r
992 $this->p_vars['my_i'] = new parserI;
\r
993 $this->setContext('my_i');
\r
995 if (is_string($word))
\r
997 if ($this->checkEventPop($word,$pevent))
\r
999 $this->dropContext();
\r
1000 $this->addText($this->p_vars['my_i']);
\r
1001 unset($this->p_vars['my_i']);
\r
1004 $this->p_vars['my_i']->add($word);
\r
1006 } else $this->p_vars['my_i']->add($word);
\r
1010 * Handles <<var>><</var>> blocks
\r
1012 function handleVar($word, $pevent)
\r
1014 if (!isset($this->p_vars['my_var']))
\r
1016 $this->setContext('my_var');
\r
1017 $this->p_vars['my_var'] = new parserDescVar;
\r
1019 if (is_string($word))
\r
1021 if ($this->checkEventPop($word,$pevent))
\r
1023 $this->dropContext();
\r
1024 $this->addText($this->p_vars['my_var']);
\r
1025 unset($this->p_vars['my_var']);
\r
1028 $this->p_vars['my_var']->add($word);
\r
1030 } else $this->p_vars['my_var']->add($word);
\r
1034 * Handles <<samp>><</samp>> blocks
\r
1036 function handleSamp($word, $pevent)
\r
1038 if (!isset($this->p_vars['my_samp']))
\r
1040 $this->setContext('my_samp');
\r
1041 $this->p_vars['my_samp'] = new parserSamp;
\r
1043 if (is_string($word))
\r
1045 if ($this->checkEventPop($word,$pevent))
\r
1047 $this->dropContext();
\r
1048 $this->addText($this->p_vars['my_samp']);
\r
1049 unset($this->p_vars['my_samp']);
\r
1052 $this->p_vars['my_samp']->add($word);
\r
1054 } else $this->p_vars['my_samp']->add($word);
\r
1058 * Handles <<kbd>><</kbd>> blocks
\r
1060 function handleKbd($word, $pevent)
\r
1062 if (!isset($this->p_vars['my_kbd']))
\r
1064 $this->setContext('my_kbd');
\r
1065 $this->p_vars['my_kbd'] = new parserKbd;
\r
1067 if (is_string($word))
\r
1069 if ($this->checkEventPop($word,$pevent))
\r
1071 $this->dropContext();
\r
1072 $this->addText($this->p_vars['my_kbd']);
\r
1073 unset($this->p_vars['my_kbd']);
\r
1076 $this->p_vars['my_kbd']->add($word);
\r
1078 } else $this->p_vars['my_kbd']->add($word);
\r
1082 * Handles <<p>><</p>> blocks
\r
1084 * Note that the only time <<p>> will be interpreted as delimiting a
\r
1085 * paragraph is if it is the first thing in the description.
\r
1087 function handleP($word, $pevent)
\r
1089 if (!isset($this->parse_Ps)) $this->parse_Ps = false;
\r
1090 if (is_string($word))
\r
1092 if (is_string($word) && $this->checkEventPush($word, $pevent)) return;
\r
1094 if (!$this->parse_Ps)
\r
1096 $this->p_vars['event_stack']->popEvent();
\r
1097 if (!is_object($word) && strtolower($this->p_vars['last_word']) == '<p>') $this->addText('<p>');
\r
1098 $this->addText($word);
\r
1101 if (is_string($word) && $word == "\n") $word = " ";
\r
1102 if (is_string($word))
\r
1104 if ($this->checkEventPop($word, $pevent))
\r
1106 $this->p_vars['curpar']++;
\r
1109 // if no closing tag, pretend there was one
\r
1110 if (!is_object($word) && strtolower($word) == '<p>' && $this->parse_Ps)
\r
1112 $this->p_vars['curpar']++;
\r
1116 if ($this->p_vars['start'])
\r
1118 $this->addText($word);
\r
1120 {// if the <p> is not at the beginning of the desc, then it is not
\r
1121 // possible to parse into paragraphs using this tag
\r
1122 if ($word === ' ' && $this->p_vars['last_word'] === ' ') return;
\r
1123 $this->addText($word);
\r
1128 * Handles \n\n as a paragraph marker
\r
1129 * @uses doSimpleList()
\r
1131 function handleDoubleCR($word, $pevent)
\r
1133 $this->p_vars['event_stack']->popEvent();
\r
1134 if ($word == "\n")
\r
1136 // only use this if <p> isn't being used
\r
1137 if ((!isset($this->parse_Ps) || !$this->parse_Ps))
\r
1139 if ($this->p_vars['last_word'] == "\n")
\r
1141 $this->p_vars['curpar']++;
\r
1142 $this->parse_Ps = false;
\r
1145 if (is_string($word) && !$this->checkEventPush($word, $pevent))
\r
1147 if ($word == ' ' && $this->p_vars['last_word'] == ' ') return;
\r
1148 $this->addText($word);
\r
1153 if (is_string($word) && !$this->checkEventPush($word, $pevent))
\r
1155 if ($word == ' ' && $this->p_vars['last_word'] == ' ') return;
\r
1156 $this->addText($word);
\r
1161 if ($this->p_vars['last_word'] == "\n")
\r
1163 if ((!isset($this->parse_Ps) || !$this->parse_Ps))
\r
1165 $this->addText(' ');
\r
1168 if (is_string($word) && !($e = $this->checkEventPush($word, $pevent)))
\r
1170 if ($word == ' ' && $this->p_vars['last_word'] == ' ') return;
\r
1171 if ($this->doSimpleList($word)) return;
\r
1172 $this->addText($word);
\r
1179 * Return a simple list, if found
\r
1181 * This helper function extracts a simple list beginning with any of
\r
1182 * 'o','-'.'#','+','0','1','0.','1.' and starts parsing it.
\r
1183 * @param string line that may contain a simple list
\r
1184 * @return boolean true if a list is found, false otherwise
\r
1186 function doSimpleList($word)
\r
1188 if ($this->p_flags['in_event']) return true;
\r
1189 if (is_object($word)) return false;
\r
1190 $ltrimword = ltrim($word);
\r
1191 if ((strlen($ltrimword) != strlen($word))
\r
1192 && strlen($ltrimword) > 1
\r
1193 && ((in_array($ltrimword{0},array('o','-','1','0','#','+')) && $ltrimword{1} == ' '))
\r
1194 || ((strlen($ltrimword) >= 2) && (substr($ltrimword,0,2) === '1.' || substr($ltrimword,0,2) === '0.') && $ltrimword{2} == ' '))
\r
1196 // save the whitespace for comparison
\r
1197 $this->p_vars['whitespace'] = substr($word,0,strlen($word) - strlen($ltrimword));
\r
1198 $this->p_vars['start_list'] = $ltrimword{0};
\r
1199 if ($this->p_vars['start_list'] != '1' && $this->p_vars['start_list'] != '1.' &&
\r
1200 $this->p_vars['start_list'] != '0' && $this->p_vars['start_list'] != '0.')
\r
1202 $this->p_flags['orderedlist'] = false;
\r
1205 if (substr($ltrimword,0,2) == '1.')
\r
1207 $this->p_vars['start_list'] = '1.';
\r
1209 $this->p_flags['orderedlist'] = true;
\r
1211 $this->p_vars['event_stack']->pushEvent(PHPDOCUMENTOR_PDP_EVENT_SIMLIST);
\r
1212 $this->setContext('list');
\r
1213 $this->p_flags['simplelist'] = true;
\r
1214 $this->p_vars['lists'][0] = new parserList($this->p_flags['orderedlist']);
\r
1215 $this->p_vars['list_count'] = 0;
\r
1216 $this->handleSimpleList($word, PHPDOCUMENTOR_PDP_EVENT_SIMLIST, true);
\r
1222 * setup the parser tokens, and the pushEvent/popEvent arrays
\r
1223 * @see $tokens, $pushEvent, $popEvent
\r
1224 * @param boolean determines whether to allow paragraph parsing
\r
1225 * @global boolean used to determine whether to slow things down or not by
\r
1226 * eliminating whitespace from comments
\r
1229 function setupStates($sdesc)
\r
1231 $this->p_flags['in_item'] = false;
\r
1232 $this->p_flags['in_event'] = false;
\r
1233 $this->p_flags['simplelist'] = false;
\r
1234 $this->_context = array('normal');
\r
1235 $this->tokens[STATE_NOEVENTS] = array("\n", "<code>", "<pre>", "<ol>", "<ul>",
\r
1236 "<b>", "<i>", '<var>', '<kbd>', '<samp>', "<br", '<<');
\r
1239 $this->tokens[STATE_NOEVENTS][] = "<p>";
\r
1240 $this->tokens[STATE_NOEVENTS][] = "</p>";
\r
1242 if (PHPDOCUMENTOR_KILL_WHITESPACE) $this->tokens[STATE_NOEVENTS][] = ' ';
\r
1243 $this->tokens[PHPDOCUMENTOR_PDP_STATE_P] = array("</p>","<code>","<pre>","\n","<ol>","<ul>","<b>","<i>","<br","<p>", '<<',
\r
1244 '<var>', '<kbd>', '<samp>');
\r
1245 if (PHPDOCUMENTOR_KILL_WHITESPACE) $this->tokens[PHPDOCUMENTOR_PDP_STATE_P][] = ' ';
\r
1246 $this->tokens[PHPDOCUMENTOR_PDP_STATE_CODE] = array("</code>", '<</code>>');
\r
1247 $this->tokens[PHPDOCUMENTOR_PDP_STATE_PRE] = array("</pre>", '<</pre>>');
\r
1248 $this->tokens[PHPDOCUMENTOR_PDP_STATE_LIST] = array("<ul>","<ol>","</ul>","</ol>","<li>","</li>","<b>","<i>","<br", '<<',"<code>","<pre>","<br",
\r
1249 '<var>', '<kbd>', '<samp>');
\r
1250 $this->tokens[PHPDOCUMENTOR_PDP_STATE_DOUBLECR] = array("\n","<ol>","<ul>","<code>","<pre>","<b>","<i>","<br","<p>","</p>",
\r
1251 '<var>', '<kbd>', '<samp>', '<<');
\r
1252 $this->tokens[PHPDOCUMENTOR_PDP_STATE_SIMLIST] = array("\n",'<var>', '<kbd>', '<samp>','<b>','<i>', '<pre>', '<code>',
\r
1255 $this->tokens[PHPDOCUMENTOR_PDP_STATE_B] = array("<code>","\n","<pre>","<ol>","<ul>","</b>","<i>","<br", '<<',
\r
1256 '<var>', '<kbd>', '<samp>');
\r
1257 $this->tokens[PHPDOCUMENTOR_PDP_STATE_KBD] = array("<code>","\n","<pre>","<ol>","<ul>","<b>","<i>","<br", '<<',
\r
1258 '<var>', '</kbd>', '<samp>');
\r
1259 $this->tokens[PHPDOCUMENTOR_PDP_STATE_VAR] = array("<code>","\n","<pre>","<ol>","<ul>","<b>","<i>","<br", '<<',
\r
1260 '</var>', '<kbd>', '<samp>');
\r
1261 $this->tokens[PHPDOCUMENTOR_PDP_STATE_SAMP] = array("<code>","\n","<pre>","<ol>","<ul>","<b>","<i>","<br", '<<',
\r
1262 '<var>', '<kbd>', '</samp>');
\r
1263 $this->tokens[PHPDOCUMENTOR_PDP_STATE_I] = array("<code>","\n","<pre>","<ol>","<ul>","<b>","</i>","<br", '<<',
\r
1264 '<var>', '<kbd>', '<samp>');
\r
1265 $this->tokens[PHPDOCUMENTOR_PDP_STATE_BR] = array(">","/>");
\r
1266 $this->tokens[PHPDOCUMENTOR_PDP_STATE_ESCAPE] = array('code>>', '/code>>', 'pre>>', '/pre>>', 'b>>', '/b>>',
\r
1267 'i>>', '/i>>', 'ol>>', '/ol>>', 'ul>>', '/ul>>', 'li>>', '/li>>',
\r
1268 'br>>', 'br />>', 'p>>', '/p>>', 'samp>>', '/samp>>',
\r
1269 'kbd>>', '/kbd>>', 'var>>', '/var>>');
\r
1270 if (PHPDOCUMENTOR_KILL_WHITESPACE) $this->tokens[PHPDOCUMENTOR_PDP_STATE_DOUBLECR][] = ' ';
\r
1272 // For each event word to event mapings
\r
1273 $this->pushEvent[PARSER_EVENT_NOEVENTS] =
\r
1275 "<code>" => PHPDOCUMENTOR_PDP_EVENT_CODE,
\r
1276 "<pre>" => PHPDOCUMENTOR_PDP_EVENT_PRE,
\r
1277 "<p>" => PHPDOCUMENTOR_PDP_EVENT_P,
\r
1278 "<var>" => PHPDOCUMENTOR_PDP_EVENT_VAR,
\r
1279 "<samp>" => PHPDOCUMENTOR_PDP_EVENT_SAMP,
\r
1280 "<kbd>" => PHPDOCUMENTOR_PDP_EVENT_KBD,
\r
1281 "<ol>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
\r
1282 "<ul>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
\r
1283 "<b>" => PHPDOCUMENTOR_PDP_EVENT_B,
\r
1284 "<i>" => PHPDOCUMENTOR_PDP_EVENT_I,
\r
1285 "<br" => PHPDOCUMENTOR_PDP_EVENT_BR,
\r
1286 "\n" => PHPDOCUMENTOR_PDP_EVENT_DOUBLECR,
\r
1287 '<<' => PHPDOCUMENTOR_PDP_EVENT_ESCAPE,
\r
1289 ##########################
\r
1290 $this->pushEvent[PHPDOCUMENTOR_PDP_EVENT_CODE] =
\r
1292 '<</code>>' => PHPDOCUMENTOR_PDP_EVENT_ESCAPE_CODE,
\r
1295 $this->popEvent[PHPDOCUMENTOR_PDP_EVENT_CODE] = array("</code>");
\r
1296 ##########################
\r
1297 $this->pushEvent[PHPDOCUMENTOR_PDP_EVENT_PRE] =
\r
1299 '<</pre>>' => PHPDOCUMENTOR_PDP_EVENT_ESCAPE_PRE,
\r
1302 $this->popEvent[PHPDOCUMENTOR_PDP_EVENT_PRE] = array("</pre>");
\r
1303 ##########################
\r
1305 $this->popEvent[PHPDOCUMENTOR_PDP_EVENT_BR] = array(">","/>");
\r
1306 ##########################
\r
1307 $this->pushEvent[PHPDOCUMENTOR_PDP_EVENT_P] =
\r
1309 "<code>" => PHPDOCUMENTOR_PDP_EVENT_CODE,
\r
1310 "<ol>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
\r
1311 "<ul>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
\r
1312 "<var>" => PHPDOCUMENTOR_PDP_EVENT_VAR,
\r
1313 "<samp>" => PHPDOCUMENTOR_PDP_EVENT_SAMP,
\r
1314 "<kbd>" => PHPDOCUMENTOR_PDP_EVENT_KBD,
\r
1315 "<pre>" => PHPDOCUMENTOR_PDP_EVENT_PRE,
\r
1316 "<b>" => PHPDOCUMENTOR_PDP_EVENT_B,
\r
1317 "<i>" => PHPDOCUMENTOR_PDP_EVENT_I,
\r
1318 "<br" => PHPDOCUMENTOR_PDP_EVENT_BR,
\r
1319 '<<' => PHPDOCUMENTOR_PDP_EVENT_ESCAPE,
\r
1322 $this->popEvent[PHPDOCUMENTOR_PDP_EVENT_P] = array("</p>");
\r
1323 ##########################
\r
1325 $this->pushEvent[PHPDOCUMENTOR_PDP_EVENT_LIST] =
\r
1327 "<ul>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
\r
1328 "<ol>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
\r
1329 "<code>" => PHPDOCUMENTOR_PDP_EVENT_CODE,
\r
1330 "<var>" => PHPDOCUMENTOR_PDP_EVENT_VAR,
\r
1331 "<samp>" => PHPDOCUMENTOR_PDP_EVENT_SAMP,
\r
1332 "<kbd>" => PHPDOCUMENTOR_PDP_EVENT_KBD,
\r
1333 "<b>" => PHPDOCUMENTOR_PDP_EVENT_B,
\r
1334 "<i>" => PHPDOCUMENTOR_PDP_EVENT_I,
\r
1335 "<pre>" => PHPDOCUMENTOR_PDP_EVENT_PRE,
\r
1336 "<br" => PHPDOCUMENTOR_PDP_EVENT_BR,
\r
1337 '<<' => PHPDOCUMENTOR_PDP_EVENT_ESCAPE,
\r
1340 $this->popEvent[PHPDOCUMENTOR_PDP_EVENT_LIST] = array("</ul>","</ol>");
\r
1341 ##########################
\r
1343 $this->pushEvent[PHPDOCUMENTOR_PDP_EVENT_SIMLIST] =
\r
1345 "<code>" => PHPDOCUMENTOR_PDP_EVENT_CODE,
\r
1346 "<pre>" => PHPDOCUMENTOR_PDP_EVENT_PRE,
\r
1347 "<p>" => PHPDOCUMENTOR_PDP_EVENT_P,
\r
1348 "<var>" => PHPDOCUMENTOR_PDP_EVENT_VAR,
\r
1349 "<samp>" => PHPDOCUMENTOR_PDP_EVENT_SAMP,
\r
1350 "<kbd>" => PHPDOCUMENTOR_PDP_EVENT_KBD,
\r
1351 "<b>" => PHPDOCUMENTOR_PDP_EVENT_B,
\r
1352 "<i>" => PHPDOCUMENTOR_PDP_EVENT_I,
\r
1353 "<br" => PHPDOCUMENTOR_PDP_EVENT_BR,
\r
1354 '<<' => PHPDOCUMENTOR_PDP_EVENT_ESCAPE,
\r
1356 ##########################
\r
1358 $this->pushEvent[PHPDOCUMENTOR_PDP_EVENT_DOUBLECR] =
\r
1360 "<code>" => PHPDOCUMENTOR_PDP_EVENT_CODE,
\r
1361 "<ol>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
\r
1362 "<ul>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
\r
1363 "<pre>" => PHPDOCUMENTOR_PDP_EVENT_PRE,
\r
1364 "<b>" => PHPDOCUMENTOR_PDP_EVENT_B,
\r
1365 "<i>" => PHPDOCUMENTOR_PDP_EVENT_I,
\r
1366 "<var>" => PHPDOCUMENTOR_PDP_EVENT_VAR,
\r
1367 "<samp>" => PHPDOCUMENTOR_PDP_EVENT_SAMP,
\r
1368 "<kbd>" => PHPDOCUMENTOR_PDP_EVENT_KBD,
\r
1369 "<br" => PHPDOCUMENTOR_PDP_EVENT_BR,
\r
1370 "<p>" => PHPDOCUMENTOR_PDP_EVENT_P,
\r
1371 '<<' => PHPDOCUMENTOR_PDP_EVENT_ESCAPE,
\r
1374 ##########################
\r
1375 $this->pushEvent[PHPDOCUMENTOR_PDP_EVENT_B] =
\r
1377 "<code>" => PHPDOCUMENTOR_PDP_EVENT_CODE,
\r
1378 "<ol>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
\r
1379 "<ul>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
\r
1380 "<pre>" => PHPDOCUMENTOR_PDP_EVENT_PRE,
\r
1381 "<var>" => PHPDOCUMENTOR_PDP_EVENT_VAR,
\r
1382 "<samp>" => PHPDOCUMENTOR_PDP_EVENT_SAMP,
\r
1383 "<kbd>" => PHPDOCUMENTOR_PDP_EVENT_KBD,
\r
1384 "<br" => PHPDOCUMENTOR_PDP_EVENT_BR,
\r
1385 '<i>' => PHPDOCUMENTOR_PDP_EVENT_I,
\r
1386 '<<' => PHPDOCUMENTOR_PDP_EVENT_ESCAPE,
\r
1389 $this->popEvent[PHPDOCUMENTOR_PDP_EVENT_B] = array("</b>");
\r
1391 ##########################
\r
1392 $this->pushEvent[PHPDOCUMENTOR_PDP_EVENT_I] =
\r
1394 "<code>" => PHPDOCUMENTOR_PDP_EVENT_CODE,
\r
1395 "<ol>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
\r
1396 "<ul>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
\r
1397 "<pre>" => PHPDOCUMENTOR_PDP_EVENT_PRE,
\r
1398 "<var>" => PHPDOCUMENTOR_PDP_EVENT_VAR,
\r
1399 "<samp>" => PHPDOCUMENTOR_PDP_EVENT_SAMP,
\r
1400 "<kbd>" => PHPDOCUMENTOR_PDP_EVENT_KBD,
\r
1401 "<br" => PHPDOCUMENTOR_PDP_EVENT_BR,
\r
1402 '<b>' => PHPDOCUMENTOR_PDP_EVENT_B,
\r
1403 '<<' => PHPDOCUMENTOR_PDP_EVENT_ESCAPE,
\r
1406 $this->popEvent[PHPDOCUMENTOR_PDP_EVENT_I] = array("</i>");
\r
1408 ##########################
\r
1409 $this->pushEvent[PHPDOCUMENTOR_PDP_EVENT_VAR] =
\r
1411 "<code>" => PHPDOCUMENTOR_PDP_EVENT_CODE,
\r
1412 "<ol>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
\r
1413 "<ul>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
\r
1414 "<pre>" => PHPDOCUMENTOR_PDP_EVENT_PRE,
\r
1415 "<i>" => PHPDOCUMENTOR_PDP_EVENT_I,
\r
1416 "<samp>" => PHPDOCUMENTOR_PDP_EVENT_SAMP,
\r
1417 "<kbd>" => PHPDOCUMENTOR_PDP_EVENT_KBD,
\r
1418 "<br" => PHPDOCUMENTOR_PDP_EVENT_BR,
\r
1419 '<b>' => PHPDOCUMENTOR_PDP_EVENT_B,
\r
1420 '<<' => PHPDOCUMENTOR_PDP_EVENT_ESCAPE,
\r
1423 $this->popEvent[PHPDOCUMENTOR_PDP_EVENT_VAR] = array("</var>");
\r
1425 ##########################
\r
1426 $this->pushEvent[PHPDOCUMENTOR_PDP_EVENT_SAMP] =
\r
1428 "<code>" => PHPDOCUMENTOR_PDP_EVENT_CODE,
\r
1429 "<ol>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
\r
1430 "<ul>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
\r
1431 "<pre>" => PHPDOCUMENTOR_PDP_EVENT_PRE,
\r
1432 "<var>" => PHPDOCUMENTOR_PDP_EVENT_VAR,
\r
1433 "<i>" => PHPDOCUMENTOR_PDP_EVENT_I,
\r
1434 "<kbd>" => PHPDOCUMENTOR_PDP_EVENT_KBD,
\r
1435 "<br" => PHPDOCUMENTOR_PDP_EVENT_BR,
\r
1436 '<b>' => PHPDOCUMENTOR_PDP_EVENT_B,
\r
1437 '<<' => PHPDOCUMENTOR_PDP_EVENT_ESCAPE,
\r
1440 $this->popEvent[PHPDOCUMENTOR_PDP_EVENT_SAMP] = array("</samp>");
\r
1442 ##########################
\r
1443 $this->pushEvent[PHPDOCUMENTOR_PDP_EVENT_KBD] =
\r
1445 "<code" => PHPDOCUMENTOR_PDP_EVENT_CODE,
\r
1446 "<ol>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
\r
1447 "<ul>" => PHPDOCUMENTOR_PDP_EVENT_LIST,
\r
1448 "<pre" => PHPDOCUMENTOR_PDP_EVENT_PRE,
\r
1449 "<var>" => PHPDOCUMENTOR_PDP_EVENT_VAR,
\r
1450 "<samp>" => PHPDOCUMENTOR_PDP_EVENT_SAMP,
\r
1451 "<i>" => PHPDOCUMENTOR_PDP_EVENT_I,
\r
1452 "<br" => PHPDOCUMENTOR_PDP_EVENT_BR,
\r
1453 '<b>' => PHPDOCUMENTOR_PDP_EVENT_B,
\r
1454 '<<' => PHPDOCUMENTOR_PDP_EVENT_ESCAPE,
\r
1457 $this->popEvent[PHPDOCUMENTOR_PDP_EVENT_KBD] = array("</kbd>");
\r
1460 function getParserEventName ($value)
\r
1463 PARSER_EVENT_NOEVENTS => "PARSER_EVENT_NOEVENTS",
\r
1464 PHPDOCUMENTOR_PDP_EVENT_CODE => "PHPDOCUMENTOR_PDP_EVENT_CODE",
\r
1465 PHPDOCUMENTOR_PDP_EVENT_P => "PHPDOCUMENTOR_PDP_EVENT_P",
\r
1466 PHPDOCUMENTOR_PDP_EVENT_B => "PHPDOCUMENTOR_PDP_EVENT_B",
\r
1467 PHPDOCUMENTOR_PDP_EVENT_I => "PHPDOCUMENTOR_PDP_EVENT_I",
\r
1468 PHPDOCUMENTOR_PDP_EVENT_BR => "PHPDOCUMENTOR_PDP_EVENT_BR",
\r
1469 PHPDOCUMENTOR_PDP_EVENT_VAR => "PHPDOCUMENTOR_PDP_EVENT_VAR",
\r
1470 PHPDOCUMENTOR_PDP_EVENT_SAMP => "PHPDOCUMENTOR_PDP_EVENT_SAMP",
\r
1471 PHPDOCUMENTOR_PDP_EVENT_KBD => "PHPDOCUMENTOR_PDP_EVENT_KBD",
\r
1472 PHPDOCUMENTOR_PDP_EVENT_ESCAPE => "PHPDOCUMENTOR_PDP_EVENT_ESCAPE",
\r
1473 PHPDOCUMENTOR_PDP_EVENT_ESCAPE_CODE => "PHPDOCUMENTOR_PDP_EVENT_ESCAPE_CODE",
\r
1474 PHPDOCUMENTOR_PDP_EVENT_ESCAPE_PRE => "PHPDOCUMENTOR_PDP_EVENT_ESCAPE_PRE",
\r
1475 PHPDOCUMENTOR_PDP_EVENT_DOUBLECR => "PHPDOCUMENTOR_PDP_EVENT_DOUBLECR",
\r
1476 PHPDOCUMENTOR_PDP_EVENT_LIST => "PHPDOCUMENTOR_PDP_EVENT_LIST",
\r
1477 PHPDOCUMENTOR_PDP_EVENT_PRE => "PHPDOCUMENTOR_PDP_EVENT_PRE",
\r
1478 PHPDOCUMENTOR_PDP_EVENT_SIMLIST => "PHPDOCUMENTOR_PDP_EVENT_SIMLIST",
\r
1480 if (isset($lookup[$value]))
\r
1481 return $lookup[$value];
\r
1482 else return $value;
\r