diff options
Diffstat (limited to 'inc/parser')
-rw-r--r-- | inc/parser/handler.php | 590 | ||||
-rw-r--r-- | inc/parser/lexer.php | 62 | ||||
-rw-r--r-- | inc/parser/parser.php | 292 | ||||
-rw-r--r-- | inc/parser/renderer.php | 156 | ||||
-rw-r--r-- | inc/parser/spamcheck.php | 22 | ||||
-rw-r--r-- | inc/parser/wiki.php | 134 | ||||
-rw-r--r-- | inc/parser/xhtml.php | 222 | ||||
-rw-r--r-- | inc/parser/xhtmlsummary.php | 170 |
8 files changed, 824 insertions, 824 deletions
diff --git a/inc/parser/handler.php b/inc/parser/handler.php index a1f2fe4c7..3609e23a8 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -2,51 +2,51 @@ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); class Doku_Handler { - + var $Renderer = NULL; - + var $CallWriter = NULL; - + var $calls = array(); - + var $meta = array( 'section' => FALSE, 'toc' => TRUE, 'cache' => TRUE, ); - + var $rewriteBlocks = TRUE; - + function Doku_Handler() { $this->CallWriter = & new Doku_Handler_CallWriter($this); } - + function _addCall($handler, $args, $pos) { $call = array($handler,$args, $pos); $this->CallWriter->writeCall($call); } - + function _finalize(){ if ( $this->meta['section'] ) { $S = & new Doku_Handler_Section(); $this->calls = $S->process($this->calls); } - + if ( $this->rewriteBlocks ) { $B = & new Doku_Handler_Block(); $this->calls = $B->process($this->calls); } - + if ( $this->meta['toc'] ) { $T = & new Doku_Handler_Toc(); $this->calls = $T->process($this->calls); } - + array_unshift($this->calls,array('document_start',array(),0)); $last_call = end($this->calls); array_push($this->calls,array('document_end',array(),$last_call[2])); } - + function fetch() { $call = each($this->calls); if ( $call ) { @@ -66,24 +66,24 @@ class Doku_Handler { */ function plugin($match, $state, $pos, $pluginname){ $data = array($match); - $plugin =& plugin_load('syntax',$pluginname); + $plugin =& plugin_load('syntax',$pluginname); if($plugin != null){ $data = $plugin->handle($match, $state, $pos, $this); } $this->_addCall('plugin',array($pluginname,$data,$pos),$pos); return TRUE; } - + function base($match, $state, $pos) { switch ( $state ) { case DOKU_LEXER_UNMATCHED: $this->_addCall('cdata',array($match), $pos); return TRUE; break; - + } } - + function header($match, $state, $pos) { $match = trim($match); $levels = array( @@ -95,23 +95,23 @@ class Doku_Handler { ); $hsplit = preg_split( '/(={2,})/u', $match,-1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ); - + // Locate the level - default to level 1 if no match (title contains == signs) if ( isset($hsplit[0]) && array_key_exists($hsplit[0], $levels) ) { $level = $levels[$hsplit[0]]; } else { $level = 1; } - + // Strip markers and whitespaces $title = trim($match,'='); $title = trim($title,' '); - + $this->_addCall('header',array($title,$level,$pos), $pos); $this->meta['section'] = TRUE; return TRUE; } - + function notoc($match, $state, $pos) { $this->meta['toc'] = FALSE; return TRUE; @@ -121,22 +121,22 @@ class Doku_Handler { $this->_addCall('nocache',array(),$pos); return TRUE; } - + function linebreak($match, $state, $pos) { $this->_addCall('linebreak',array(),$pos); return TRUE; } - + function eol($match, $state, $pos) { $this->_addCall('eol',array(),$pos); return TRUE; } - + function hr($match, $state, $pos) { $this->_addCall('hr',array(),$pos); return TRUE; } - + function _nestingTag($match, $state, $pos, $name) { switch ( $state ) { case DOKU_LEXER_ENTER: @@ -150,48 +150,48 @@ class Doku_Handler { break; } } - + function strong($match, $state, $pos) { $this->_nestingTag($match, $state, $pos, 'strong'); return TRUE; } - + function emphasis($match, $state, $pos) { $this->_nestingTag($match, $state, $pos, 'emphasis'); return TRUE; } - + function underline($match, $state, $pos) { $this->_nestingTag($match, $state, $pos, 'underline'); return TRUE; } - + function monospace($match, $state, $pos) { $this->_nestingTag($match, $state, $pos, 'monospace'); return TRUE; } - + function subscript($match, $state, $pos) { $this->_nestingTag($match, $state, $pos, 'subscript'); return TRUE; } - + function superscript($match, $state, $pos) { $this->_nestingTag($match, $state, $pos, 'superscript'); return TRUE; } - + function deleted($match, $state, $pos) { $this->_nestingTag($match, $state, $pos, 'deleted'); return TRUE; } - - + + function footnote($match, $state, $pos) { $this->_nestingTag($match, $state, $pos, 'footnote'); return TRUE; } - + function listblock($match, $state, $pos) { switch ( $state ) { case DOKU_LEXER_ENTER: @@ -214,38 +214,38 @@ class Doku_Handler { } return TRUE; } - + function unformatted($match, $state, $pos) { if ( $state == DOKU_LEXER_UNMATCHED ) { $this->_addCall('unformatted',array($match), $pos); } return TRUE; } - + function php($match, $state, $pos) { - global $conf; + global $conf; if ( $state == DOKU_LEXER_UNMATCHED ) { - if ($conf['phpok']) { - $this->_addCall('php',array($match), $pos); - } else { - $this->_addCall('file',array($match), $pos); - } + if ($conf['phpok']) { + $this->_addCall('php',array($match), $pos); + } else { + $this->_addCall('file',array($match), $pos); + } } return TRUE; } - + function html($match, $state, $pos) { - global $conf; + global $conf; if ( $state == DOKU_LEXER_UNMATCHED ) { - if($conf['htmlok']){ - $this->_addCall('html',array($match), $pos); - } else { - $this->_addCall('file',array($match), $pos); - } + if($conf['htmlok']){ + $this->_addCall('html',array($match), $pos); + } else { + $this->_addCall('file',array($match), $pos); + } } return TRUE; } - + function preformatted($match, $state, $pos) { switch ( $state ) { case DOKU_LEXER_ENTER: @@ -266,47 +266,47 @@ class Doku_Handler { $this->_addCall('preformatted_content',array($match), $pos); break; } - + return TRUE; } - + function file($match, $state, $pos) { if ( $state == DOKU_LEXER_UNMATCHED ) { $this->_addCall('file',array($match), $pos); } return TRUE; } - + function quote($match, $state, $pos) { - + switch ( $state ) { - + case DOKU_LEXER_ENTER: $ReWriter = & new Doku_Handler_Quote($this->CallWriter); $this->CallWriter = & $ReWriter; $this->_addCall('quote_start',array($match), $pos); break; - + case DOKU_LEXER_EXIT: $this->_addCall('quote_end',array(), $pos); $this->CallWriter->process(); $ReWriter = & $this->CallWriter; $this->CallWriter = & $ReWriter->CallWriter; break; - + case DOKU_LEXER_MATCHED: $this->_addCall('quote_newline',array($match), $pos); break; - + case DOKU_LEXER_UNMATCHED: $this->_addCall('cdata',array($match), $pos); break; - + } - + return TRUE; } - + function code($match, $state, $pos) { switch ( $state ) { case DOKU_LEXER_UNMATCHED: @@ -327,64 +327,64 @@ class Doku_Handler { } return TRUE; } - + function acronym($match, $state, $pos) { $this->_addCall('acronym',array($match), $pos); return TRUE; } - + function smiley($match, $state, $pos) { $this->_addCall('smiley',array($match), $pos); return TRUE; } - + function wordblock($match, $state, $pos) { $this->_addCall('wordblock',array($match), $pos); return TRUE; } - + function entity($match, $state, $pos) { $this->_addCall('entity',array($match), $pos); return TRUE; } - + function multiplyentity($match, $state, $pos) { preg_match_all('/\d+/',$match,$matches); $this->_addCall('multiplyentity',array($matches[0][0],$matches[0][1]), $pos); return TRUE; } - + function singlequoteopening($match, $state, $pos) { $this->_addCall('singlequoteopening',array(), $pos); return TRUE; } - + function singlequoteclosing($match, $state, $pos) { $this->_addCall('singlequoteclosing',array(), $pos); return TRUE; } - + function doublequoteopening($match, $state, $pos) { $this->_addCall('doublequoteopening',array(), $pos); return TRUE; } - + function doublequoteclosing($match, $state, $pos) { $this->_addCall('doublequoteclosing',array(), $pos); return TRUE; } - + function camelcaselink($match, $state, $pos) { $this->_addCall('camelcaselink',array($match), $pos); return TRUE; } - + /* */ function internallink($match, $state, $pos) { // Strip the opening and closing markup $link = preg_replace(array('/^\[\[/','/\]\]$/u'),'',$match); - + // Split title from URL $link = preg_split('/\|/u',$link,2); if ( !isset($link[1]) ) { @@ -444,20 +444,20 @@ class Doku_Handler { return TRUE; } - + function filelink($match, $state, $pos) { $this->_addCall('filelink',array($match, NULL), $pos); return TRUE; } - + function windowssharelink($match, $state, $pos) { $this->_addCall('windowssharelink',array($match, NULL), $pos); return TRUE; } - + function media($match, $state, $pos) { $p = Doku_Handler_Parse_Media($match); - + $this->_addCall( $p['type'], array($p['src'], $p['title'], $p['align'], $p['width'], @@ -472,7 +472,7 @@ class Doku_Handler { $this->_addCall('rss',array($link),$pos); return TRUE; } - + function externallink($match, $state, $pos) { // Prevent use of multibyte strings in URLs // See: http://www.boingboing.net/2005/02/06/shmoo_group_exploit_.html @@ -480,26 +480,26 @@ class Doku_Handler { /*if ( strlen($match) != utf8_strlen($match) ) { $this->_addCall('cdata',array($match), $pos); } else {*/ - + $this->_addCall('externallink',array($match, NULL), $pos); //} return TRUE; } - + function emaillink($match, $state, $pos) { $email = preg_replace(array('/^</','/>$/'),'',$match); $this->_addCall('emaillink',array($email, NULL), $pos); return TRUE; } - + function table($match, $state, $pos) { switch ( $state ) { - + case DOKU_LEXER_ENTER: - + $ReWriter = & new Doku_Handler_Table($this->CallWriter); $this->CallWriter = & $ReWriter; - + $this->_addCall('table_start', array(), $pos); //$this->_addCall('table_row', array(), $pos); if ( trim($match) == '^' ) { @@ -508,20 +508,20 @@ class Doku_Handler { $this->_addCall('tablecell', array(), $pos); } break; - + case DOKU_LEXER_EXIT: $this->_addCall('table_end', array(), $pos); $this->CallWriter->process(); $ReWriter = & $this->CallWriter; $this->CallWriter = & $ReWriter->CallWriter; break; - + case DOKU_LEXER_UNMATCHED: if ( trim($match) != '' ) { $this->_addCall('cdata',array($match), $pos); } break; - + case DOKU_LEXER_MATCHED: if ( $match == ' ' ){ $this->_addCall('cdata', array($match), $pos); @@ -551,15 +551,15 @@ function Doku_Handler_Parse_Media($match) { // Strip the opening and closing markup $link = preg_replace(array('/^\{\{/','/\}\}$/u'),'',$match); - + // Split title from URL $link = preg_split('/\|/u',$link,2); - - + + // Check alignment $ralign = (bool)preg_match('/^ /',$link[0]); $lalign = (bool)preg_match('/ $/',$link[0]); - + // Logic = what's that ;)... if ( $lalign & $ralign ) { $align = 'center'; @@ -570,15 +570,15 @@ function Doku_Handler_Parse_Media($match) { } else { $align = NULL; } - + // The title... if ( !isset($link[1]) ) { $link[1] = NULL; } - + //remove aligning spaces $link[0] = trim($link[0]); - + //split into src and parameters (using the very last questionmark) $pos = strrpos($link[0], '?'); if($pos !== false){ @@ -606,14 +606,14 @@ function Doku_Handler_Parse_Media($match) { }else{ $linking = 'details'; } - + //get caching command if (preg_match('/(nocache|recache)/i',$param,$cachemode)){ $cache = $cachemode[1]; }else{ $cache = 'cache'; } - + // Check whether this is a local or remote image if ( preg_match('#^(https?|ftp)#i',$src) ) { $call = 'externalmedia'; @@ -631,23 +631,23 @@ function Doku_Handler_Parse_Media($match) { 'cache'=>$cache, 'linking'=>$linking, ); - + return $params; } //------------------------------------------------------------------------ class Doku_Handler_CallWriter { - + var $Handler; - + function Doku_Handler_CallWriter(& $Handler) { $this->Handler = & $Handler; } - + function writeCall($call) { $this->Handler->calls[] = $call; } - + function writeCalls($calls) { $this->Handler->calls = array_merge($this->Handler->calls, $calls); } @@ -655,27 +655,27 @@ class Doku_Handler_CallWriter { //------------------------------------------------------------------------ class Doku_Handler_List { - + var $CallWriter; - + var $calls = array(); var $listCalls = array(); var $listStack = array(); - + function Doku_Handler_List(& $CallWriter) { $this->CallWriter = & $CallWriter; } - + function writeCall($call) { $this->calls[] = $call; } - + // Probably not needed but just in case... function writeCalls($calls) { $this->calls = array_merge($this->calls, $calls); $this->CallWriter->writeCalls($this->calls); } - + //------------------------------------------------------------------------ function process() { foreach ( $this->calls as $call ) { @@ -694,26 +694,26 @@ class Doku_Handler_List { break; } } - + $this->CallWriter->writeCalls($this->listCalls); } - + //------------------------------------------------------------------------ function listStart($call) { $depth = $this->interpretSyntax($call[1][0], $listType); - + $this->initialDepth = $depth; $this->listStack[] = array($listType, $depth); - + $this->listCalls[] = array('list'.$listType.'_open',array(),$call[2]); $this->listCalls[] = array('listitem_open',array(1),$call[2]); $this->listCalls[] = array('listcontent_open',array(),$call[2]); } - + //------------------------------------------------------------------------ function listEnd($call) { $closeContent = TRUE; - + while ( $list = array_pop($this->listStack) ) { if ( $closeContent ) { $this->listCalls[] = array('listcontent_close',array(),$call[2]); @@ -723,109 +723,109 @@ class Doku_Handler_List { $this->listCalls[] = array('list'.$list[0].'_close', array(), $call[2]); } } - + //------------------------------------------------------------------------ function listOpen($call) { $depth = $this->interpretSyntax($call[1][0], $listType); $end = end($this->listStack); - + // Not allowed to be shallower than initialDepth if ( $depth < $this->initialDepth ) { $depth = $this->initialDepth; } - + //------------------------------------------------------------------------ if ( $depth == $end[1] ) { - + // Just another item in the list... if ( $listType == $end[0] ) { $this->listCalls[] = array('listcontent_close',array(),$call[2]); $this->listCalls[] = array('listitem_close',array(),$call[2]); $this->listCalls[] = array('listitem_open',array($depth-1),$call[2]); $this->listCalls[] = array('listcontent_open',array(),$call[2]); - + // Switched list type... } else { - + $this->listCalls[] = array('listcontent_close',array(),$call[2]); $this->listCalls[] = array('listitem_close',array(),$call[2]); $this->listCalls[] = array('list'.$end[0].'_close', array(), $call[2]); $this->listCalls[] = array('list'.$listType.'_open', array(), $call[2]); $this->listCalls[] = array('listitem_open', array($depth-1), $call[2]); $this->listCalls[] = array('listcontent_open',array(),$call[2]); - + array_pop($this->listStack); $this->listStack[] = array($listType, $depth); } - + //------------------------------------------------------------------------ // Getting deeper... } else if ( $depth > $end[1] ) { - + $this->listCalls[] = array('listcontent_close',array(),$call[2]); $this->listCalls[] = array('list'.$listType.'_open', array(), $call[2]); $this->listCalls[] = array('listitem_open', array($depth-1), $call[2]); $this->listCalls[] = array('listcontent_open',array(),$call[2]); - + $this->listStack[] = array($listType, $depth); - + //------------------------------------------------------------------------ // Getting shallower ( $depth < $end[1] ) } else { $this->listCalls[] = array('listcontent_close',array(),$call[2]); $this->listCalls[] = array('listitem_close',array(),$call[2]); $this->listCalls[] = array('list'.$end[0].'_close',array(),$call[2]); - + // Throw away the end - done array_pop($this->listStack); - + while (1) { $end = end($this->listStack); - + if ( $end[1] <= $depth ) { - + // Normalize depths $depth = $end[1]; - + $this->listCalls[] = array('listitem_close',array(),$call[2]); - + if ( $end[0] == $listType ) { $this->listCalls[] = array('listitem_open',array($depth-1),$call[2]); $this->listCalls[] = array('listcontent_open',array(),$call[2]); - + } else { // Switching list type... $this->listCalls[] = array('list'.$end[0].'_close', array(), $call[2]); $this->listCalls[] = array('list'.$listType.'_open', array(), $call[2]); $this->listCalls[] = array('listitem_open', array($depth-1), $call[2]); $this->listCalls[] = array('listcontent_open',array(),$call[2]); - + array_pop($this->listStack); $this->listStack[] = array($listType, $depth); } - + break; - + // Haven't dropped down far enough yet.... ( $end[1] > $depth ) } else { - + $this->listCalls[] = array('listitem_close',array(),$call[2]); $this->listCalls[] = array('list'.$end[0].'_close',array(),$call[2]); - + array_pop($this->listStack); - + } - + } - + } } - + //------------------------------------------------------------------------ function listContent($call) { $this->listCalls[] = $call; } - + //------------------------------------------------------------------------ function interpretSyntax($match, & $type) { if ( substr($match,-1) == '*' ) { @@ -839,29 +839,29 @@ class Doku_Handler_List { //------------------------------------------------------------------------ class Doku_Handler_Preformatted { - + var $CallWriter; - + var $calls = array(); var $pos; var $text =''; - - - + + + function Doku_Handler_Preformatted(& $CallWriter) { $this->CallWriter = & $CallWriter; } - + function writeCall($call) { $this->calls[] = $call; } - + // Probably not needed but just in case... function writeCalls($calls) { $this->calls = array_merge($this->calls, $calls); $this->CallWriter->writeCalls($this->calls); } - + function process() { foreach ( $this->calls as $call ) { switch ($call[0]) { @@ -884,42 +884,42 @@ class Doku_Handler_Preformatted { //------------------------------------------------------------------------ class Doku_Handler_Quote { - + var $CallWriter; - + var $calls = array(); - + var $quoteCalls = array(); - + function Doku_Handler_Quote(& $CallWriter) { $this->CallWriter = & $CallWriter; } - + function writeCall($call) { $this->calls[] = $call; } - + // Probably not needed but just in case... function writeCalls($calls) { $this->calls = array_merge($this->calls, $calls); $this->CallWriter->writeCalls($this->calls); } - + function process() { - + $quoteDepth = 1; - + foreach ( $this->calls as $call ) { switch ($call[0]) { - + case 'quote_start': - + $this->quoteCalls[] = array('quote_open',array(),$call[2]); - + case 'quote_newline': - + $quoteLength = $this->getDepth($call[1][0]); - + if ( $quoteLength > $quoteDepth ) { $quoteDiff = $quoteLength - $quoteDepth; for ( $i = 1; $i <= $quoteDiff; $i++ ) { @@ -931,32 +931,32 @@ class Doku_Handler_Quote { $this->quoteCalls[] = array('quote_close',array(),$call[2]); } } - + $quoteDepth = $quoteLength; - + break; - + case 'quote_end': - + if ( $quoteDepth > 1 ) { $quoteDiff = $quoteDepth - 1; for ( $i = 1; $i <= $quoteDiff; $i++ ) { $this->quoteCalls[] = array('quote_close',array(),$call[2]); } } - + $this->quoteCalls[] = array('quote_close',array(),$call[2]); - + $this->CallWriter->writeCalls($this->quoteCalls); break; - + default: $this->quoteCalls[] = $call; break; } } } - + function getDepth($marker) { preg_match('/>{1,}/', $marker, $matches); $quoteLength = strlen($matches[0]); @@ -966,9 +966,9 @@ class Doku_Handler_Quote { //------------------------------------------------------------------------ class Doku_Handler_Table { - + var $CallWriter; - + var $calls = array(); var $tableCalls = array(); var $maxCols = 0; @@ -976,21 +976,21 @@ class Doku_Handler_Table { var $currentCols = 0; var $firstCell = FALSE; var $lastCellType = 'tablecell'; - + function Doku_Handler_Table(& $CallWriter) { $this->CallWriter = & $CallWriter; } - + function writeCall($call) { $this->calls[] = $call; } - + // Probably not needed but just in case... function writeCalls($calls) { $this->calls = array_merge($this->calls, $calls); $this->CallWriter->writeCalls($this->calls); } - + //------------------------------------------------------------------------ function process() { foreach ( $this->calls as $call ) { @@ -1017,18 +1017,18 @@ class Doku_Handler_Table { } $this->CallWriter->writeCalls($this->tableCalls); } - + function tableStart($call) { $this->tableCalls[] = array('table_open',array(),$call[2]); $this->tableCalls[] = array('tablerow_open',array(),$call[2]); $this->firstCell = TRUE; } - + function tableEnd($call) { $this->tableCalls[] = array('table_close',array(),$call[2]); $this->finalizeTable(); } - + function tableRowOpen($call) { $this->tableCalls[] = $call; $this->currentCols = 0; @@ -1036,16 +1036,16 @@ class Doku_Handler_Table { $this->lastCellType = 'tablecell'; $this->maxRows++; } - + function tableRowClose($call) { // Strip off final cell opening and anything after it while ( $discard = array_pop($this->tableCalls ) ) { - + if ( $discard[0] == 'tablecell_open' || $discard[0] == 'tableheader_open') { - + // Its a spanning element - put it back and close it if ( $discard[1][0] > 1 ) { - + $this->tableCalls[] = $discard; if ( strstr($discard[0],'cell') ) { $name = 'tablecell'; @@ -1054,50 +1054,50 @@ class Doku_Handler_Table { } $this->tableCalls[] = array($name.'_close',array(),$call[2]); } - + break; } } $this->tableCalls[] = $call; - + if ( $this->currentCols > $this->maxCols ) { $this->maxCols = $this->currentCols; } } - + function tableCell($call) { if ( !$this->firstCell ) { - + // Increase the span $lastCall = end($this->tableCalls); - + // A cell call which follows an open cell means an empty cell so span if ( $lastCall[0] == 'tablecell_open' || $lastCall[0] == 'tableheader_open' ) { $this->tableCalls[] = array('colspan',array(),$call[2]); - + } - + $this->tableCalls[] = array($this->lastCellType.'_close',array(),$call[2]); $this->tableCalls[] = array($call[0].'_open',array(1,NULL),$call[2]); $this->lastCellType = $call[0]; - + } else { - + $this->tableCalls[] = array($call[0].'_open',array(1,NULL),$call[2]); $this->lastCellType = $call[0]; $this->firstCell = FALSE; - + } - + $this->currentCols++; } - + function tableDefault($call) { $this->tableCalls[] = $call; } - + function finalizeTable() { - + // Add the max cols and rows to the table opening if ( $this->tableCalls[0][0] == 'table_open' ) { // Adjust to num cols not num col delimeters @@ -1106,30 +1106,30 @@ class Doku_Handler_Table { } else { trigger_error('First element in table call list is not table_open'); } - + $lastRow = 0; $lastCell = 0; $toDelete = array(); - + // Look for the colspan elements and increment the colspan on the // previous non-empty opening cell. Once done, delete all the cells // that contain colspans foreach ( $this->tableCalls as $key => $call ) { - + if ( $call[0] == 'tablerow_open' ) { - + $lastRow = $key; - + } else if ( $call[0] == 'tablecell_open' || $call[0] == 'tableheader_open' ) { - + $lastCell = $key; - + } else if ( $call[0] == 'table_align' ) { - + // If the previous element was a cell open, align right if ( $this->tableCalls[$key-1][0] == 'tablecell_open' || $this->tableCalls[$key-1][0] == 'tableheader_open' ) { $this->tableCalls[$key-1][1][1] = 'right'; - + // If the next element if the close of an element, align either center or left } else if ( $this->tableCalls[$key+1][0] == 'tablecell_close' || $this->tableCalls[$key+1][0] == 'tableheader_close' ) { if ( $this->tableCalls[$lastCell][1][1] == 'right' ) { @@ -1137,29 +1137,29 @@ class Doku_Handler_Table { } else { $this->tableCalls[$lastCell][1][1] = 'left'; } - + } - + // Now convert the whitespace back to cdata $this->tableCalls[$key][0] = 'cdata'; } else if ( $call[0] == 'colspan' ) { - + $this->tableCalls[$key-1][1][0] = FALSE; - + for($i = $key-2; $i > $lastRow; $i--) { - + if ( $this->tableCalls[$i][0] == 'tablecell_open' || $this->tableCalls[$i][0] == 'tableheader_open' ) { - + if ( FALSE !== $this->tableCalls[$i][1][0] ) { $this->tableCalls[$i][1][0]++; break; } - - + + } } - + $toDelete[] = $key-1; $toDelete[] = $key; $toDelete[] = $key+1; @@ -1191,36 +1191,36 @@ class Doku_Handler_Table { //------------------------------------------------------------------------ class Doku_Handler_Section { - + function process($calls) { - + $sectionCalls = array(); $inSection = FALSE; - + foreach ( $calls as $call ) { - + if ( $call[0] == 'header' ) { - + if ( $inSection ) { $sectionCalls[] = array('section_close',array(), $call[2]); } - + $sectionCalls[] = $call; $sectionCalls[] = array('section_open',array($call[1][1]), $call[2]); $inSection = TRUE; - + } else { $sectionCalls[] = $call; } } - + if ( $inSection ) { $sectionCalls[] = array('section_close',array(), $call[2]); } - + return $sectionCalls; } - + } /** @@ -1229,15 +1229,15 @@ class Doku_Handler_Section { * @author Harry Fuecks <hfuecks@gmail.com> */ class Doku_Handler_Block { - + var $calls = array(); - + var $blockStack = array(); - + var $inParagraph = FALSE; var $atStart = TRUE; var $skipEolKey = -1; - + // Blocks these should not be inside paragraphs var $blockOpen = array( 'header', @@ -1247,7 +1247,7 @@ class Doku_Handler_Block { 'section_open', // Needed to prevent p_open between header and section_open 'code','file','hr','preformatted', ); - + var $blockClose = array( 'header', 'listu_close','listo_close','listitem_close','listcontent_close', @@ -1256,16 +1256,16 @@ class Doku_Handler_Block { 'section_close', // Needed to prevent p_close after section_close 'code','file','hr','preformatted', ); - + // Stacks can contain paragraphs var $stackOpen = array( 'footnote_open','section_open', ); - + var $stackClose = array( 'footnote_close','section_close', ); - + /** * Constructor. Adds loaded syntax plugins to the block and stack @@ -1292,7 +1292,7 @@ class Doku_Handler_Block { } } } - + /** * Close a paragraph if needed * @@ -1313,7 +1313,7 @@ class Doku_Handler_Block { break; } } - + if(trim($content)==''){ //remove the whole paragraph array_splice($this->calls,$i); @@ -1321,7 +1321,7 @@ class Doku_Handler_Block { $this->calls[] = array('p_close',array(), $pos); } } - + /** * Processes the whole instruction stack to open and close paragraphs * @@ -1333,7 +1333,7 @@ class Doku_Handler_Block { foreach ( $calls as $key => $call ) { $cname = $call[0]; if($cname == 'plugin') $cname='plugin_'.$call[1][0]; - + // Process blocks which are stack like... (contain linefeeds) if ( in_array($cname,$this->stackOpen ) ) { /* @@ -1344,7 +1344,7 @@ class Doku_Handler_Block { } */ $this->calls[] = $call; - + // Hack - footnotes shouldn't immediately contain a p_open if ( $cname != 'footnote_open' ) { $this->addToStack(); @@ -1353,9 +1353,9 @@ class Doku_Handler_Block { } continue; } - + if ( in_array($cname,$this->stackClose ) ) { - + if ( $this->inParagraph ) { //$this->calls[] = array('p_close',array(), $call[2]); $this->closeParagraph($call[2]); @@ -1364,11 +1364,11 @@ class Doku_Handler_Block { $this->removeFromStack(); continue; } - + if ( !$this->atStart ) { - + if ( $cname == 'eol' ) { - + /* XXX if ( $this->inParagraph ) { @@ -1391,7 +1391,7 @@ class Doku_Handler_Block { $this->calls[] = array('p_open',array(), $call[2]); $this->inParagraph = TRUE; - + # Mark the next instruction for skipping $this->skipEolKey = $key+1; @@ -1401,9 +1401,9 @@ class Doku_Handler_Block { } } - + } else { - + $storeCall = TRUE; if ( $this->inParagraph && in_array($cname, $this->blockOpen) ) { //$this->calls[] = array('p_close',array(), $call[2]); @@ -1412,7 +1412,7 @@ class Doku_Handler_Block { $this->calls[] = $call; $storeCall = FALSE; } - + if ( in_array($cname, $this->blockClose) ) { if ( $this->inParagraph ) { //$this->calls[] = array('p_close',array(), $call[2]); @@ -1423,7 +1423,7 @@ class Doku_Handler_Block { $this->calls[] = $call; $storeCall = FALSE; } - + // This really sucks and suggests this whole class sucks but... if ( isset($calls[$key+1]) && @@ -1431,21 +1431,21 @@ class Doku_Handler_Block { && !in_array($calls[$key+1][0], $this->blockClose) ) { - + $this->calls[] = array('p_open',array(), $call[2]); $this->inParagraph = TRUE; } } - + if ( $storeCall ) { $this->calls[] = $call; } - + } - - + + } else { - + // Unless there's already a block at the start, start a paragraph if ( !in_array($cname,$this->blockOpen) ) { $this->calls[] = array('p_open',array(), $call[2]); @@ -1458,11 +1458,11 @@ class Doku_Handler_Block { $this->calls[] = $call; $this->atStart = FALSE; } - + } - + } - + if ( $this->inParagraph ) { if ( $cname == 'p_open' ) { // Ditch the last call @@ -1477,16 +1477,16 @@ class Doku_Handler_Block { $this->calls[] = $last_call; } } - + return $this->calls; } - + function addToStack($newStart = TRUE) { $this->blockStack[] = array($this->atStart, $this->inParagraph); $this->atStart = $newStart; $this->inParagraph = FALSE; } - + function removeFromStack() { $state = array_pop($this->blockStack); $this->atStart = $state[0]; @@ -1504,30 +1504,30 @@ define('DOKU_TOCBRANCH_CLOSE',6); define('DOKU_TOC_CLOSE',7); class Doku_Handler_Toc { - + var $calls = array(); var $tocStack = array(); var $toc = array(); var $numHeaders = 0; - + function process($calls) { #FIXME can this be done better? - + global $conf; - + if ( isset($conf['toptoclevel']) ) { // retrieve vars once to save time $toplevel = $conf['toptoclevel']; } else { $toplevel = 0; } - + if ( isset($conf['maxtoclevel']) ) { $maxlevel = $conf['maxtoclevel']; } else { $maxlevel = 0; } - + foreach ( $calls as $call ) { if ( !isset($call[1][1]) ) { $this->calls[] = $call; @@ -1540,42 +1540,42 @@ class Doku_Handler_Toc { } $this->calls[] = $call; } - + // Complete the table of contents then prepend to the calls $this->finalizeToc($call); return $this->calls; } - + function addToToc($depth, $call) { - + // If it's the opening item... if ( count ( $this->toc) == 0 ) { - + $this->addTocCall($call, DOKU_TOC_OPEN); - + for ( $i = 1; $i <= $depth; $i++ ) { - + $this->addTocCall(array($call[0],array($call[1][0],$i),$call[2]), DOKU_TOCBRANCH_OPEN); - + if ( $i != $depth ) { $this->addTocCall(array($call[0],array($call[1][0], $i, '', TRUE),$call[2]), DOKU_TOCITEM_OPEN); } else { $this->addTocCall(array($call[0],array($call[1][0], $i),$call[2]), DOKU_TOCITEM_OPEN); $this->addTocCall(array($call[0],array($call[1][0], $i),$call[2]), DOKU_TOC_ELEMENT); } - + $this->tocStack[] = $i; - + } return; } - + $currentDepth = end($this->tocStack); $initialDepth = $currentDepth; - + // Create new branches as needed if ( $depth > $currentDepth ) { - + for ($i = $currentDepth+1; $i <= $depth; $i++ ) { $this->addTocCall(array($call[0],array($call[1][0],$i),$call[2]), DOKU_TOCBRANCH_OPEN); // It's just a filler @@ -1586,11 +1586,11 @@ class Doku_Handler_Toc { } $this->tocStack[] = $i; } - + $currentDepth = $i-1; - + } - + // Going down if ( $depth < $currentDepth ) { for ( $i = $currentDepth; $i >= $depth; $i-- ) { @@ -1606,27 +1606,27 @@ class Doku_Handler_Toc { } } } - + if ( $depth == $initialDepth ) { $this->addTocCall($call, DOKU_TOCITEM_CLOSE); $this->addTocCall($call, DOKU_TOCITEM_OPEN); } - + $this->addTocCall($call, DOKU_TOC_ELEMENT); - - + + } - + function addTocCall($call, $type) { switch ( $type ) { case DOKU_TOC_OPEN: $this->toc[] = array('toc_open',array(),$call[2]); break; - + case DOKU_TOCBRANCH_OPEN: $this->toc[] = array('tocbranch_open',array($call[1][1]),$call[2]); break; - + case DOKU_TOCITEM_OPEN: if ( isset( $call[1][3] ) ) { $this->toc[] = array('tocitem_open',array($call[1][1], TRUE),$call[2]); @@ -1634,19 +1634,19 @@ class Doku_Handler_Toc { $this->toc[] = array('tocitem_open',array($call[1][1]),$call[2]); } break; - + case DOKU_TOC_ELEMENT: $this->toc[] = array('tocelement',array($call[1][1],$call[1][0]),$call[2]); break; - + case DOKU_TOCITEM_CLOSE: $this->toc[] = array('tocitem_close',array($call[1][1]),$call[2]); break; - + case DOKU_TOCBRANCH_CLOSE: $this->toc[] = array('tocbranch_close',array($call[1][1]),$call[2]); break; - + case DOKU_TOC_CLOSE: if ( count($this->toc) > 0 ) { $this->toc[] = array('toc_close',array(),$call[2]); @@ -1654,7 +1654,7 @@ class Doku_Handler_Toc { break; } } - + function finalizeToc($call) { global $conf; if ( isset($conf['maxtoclevel']) && $this->numHeaders < $conf['maxtoclevel'] ) { @@ -1669,7 +1669,7 @@ class Doku_Handler_Toc { $this->addTocCall($call, DOKU_TOC_CLOSE); $this->calls = array_merge($this->toc, $this->calls); } - + } diff --git a/inc/parser/lexer.php b/inc/parser/lexer.php index e096fd045..e764fa236 100644 --- a/inc/parser/lexer.php +++ b/inc/parser/lexer.php @@ -37,7 +37,7 @@ class Doku_LexerParallelRegex { var $_labels; var $_regex; var $_case; - + /** * Constructor. Starts with no patterns. * @param boolean $case True for case sensitive, false @@ -50,7 +50,7 @@ class Doku_LexerParallelRegex { $this->_labels = array(); $this->_regex = null; } - + /** * Adds a pattern with an optional label. * @param mixed $pattern Perl style regex. Must be UTF-8 @@ -68,7 +68,7 @@ class Doku_LexerParallelRegex { $this->_labels[$count] = $label; $this->_regex = null; } - + /** * Attempts to match all patterns at once against * a string. @@ -86,7 +86,7 @@ class Doku_LexerParallelRegex { $match = ""; return false; } - + $match = $matches[0]; $size = count($matches); for ($i = 1; $i < $size; $i++) { @@ -96,7 +96,7 @@ class Doku_LexerParallelRegex { } return true; } - + /** * Attempts to split the string against all patterns at once * @@ -111,20 +111,20 @@ class Doku_LexerParallelRegex { if (count($this->_patterns) == 0) { return false; } - + if (! preg_match($this->_getCompoundedRegex(), $subject, $matches)) { $split = array($subject, "", ""); return false; } - + $idx = count($matches)-2; list($pre, $post) = preg_split($this->_patterns[$idx].$this->_getPerlMatchingFlags(), $subject, 2); - + $split = array($pre, $matches[0], $post); return isset($this->_labels[$idx]) ? $this->_labels[$idx] : true; } - + /** * Compounds the patterns into a single * regular expression separated with the @@ -137,7 +137,7 @@ class Doku_LexerParallelRegex { if ($this->_regex == null) { $cnt = count($this->_patterns); for ($i = 0; $i < $cnt; $i++) { - + // Replace lookaheads / lookbehinds with marker $m = "\1\1"; $pattern = preg_replace( @@ -167,7 +167,7 @@ class Doku_LexerParallelRegex { array('\/', '\(', '\)'), $pattern ); - + // Restore lookaheads / lookbehinds $pattern = preg_replace( array ( @@ -190,14 +190,14 @@ class Doku_LexerParallelRegex { ), $pattern ); - + $this->_patterns[$i] = '('.$pattern.')'; } $this->_regex = "/" . implode("|", $this->_patterns) . "/" . $this->_getPerlMatchingFlags(); } return $this->_regex; } - + /** * Accessor for perl regex mode flags to use. * @return string Perl regex flags. @@ -215,7 +215,7 @@ class Doku_LexerParallelRegex { */ class Doku_LexerStateStack { var $_stack; - + /** * Constructor. Starts in named state. * @param string $start Starting state name. @@ -224,7 +224,7 @@ class Doku_LexerStateStack { function Doku_LexerStateStack($start) { $this->_stack = array($start); } - + /** * Accessor for current state. * @return string State. @@ -233,7 +233,7 @@ class Doku_LexerStateStack { function getCurrent() { return $this->_stack[count($this->_stack) - 1]; } - + /** * Adds a state to the stack and sets it * to be the current state. @@ -243,7 +243,7 @@ class Doku_LexerStateStack { function enter($state) { array_push($this->_stack, $state); } - + /** * Leaves the current state and reverts * to the previous one. @@ -275,7 +275,7 @@ class Doku_Lexer { var $_mode; var $_mode_handlers; var $_case; - + /** * Sets up the lexer in case insensitive matching * by default. @@ -292,7 +292,7 @@ class Doku_Lexer { $this->_mode = &new Doku_LexerStateStack($start); $this->_mode_handlers = array(); } - + /** * Adds a token search pattern for a particular * parsing mode. The pattern does not change the @@ -310,7 +310,7 @@ class Doku_Lexer { } $this->_regexes[$mode]->addPattern($pattern); } - + /** * Adds a pattern that will enter a new parsing * mode. Useful for entering parenthesis, strings, @@ -330,7 +330,7 @@ class Doku_Lexer { } $this->_regexes[$mode]->addPattern($pattern, $new_mode); } - + /** * Adds a pattern that will exit the current mode * and re-enter the previous one. @@ -345,7 +345,7 @@ class Doku_Lexer { } $this->_regexes[$mode]->addPattern($pattern, "__exit"); } - + /** * Adds a pattern that has a special mode. Acts as an entry * and exit pattern in one go, effectively calling a special @@ -364,7 +364,7 @@ class Doku_Lexer { } $this->_regexes[$mode]->addPattern($pattern, "_$special"); } - + /** * Adds a mapping from a mode to another handler. * @param string $mode Mode to be remapped. @@ -374,7 +374,7 @@ class Doku_Lexer { function mapHandler($mode, $handler) { $this->_mode_handlers[$mode] = $handler; } - + /** * Splits the page text into tokens. Will fail * if the handlers report an error or if no @@ -410,7 +410,7 @@ class Doku_Lexer { } return $this->_invokeParser($raw, DOKU_LEXER_UNMATCHED, $pos); } - + /** * Sends the matched token and any leading unmatched * text to the parser changing the lexer to a new @@ -448,7 +448,7 @@ class Doku_Lexer { } return $this->_invokeParser($matched, DOKU_LEXER_MATCHED, $matchPos); } - + /** * Tests to see if the new mode is actually to leave * the current mode and pop an item from the matching @@ -460,7 +460,7 @@ class Doku_Lexer { function _isModeEnd($mode) { return ($mode === "__exit"); } - + /** * Test to see if the mode is one where this mode * is entered for this token only and automatically @@ -472,7 +472,7 @@ class Doku_Lexer { function _isSpecialMode($mode) { return (strncmp($mode, "_", 1) == 0); } - + /** * Strips the magic underscore marking single token * modes. @@ -483,7 +483,7 @@ class Doku_Lexer { function _decodeSpecial($mode) { return substr($mode, 1); } - + /** * Calls the parser method named after the current * mode. Empty content will be ignored. The lexer @@ -512,7 +512,7 @@ class Doku_Lexer { return $this->_parser->$handler($content, $is_match, $pos); } - + /** * Tries to match a chunk of text and if successful * removes the recognised chunk and any leading @@ -567,7 +567,7 @@ function Doku_Lexer_Escape($str) { '/\|/', '/\:/' ); - + $escaped = array( '\.', '\\\\\\\\', diff --git a/inc/parser/parser.php b/inc/parser/parser.php index 7a3342fbf..d5e8f4552 100644 --- a/inc/parser/parser.php +++ b/inc/parser/parser.php @@ -32,10 +32,10 @@ $PARSER_MODES = array( 'windowssharelink','filelink','notoc', 'nocache','multiplyentity','quotes','rss'), - // modes which have a start and end token but inside which + // modes which have a start and end token but inside which // no other modes should be applied 'protected' => array('preformatted','code','file','php','html'), - + // inside this mode no wiki markup should be applied but lineendings // and whitespace isn't preserved 'disabled' => array('unformatted'), @@ -51,15 +51,15 @@ $PARSER_MODES = array( * For an intro to the Lexer see: wiki:parser */ class Doku_Parser { - + var $Handler; - + var $Lexer; - + var $modes = array(); - + var $connected = FALSE; - + function addBaseMode(& $BaseMode) { $this->modes['base'] = & $BaseMode; if ( !$this->Lexer ) { @@ -67,7 +67,7 @@ class Doku_Parser { } $this->modes['base']->Lexer = & $this->Lexer; } - + /** * PHP preserves order of associative elements * Mode sequence is important @@ -79,36 +79,36 @@ class Doku_Parser { $Mode->Lexer = & $this->Lexer; $this->modes[$name] = & $Mode; } - + function connectModes() { - + if ( $this->connected ) { return; } - + foreach ( array_keys($this->modes) as $mode ) { - + // Base isn't connected to anything if ( $mode == 'base' ) { continue; } - + $this->modes[$mode]->preConnect(); - + foreach ( array_keys($this->modes) as $cm ) { - + if ( $this->modes[$cm]->accepts($mode) ) { $this->modes[$mode]->connectTo($cm); } - + } - + $this->modes[$mode]->postConnect(); } - + $this->connected = TRUE; } - + function parse($doc) { if ( $this->Lexer ) { $this->connectModes(); @@ -121,7 +121,7 @@ class Doku_Parser { return FALSE; } } - + } //------------------------------------------------------------------- @@ -136,9 +136,9 @@ class Doku_Parser { * @author Harry Fuecks <hfuecks@gmail.com> */ class Doku_Parser_Mode { - + var $Lexer; - + var $allowedModes = array(); // returns a number used to determine in which order modes are added @@ -149,24 +149,24 @@ class Doku_Parser_Mode { // Called before any calls to connectTo function preConnect() {} - // Connects the mode + // Connects the mode function connectTo($mode) {} // Called after all calls to connectTo function postConnect() {} - + function accepts($mode) { return in_array($mode, $this->allowedModes ); } - + } //------------------------------------------------------------------- class Doku_Parser_Mode_base extends Doku_Parser_Mode { - + function Doku_Parser_Mode_base() { global $PARSER_MODES; - + $this->allowedModes = array_merge ( $PARSER_MODES['container'], $PARSER_MODES['baseonly'], @@ -185,10 +185,10 @@ class Doku_Parser_Mode_base extends Doku_Parser_Mode { //------------------------------------------------------------------- class Doku_Parser_Mode_footnote extends Doku_Parser_Mode { - + function Doku_Parser_Mode_footnote() { global $PARSER_MODES; - + $this->allowedModes = array_merge ( $PARSER_MODES['container'], $PARSER_MODES['formatting'], @@ -196,20 +196,20 @@ class Doku_Parser_Mode_footnote extends Doku_Parser_Mode { $PARSER_MODES['protected'], $PARSER_MODES['disabled'] ); - + } - + function connectTo($mode) { $this->Lexer->addEntryPattern( '\x28\x28(?=.*\x29\x29)',$mode,'footnote' ); } - + function postConnect() { $this->Lexer->addExitPattern( '\x29\x29','footnote' ); - + } function getSort() { @@ -219,17 +219,17 @@ class Doku_Parser_Mode_footnote extends Doku_Parser_Mode { //------------------------------------------------------------------- class Doku_Parser_Mode_header extends Doku_Parser_Mode { - + function preConnect() { //we're not picky about the closing ones, two are enough - + // Header 1 is special case - match 6 or more $this->Lexer->addSpecialPattern( '[ \t]*={6,}[^\n]+={2,}[ \t]*(?=\n)', 'base', 'header' ); - + // For the rest, match exactly for ( $i = 5; $i > 1; $i--) { $this->Lexer->addSpecialPattern( @@ -239,7 +239,7 @@ class Doku_Parser_Mode_header extends Doku_Parser_Mode { ); } } - + function getSort() { return 50; } @@ -247,11 +247,11 @@ class Doku_Parser_Mode_header extends Doku_Parser_Mode { //------------------------------------------------------------------- class Doku_Parser_Mode_notoc extends Doku_Parser_Mode { - + function connectTo($mode) { $this->Lexer->addSpecialPattern('~~NOTOC~~',$mode,'notoc'); } - + function getSort() { return 30; } @@ -259,19 +259,19 @@ class Doku_Parser_Mode_notoc extends Doku_Parser_Mode { //------------------------------------------------------------------- class Doku_Parser_Mode_nocache extends Doku_Parser_Mode { - + function connectTo($mode) { $this->Lexer->addSpecialPattern('~~NOCACHE~~',$mode,'nocache'); - } - + } + function getSort() { return 40; } -} - +} + //------------------------------------------------------------------- class Doku_Parser_Mode_linebreak extends Doku_Parser_Mode { - + function connectTo($mode) { $this->Lexer->addSpecialPattern('\x5C{2}(?=\s)',$mode,'linebreak'); } @@ -283,7 +283,7 @@ class Doku_Parser_Mode_linebreak extends Doku_Parser_Mode { //------------------------------------------------------------------- class Doku_Parser_Mode_eol extends Doku_Parser_Mode { - + function connectTo($mode) { $badModes = array('listblock','table'); if ( in_array($mode, $badModes) ) { @@ -306,64 +306,64 @@ class Doku_Parser_Mode_hr extends Doku_Parser_Mode { function getSort() { return 160; - } + } } //------------------------------------------------------------------- class Doku_Parser_Mode_formatting extends Doku_Parser_Mode { var $type; - + var $formatting = array ( 'strong' => array ( 'entry'=>'\*\*(?=.*\*\*)', 'exit'=>'\*\*', 'sort'=>70 ), - + 'emphasis'=> array ( - 'entry'=>'//(?=[^\x00]*[^:]//)', //hack for bug #384 + 'entry'=>'//(?=[^\x00]*[^:]//)', //hack for bug #384 'exit'=>'//', 'sort'=>80 ), - + 'underline'=> array ( 'entry'=>'__(?=.*__)', 'exit'=>'__', 'sort'=>90 ), - + 'monospace'=> array ( 'entry'=>'\x27\x27(?=.*\x27\x27)', 'exit'=>'\x27\x27', 'sort'=>100 ), - + 'subscript'=> array ( 'entry'=>'<sub>(?=.*\x3C/sub\x3E)', 'exit'=>'</sub>', 'sort'=>110 ), - + 'superscript'=> array ( 'entry'=>'<sup>(?=.*\x3C/sup\x3E)', 'exit'=>'</sup>', 'sort'=>120 ), - + 'deleted'=> array ( 'entry'=>'<del>(?=.*\x3C/del\x3E)', 'exit'=>'</del>', 'sort'=>130 ), ); - + function Doku_Parser_Mode_formatting($type) { global $PARSER_MODES; - + if ( !array_key_exists($type, $this->formatting) ) { trigger_error('Invalid formatting type '.$type, E_USER_WARNING); } - + $this->type = $type; // formatting may contain other formatting but not it self @@ -379,28 +379,28 @@ class Doku_Parser_Mode_formatting extends Doku_Parser_Mode { $PARSER_MODES['disabled'] ); } - + function connectTo($mode) { - + // Can't nest formatting in itself if ( $mode == $this->type ) { return; } - + $this->Lexer->addEntryPattern( $this->formatting[$this->type]['entry'], $mode, $this->type ); } - + function postConnect() { - + $this->Lexer->addExitPattern( $this->formatting[$this->type]['exit'], $this->type ); - + } function getSort() { @@ -413,7 +413,7 @@ class Doku_Parser_Mode_listblock extends Doku_Parser_Mode { function Doku_Parser_Mode_listblock() { global $PARSER_MODES; - + $this->allowedModes = array_merge ( $PARSER_MODES['formatting'], $PARSER_MODES['substition'], @@ -423,16 +423,16 @@ class Doku_Parser_Mode_listblock extends Doku_Parser_Mode { // $this->allowedModes[] = 'footnote'; } - + function connectTo($mode) { $this->Lexer->addEntryPattern('\n {2,}[\-\*]',$mode,'listblock'); $this->Lexer->addEntryPattern('\n\t{1,}[\-\*]',$mode,'listblock'); - + $this->Lexer->addPattern('\n {2,}[\-\*]','listblock'); $this->Lexer->addPattern('\n\t{1,}[\-\*]','listblock'); - + } - + function postConnect() { $this->Lexer->addExitPattern('\n','listblock'); } @@ -444,10 +444,10 @@ class Doku_Parser_Mode_listblock extends Doku_Parser_Mode { //------------------------------------------------------------------- class Doku_Parser_Mode_table extends Doku_Parser_Mode { - + function Doku_Parser_Mode_table() { global $PARSER_MODES; - + $this->allowedModes = array_merge ( $PARSER_MODES['formatting'], $PARSER_MODES['substition'], @@ -455,12 +455,12 @@ class Doku_Parser_Mode_table extends Doku_Parser_Mode { $PARSER_MODES['protected'] ); } - + function connectTo($mode) { $this->Lexer->addEntryPattern('\n\^',$mode,'table'); $this->Lexer->addEntryPattern('\n\|',$mode,'table'); } - + function postConnect() { $this->Lexer->addPattern('\n\^','table'); $this->Lexer->addPattern('\n\|','table'); @@ -478,12 +478,12 @@ class Doku_Parser_Mode_table extends Doku_Parser_Mode { //------------------------------------------------------------------- class Doku_Parser_Mode_unformatted extends Doku_Parser_Mode { - + function connectTo($mode) { $this->Lexer->addEntryPattern('<nowiki>(?=.*\x3C/nowiki\x3E)',$mode,'unformatted'); $this->Lexer->addEntryPattern('%%(?=.*%%)',$mode,'unformattedalt'); } - + function postConnect() { $this->Lexer->addExitPattern('</nowiki>','unformatted'); $this->Lexer->addExitPattern('%%','unformattedalt'); @@ -497,11 +497,11 @@ class Doku_Parser_Mode_unformatted extends Doku_Parser_Mode { //------------------------------------------------------------------- class Doku_Parser_Mode_php extends Doku_Parser_Mode { - + function connectTo($mode) { $this->Lexer->addEntryPattern('<php>(?=.*\x3C/php\x3E)',$mode,'php'); } - + function postConnect() { $this->Lexer->addExitPattern('</php>','php'); } @@ -513,11 +513,11 @@ class Doku_Parser_Mode_php extends Doku_Parser_Mode { //------------------------------------------------------------------- class Doku_Parser_Mode_html extends Doku_Parser_Mode { - + function connectTo($mode) { $this->Lexer->addEntryPattern('<html>(?=.*\x3C/html\x3E)',$mode,'html'); } - + function postConnect() { $this->Lexer->addExitPattern('</html>','html'); } @@ -529,38 +529,38 @@ class Doku_Parser_Mode_html extends Doku_Parser_Mode { //------------------------------------------------------------------- class Doku_Parser_Mode_preformatted extends Doku_Parser_Mode { - + function connectTo($mode) { // Has hard coded awareness of lists... $this->Lexer->addEntryPattern('\n (?![\*\-])',$mode,'preformatted'); $this->Lexer->addEntryPattern('\n\t(?![\*\-])',$mode,'preformatted'); - + // How to effect a sub pattern with the Lexer! $this->Lexer->addPattern('\n ','preformatted'); $this->Lexer->addPattern('\n\t','preformatted'); } - + function postConnect() { $this->Lexer->addExitPattern('\n','preformatted'); } function getSort() { return 20; - } + } } //------------------------------------------------------------------- class Doku_Parser_Mode_code extends Doku_Parser_Mode { - + function connectTo($mode) { $this->Lexer->addEntryPattern('<code(?=.*\x3C/code\x3E)',$mode,'code'); } - + function postConnect() { $this->Lexer->addExitPattern('</code>','code'); } - + function getSort() { return 200; } @@ -568,15 +568,15 @@ class Doku_Parser_Mode_code extends Doku_Parser_Mode { //------------------------------------------------------------------- class Doku_Parser_Mode_file extends Doku_Parser_Mode { - + function connectTo($mode) { $this->Lexer->addEntryPattern('<file>(?=.*\x3C/file\x3E)',$mode,'file'); } - + function postConnect() { $this->Lexer->addExitPattern('</file>','file'); } - + function getSort() { return 210; } @@ -584,10 +584,10 @@ class Doku_Parser_Mode_file extends Doku_Parser_Mode { //------------------------------------------------------------------- class Doku_Parser_Mode_quote extends Doku_Parser_Mode { - + function Doku_Parser_Mode_quote() { global $PARSER_MODES; - + $this->allowedModes = array_merge ( $PARSER_MODES['formatting'], $PARSER_MODES['substition'], @@ -598,16 +598,16 @@ class Doku_Parser_Mode_quote extends Doku_Parser_Mode { #$this->allowedModes[] = 'preformatted'; #$this->allowedModes[] = 'unformatted'; } - + function connectTo($mode) { $this->Lexer->addEntryPattern('\n>{1,}',$mode,'quote'); } - + function postConnect() { $this->Lexer->addPattern('\n>{1,}','quote'); $this->Lexer->addExitPattern('\n','quote'); } - + function getSort() { return 220; } @@ -618,23 +618,23 @@ class Doku_Parser_Mode_acronym extends Doku_Parser_Mode { // A list var $acronyms = array(); var $pattern = ''; - + function Doku_Parser_Mode_acronym($acronyms) { $this->acronyms = $acronyms; } - + function preConnect() { $bound = '[\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]'; $acronyms = array_map('Doku_Lexer_Escape',$this->acronyms); $this->pattern = '(?<=^|'.$bound.')(?:'.join('|',$acronyms).')(?='.$bound.')'; } - + function connectTo($mode) { if ( strlen($this->pattern) > 0 ) { - $this->Lexer->addSpecialPattern($this->pattern,$mode,'acronym'); + $this->Lexer->addSpecialPattern($this->pattern,$mode,'acronym'); } } - + function getSort() { return 240; } @@ -645,11 +645,11 @@ class Doku_Parser_Mode_smiley extends Doku_Parser_Mode { // A list var $smileys = array(); var $pattern = ''; - + function Doku_Parser_Mode_smiley($smileys) { $this->smileys = $smileys; } - + function preConnect() { $sep = ''; foreach ( $this->smileys as $smiley ) { @@ -657,13 +657,13 @@ class Doku_Parser_Mode_smiley extends Doku_Parser_Mode { $sep = '|'; } } - + function connectTo($mode) { if ( strlen($this->pattern) > 0 ) { - $this->Lexer->addSpecialPattern($this->pattern,$mode,'smiley'); + $this->Lexer->addSpecialPattern($this->pattern,$mode,'smiley'); } } - + function getSort() { return 230; } @@ -674,31 +674,31 @@ class Doku_Parser_Mode_wordblock extends Doku_Parser_Mode { // A list var $badwords = array(); var $pattern = ''; - + function Doku_Parser_Mode_wordblock($badwords) { $this->badwords = $badwords; } - + function preConnect() { - + if ( count($this->badwords) == 0 ) { return; } - + $sep = ''; foreach ( $this->badwords as $badword ) { $this->pattern .= $sep.'(?<=\b)(?i)'.Doku_Lexer_Escape($badword).'(?-i)(?=\b)'; $sep = '|'; } - + } - + function connectTo($mode) { if ( strlen($this->pattern) > 0 ) { $this->Lexer->addSpecialPattern($this->pattern,$mode,'wordblock'); } } - + function getSort() { return 250; } @@ -712,11 +712,11 @@ class Doku_Parser_Mode_entity extends Doku_Parser_Mode { // A list var $entities = array(); var $pattern = ''; - + function Doku_Parser_Mode_entity($entities) { $this->entities = $entities; } - + function preConnect() { $sep = ''; foreach ( $this->entities as $entity ) { @@ -724,13 +724,13 @@ class Doku_Parser_Mode_entity extends Doku_Parser_Mode { $sep = '|'; } } - + function connectTo($mode) { if ( strlen($this->pattern) > 0 ) { $this->Lexer->addSpecialPattern($this->pattern,$mode,'entity'); } } - + function getSort() { return 260; } @@ -739,15 +739,15 @@ class Doku_Parser_Mode_entity extends Doku_Parser_Mode { //------------------------------------------------------------------- // Implements the 640x480 replacement class Doku_Parser_Mode_multiplyentity extends Doku_Parser_Mode { - + function connectTo($mode) { - + $this->Lexer->addSpecialPattern( '(?<=\b)\d+[xX]\d+(?=\b)',$mode,'multiplyentity' ); } - + function getSort() { return 270; } @@ -755,9 +755,9 @@ class Doku_Parser_Mode_multiplyentity extends Doku_Parser_Mode { //------------------------------------------------------------------- class Doku_Parser_Mode_quotes extends Doku_Parser_Mode { - + function connectTo($mode) { - + $this->Lexer->addSpecialPattern( '(?<=^|\s)\'(?=\S)',$mode,'singlequoteopening' ); @@ -772,7 +772,7 @@ class Doku_Parser_Mode_quotes extends Doku_Parser_Mode { ); } - + function getSort() { return 280; } @@ -780,13 +780,13 @@ class Doku_Parser_Mode_quotes extends Doku_Parser_Mode { //------------------------------------------------------------------- class Doku_Parser_Mode_camelcaselink extends Doku_Parser_Mode { - + function connectTo($mode) { $this->Lexer->addSpecialPattern( '\b[A-Z]+[a-z]+[A-Z][A-Za-z]*\b',$mode,'camelcaselink' ); } - + function getSort() { return 290; } @@ -794,12 +794,12 @@ class Doku_Parser_Mode_camelcaselink extends Doku_Parser_Mode { //------------------------------------------------------------------- class Doku_Parser_Mode_internallink extends Doku_Parser_Mode { - + function connectTo($mode) { // Word boundaries? $this->Lexer->addSpecialPattern("\[\[.+?\]\]",$mode,'internallink'); } - + function getSort() { return 300; } @@ -807,12 +807,12 @@ class Doku_Parser_Mode_internallink extends Doku_Parser_Mode { //------------------------------------------------------------------- class Doku_Parser_Mode_media extends Doku_Parser_Mode { - + function connectTo($mode) { // Word boundaries? $this->Lexer->addSpecialPattern("\{\{[^\}]+\}\}",$mode,'media'); } - + function getSort() { return 320; } @@ -831,33 +831,33 @@ class Doku_Parser_Mode_rss extends Doku_Parser_Mode { } //------------------------------------------------------------------- -class Doku_Parser_Mode_externallink extends Doku_Parser_Mode { +class Doku_Parser_Mode_externallink extends Doku_Parser_Mode { var $schemes = array('http','https','telnet','gopher','wais','ftp','ed2k','irc'); var $patterns = array(); - + function preConnect() { - + $ltrs = '\w'; $gunk = '/\#~:.?+=&%@!\-'; $punc = '.:?\-;,'; $host = $ltrs.$punc; $any = $ltrs.$gunk.$punc; - + foreach ( $this->schemes as $scheme ) { $this->patterns[] = '\b(?i)'.$scheme.'(?-i)://['.$any.']+?(?=['.$punc.']*[^'.$any.'])'; } - + $this->patterns[] = '\b(?i)www?(?-i)\.['.$host.']+?\.['.$host.']+?['.$any.']+?(?=['.$punc.']*[^'.$any.'])'; $this->patterns[] = '\b(?i)ftp?(?-i)\.['.$host.']+?\.['.$host.']+?['.$any.']+?(?=['.$punc.']*[^'.$any.'])'; - + } - + function connectTo($mode) { foreach ( $this->patterns as $pattern ) { $this->Lexer->addSpecialPattern($pattern,$mode,'externallink'); } } - + function getSort() { return 330; } @@ -865,21 +865,21 @@ class Doku_Parser_Mode_externallink extends Doku_Parser_Mode { //------------------------------------------------------------------- class Doku_Parser_Mode_filelink extends Doku_Parser_Mode { - + var $pattern; - + function preConnect() { - + $ltrs = '\w'; $gunk = '/\#~:.?+=&%@!\-'; $punc = '.:?\-;,'; $host = $ltrs.$punc; $any = $ltrs.$gunk.$punc; - + $this->pattern = '\b(?i)file(?-i)://['.$any.']+?['. $punc.']*[^'.$any.']'; } - + function connectTo($mode) { $this->Lexer->addSpecialPattern( $this->pattern,$mode,'filelink'); @@ -892,18 +892,18 @@ class Doku_Parser_Mode_filelink extends Doku_Parser_Mode { //------------------------------------------------------------------- class Doku_Parser_Mode_windowssharelink extends Doku_Parser_Mode { - + var $pattern; - + function preConnect() { $this->pattern = "\\\\\\\\\w+?(?:\\\\[\w$]+)+"; } - + function connectTo($mode) { $this->Lexer->addSpecialPattern( $this->pattern,$mode,'windowssharelink'); } - + function getSort() { return 350; } @@ -911,11 +911,11 @@ class Doku_Parser_Mode_windowssharelink extends Doku_Parser_Mode { //------------------------------------------------------------------- class Doku_Parser_Mode_emaillink extends Doku_Parser_Mode { - + function connectTo($mode) { $this->Lexer->addSpecialPattern("<[\w0-9\-_.]+?@[\w\-]+\.[\w\-\.]+\.*[\w]+>",$mode,'emaillink'); } - + function getSort() { return 340; } diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index 7ac1c9d7b..a9c86c3f5 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -19,157 +19,157 @@ class Doku_Renderer { function nocache() { $this->info['cache'] = FALSE; } - + //handle plugin rendering function plugin($name,$data){ - $plugin =& plugin_load('syntax',$name); + $plugin =& plugin_load('syntax',$name); if($plugin != null){ - // determine mode from renderer class name - format = "Doku_Renderer_<mode>" - $mode = substr(get_class($this), 14); + // determine mode from renderer class name - format = "Doku_Renderer_<mode>" + $mode = substr(get_class($this), 14); $plugin->render($mode,$this,$data); } } - + function document_start() {} - + function document_end() {} - + function toc_open() {} - + function tocbranch_open($level) {} - + function tocitem_open($level, $empty = FALSE) {} - + function tocelement($level, $title) {} - + function tocitem_close($level) {} - + function tocbranch_close($level) {} - + function toc_close() {} - + function header($text, $level, $pos) {} - + function section_open($level) {} - + function section_close() {} - + function cdata($text) {} - + function p_open() {} - + function p_close() {} - + function linebreak() {} - + function hr() {} - + function strong_open() {} - + function strong_close() {} - + function emphasis_open() {} - + function emphasis_close() {} - + function underline_open() {} - + function underline_close() {} - + function monospace_open() {} - + function monospace_close() {} - + function subscript_open() {} - + function subscript_close() {} - + function superscript_open() {} - + function superscript_close() {} - + function deleted_open() {} - + function deleted_close() {} - + function footnote_open() {} - + function footnote_close() {} - + function listu_open() {} - + function listu_close() {} - + function listo_open() {} - + function listo_close() {} - + function listitem_open($level) {} - + function listitem_close() {} - + function listcontent_open() {} - + function listcontent_close() {} - + function unformatted($text) {} - + function php($text) {} - + function html($text) {} - + function preformatted($text) {} - + function file($text) {} - + function quote_open() {} - + function quote_close() {} - + function code($text, $lang = NULL) {} - + function acronym($acronym) {} - + function smiley($smiley) {} - + function wordblock($word) {} - + function entity($entity) {} - + // 640x480 ($x=640, $y=480) function multiplyentity($x, $y) {} - + function singlequoteopening() {} - + function singlequoteclosing() {} - + function doublequoteopening() {} - + function doublequoteclosing() {} - + // $link like 'SomePage' function camelcaselink($link) {} - + // $link like 'wiki:syntax', $title could be an array (media) function internallink($link, $title = NULL) {} - + // $link is full URL with scheme, $title could be an array (media) function externallink($link, $title = NULL) {} - + // $link is the original link - probably not much use // $wikiName is an indentifier for the wiki // $wikiUri is the URL fragment to append to some known URL function interwikilink($link, $title = NULL, $wikiName, $wikiUri) {} - + // Link to file on users OS, $title could be an array (media) function filelink($link, $title = NULL) {} - + // Link to a Windows share, , $title could be an array (media) function windowssharelink($link, $title = NULL) {} - + // function email($address, $title = NULL) {} function emaillink($address, $name = NULL) {} - + function internalmedialink ( $src,$title=NULL,$align=NULL,$width=NULL,$height=NULL,$cache=NULL ) {} @@ -177,21 +177,21 @@ class Doku_Renderer { function externalmedialink( $src,$title=NULL,$align=NULL,$width=NULL,$height=NULL,$cache=NULL ) {} - + function table_open($maxcols = NULL, $numrows = NULL){} - + function table_close(){} - + function tablerow_open(){} - + function tablerow_close(){} - + function tableheader_open($colspan = 1, $align = NULL){} - + function tableheader_close(){} - + function tablecell_open($colspan = 1, $align = NULL){} - + function tablecell_close(){} } diff --git a/inc/parser/spamcheck.php b/inc/parser/spamcheck.php index b1f473d8c..42b9781c5 100644 --- a/inc/parser/spamcheck.php +++ b/inc/parser/spamcheck.php @@ -4,44 +4,44 @@ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../') require_once DOKU_INC . 'inc/parser/renderer.php'; class Doku_Renderer_SpamCheck extends Doku_Renderer { - + // This should be populated by the code executing the instructions var $currentCall; - + // An array of instructions that contain spam var $spamFound = array(); - + // pcre pattern for finding spam var $spamPattern = '#^$#'; - + function internallink($link, $title = NULL) { $this->_checkTitle($title); } - + function externallink($link, $title = NULL) { $this->_checkLinkForSpam($link); $this->_checkTitle($title); } - + function interwikilink($link, $title = NULL) { $this->_checkTitle($title); } - + function filelink($link, $title = NULL) { $this->_checkLinkForSpam($link); $this->_checkTitle($title); } - + function windowssharelink($link, $title = NULL) { $this->_checkLinkForSpam($link); $this->_checkTitle($title); } - + function email($address, $title = NULL) { $this->_checkLinkForSpam($address); $this->_checkTitle($title); } - + function internalmedialink ($src) { $this->_checkLinkForSpam($src); } @@ -55,7 +55,7 @@ class Doku_Renderer_SpamCheck extends Doku_Renderer { $this->_checkLinkForSpam($title['src']); } } - + // Pattern matching happens here /** * @TODO What about links like www.google.com - no http:// diff --git a/inc/parser/wiki.php b/inc/parser/wiki.php index 2b24d2539..b393d6ec0 100644 --- a/inc/parser/wiki.php +++ b/inc/parser/wiki.php @@ -6,23 +6,23 @@ * Main issues lie with lists, quote and tables */ class Doku_Renderer_Wiki extends Doku_Renderer { - + var $doc = ''; - + // This should be eliminated var $listMarker = '*'; - + function document_start() { ob_start(); } - + function document_end() { - + $this->doc .= ob_get_contents(); ob_end_clean(); } - + function header($text, $level) { $levels = array( 1=>'======', @@ -31,7 +31,7 @@ class Doku_Renderer_Wiki extends Doku_Renderer { 4=>'===', 5=>'==', ); - + if ( isset($levels[$level]) ) { $token = $levels[$level]; } else { @@ -41,189 +41,189 @@ class Doku_Renderer_Wiki extends Doku_Renderer { echo trim($text); echo " {$token}\n"; } - + function cdata($text) { echo $text; } - + function linebreak() { echo '\\\\ '; } - + function hr() { echo "\n----\n"; } - + function strong_open() { echo '**'; } - + function strong_close() { echo '**'; } - + function emphasis_open() { echo '//'; } - + function emphasis_close() { echo '//'; } - + function underline_open() { echo '__'; } - + function underline_close() { echo '__'; } - + function monospace_open() { echo "''"; } - + function monospace_close() { echo "''"; } - + function subscript_open() { echo '<sub>'; } - + function subscript_close() { echo '</sub>'; } - + function superscript_open() { echo '<sup>'; } - + function superscript_close() { echo '</sup>'; } - + function deleted_open() { echo '<del>'; } - + function deleted_close() { echo '</del>'; } - + function footnote_open() { echo '(('; } - + function footnote_close() { echo '))'; } - + function listu_open() { $this->listMarker = '*'; echo "\n"; } - + function listo_open() { $this->listMarker = '-'; echo "\n"; } - + /** * @TODO Problem here with nested lists */ function listitem_open($level) { echo str_repeat(' ', $level).$this->listMarker; } - + function listitem_close() { echo "\n"; } - + function unformatted($text) { echo '%%'.$text.'%%'; } - + function php($text) { echo "\n<php>\n$text\n</php>\n"; } - + function html($text) { echo "\n<html>\n$text\n</html>\n"; } - + /** * Indent? */ function preformatted($text) { echo "\n<code>\n$text\n</code>\n"; } - + function file($text) { echo "\n<file>\n$text\n</file>\n"; } - + /** * Problem here with nested quotes */ function quote_open() { echo '>'; } - + function quote_close() { echo "\n"; } - + function code($text, $lang = NULL) { if ( !$lang ) { echo "\n<code>\n$text\n</code>\n"; } else { echo "\n<code $lang>\n$text\n</code>\n"; } - + } - + function acronym($acronym) { echo $acronym; } - + function smiley($smiley) { echo $smiley; } - + function wordblock($word) { echo $word; } - + function entity($entity) { echo $entity; } - + // 640x480 ($x=640, $y=480) function multiplyentity($x, $y) { echo "{$x}x{$y}"; } - + function singlequoteopening() { echo "'"; } - + function singlequoteclosing() { echo "'"; } - + function doublequoteopening() { echo '"'; } - + function doublequoteclosing() { echo '"'; } - + // $link like 'SomePage' function camelcaselink($link) { echo $link; } - + // $link like 'wikie:syntax', $title could be an array (media) function internallink($link, $title = NULL) { if ( $title ) { @@ -232,7 +232,7 @@ class Doku_Renderer_Wiki extends Doku_Renderer { echo '[['.$link.']]'; } } - + // $link is full URL with scheme, $title could be an array (media) function externallink($link, $title = NULL) { if ( $title ) { @@ -241,7 +241,7 @@ class Doku_Renderer_Wiki extends Doku_Renderer { echo '[['.$link.']]'; } } - + // $link is the original link - probably not much use // $wikiName is an indentifier for the wiki // $wikiUri is the URL fragment to append to some known URL @@ -252,7 +252,7 @@ class Doku_Renderer_Wiki extends Doku_Renderer { echo '[['.$link.']]'; } } - + // Link to file on users OS, $title could be an array (media) function filelink($link, $title = NULL) { if ( $title ) { @@ -261,7 +261,7 @@ class Doku_Renderer_Wiki extends Doku_Renderer { echo '[['.$link.']]'; } } - + // Link to a Windows share, , $title could be an array (media) function windowssharelink($link, $title = NULL) { if ( $title ) { @@ -270,7 +270,7 @@ class Doku_Renderer_Wiki extends Doku_Renderer { echo '[['.$link.']]'; } } - + function email($address, $title = NULL) { if ( $title ) { echo '[['.$address.'|'.$title.']]'; @@ -278,14 +278,14 @@ class Doku_Renderer_Wiki extends Doku_Renderer { echo '[['.$address.']]'; } } - + // @TODO function internalmedialink ( $src,$title=NULL,$align=NULL,$width=NULL,$height=NULL,$cache=NULL ) { - + } - + // @TODO function externalmedialink( $src,$title=NULL,$align=NULL,$width=NULL,$height=NULL,$cache=NULL @@ -296,23 +296,23 @@ class Doku_Renderer_Wiki extends Doku_Renderer { echo '{{'.$src.'}}'; } } - + function table_open($maxcols = NULL, $numrows = NULL){} - + function table_close(){} - + function tablerow_open(){} - + function tablerow_close(){} - + function tableheader_open($colspan = 1, $align = NULL){} - + function tableheader_close(){} - + function tablecell_open($colspan = 1, $align = NULL){} - + function tablecell_close(){} - + } diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 5e898ab36..1c7343cda 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -21,16 +21,16 @@ if ( !defined('DOKU_TAB') ) { require_once DOKU_INC . 'inc/parser/renderer.php'; /** - * The Renderer + * The Renderer */ class Doku_Renderer_xhtml extends Doku_Renderer { var $doc = ''; - + var $headers = array(); - + var $footnotes = array(); - + var $acronyms = array(); var $smileys = array(); var $badwords = array(); @@ -43,18 +43,18 @@ class Doku_Renderer_xhtml extends Doku_Renderer { function document_start() { } - + function document_end() { // add button for last section if any and more than one if($this->lastsec > 1) $this->_secedit($this->lastsec,''); - + if ( count ($this->footnotes) > 0 ) { $this->doc .= '<div class="footnotes">'.DOKU_LF; $id = 0; foreach ( $this->footnotes as $footnote ) { $id++; // the number of the current footnote - + // check its not a placeholder that indicates actual footnote text is elsewhere if (substr($footnote, 0, 5) != "@@FNT") { @@ -62,18 +62,18 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $this->doc .= '<div class="fn">'; $this->doc .= '<a href="#fnt'.$id.'" id="fn'.$id.'" name="fn'.$id.'" class="fn_bot">'; $this->doc .= $id.')</a> '.DOKU_LF; - + // get any other footnotes that use the same markup $alt = array_keys($this->footnotes, "@@FNT$id"); - + if (count($alt)) { foreach ($alt as $ref) { // set anchor and backlink for the other footnotes $this->doc .= ', <a href="#fnt'.($ref+1).'" id="fn'.($ref+1).'" name="fn'.($ref+1).'" class="fn_bot">'; - $this->doc .= ($ref+1).')</a> '.DOKU_LF; + $this->doc .= ($ref+1).')</a> '.DOKU_LF; } } - + // add footnote markup and close this footnote $this->doc .= $footnote; $this->doc .= '</div>' . DOKU_LF; @@ -91,11 +91,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $this->doc .= '</div>'.DOKU_LF; $this->doc .= '<div id="toc__inside">'.DOKU_LF; } - + function tocbranch_open($level) { $this->doc .= '<ul class="toc">'.DOKU_LF; } - + function tocitem_open($level, $empty = FALSE) { if ( !$empty ) { $this->doc .= '<li class="level'.$level.'">'; @@ -103,28 +103,28 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $this->doc .= '<li class="clear">'; } } - + function tocelement($level, $title) { $this->doc .= '<span class="li"><a href="#'.$this->_headerToLink($title).'" class="toc">'; $this->doc .= $this->_xmlEntities($title); $this->doc .= '</a></span>'; } - + function tocitem_close($level) { $this->doc .= '</li>'.DOKU_LF; } - + function tocbranch_close($level) { $this->doc .= '</ul>'.DOKU_LF; } - + function toc_close() { $this->doc .= '</div>'.DOKU_LF.'</div>'.DOKU_LF; } - + function header($text, $level, $pos) { global $conf; - //handle section editing + //handle section editing if($level <= $conf['maxseclevel']){ // add button for last section if any if($this->lastsec) $this->_secedit($this->lastsec,$pos-1); @@ -136,91 +136,91 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $this->doc .= $this->_xmlEntities($text); $this->doc .= "</a></h$level>".DOKU_LF; } - + function section_open($level) { $this->doc .= "<div class=\"level$level\">".DOKU_LF; } - + function section_close() { $this->doc .= DOKU_LF.'</div>'.DOKU_LF; } - + function cdata($text) { $this->doc .= $this->_xmlEntities($text); } - + function p_open() { $this->doc .= DOKU_LF.'<p>'.DOKU_LF; } - + function p_close() { $this->doc .= DOKU_LF.'</p>'.DOKU_LF; } - + function linebreak() { $this->doc .= '<br/>'.DOKU_LF; } - + function hr() { $this->doc .= '<hr />'.DOKU_LF; } - + function strong_open() { $this->doc .= '<strong>'; } - + function strong_close() { $this->doc .= '</strong>'; } - + function emphasis_open() { $this->doc .= '<em>'; } - + function emphasis_close() { $this->doc .= '</em>'; } - + function underline_open() { $this->doc .= '<em class="u">'; } - + function underline_close() { $this->doc .= '</em>'; } - + function monospace_open() { $this->doc .= '<code>'; } - + function monospace_close() { $this->doc .= '</code>'; } - + function subscript_open() { $this->doc .= '<sub>'; } - + function subscript_close() { $this->doc .= '</sub>'; } - + function superscript_open() { $this->doc .= '<sup>'; } - + function superscript_close() { $this->doc .= '</sup>'; } - + function deleted_open() { $this->doc .= '<del>'; } - + function deleted_close() { $this->doc .= '</del>'; } - + /** * Callback for footnote start syntax * @@ -236,7 +236,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $this->store = $this->doc; $this->doc = ''; } - + /** * Callback for footnote end syntax * @@ -251,10 +251,10 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $footnote = $this->doc; $this->doc = $this->store; $this->store = ''; - + // check to see if this footnote has been seen before $i = array_search($footnote, $this->footnotes); - + if ($i === false) { // its a new footnote, add it to the $footnotes array $id = count($this->footnotes)+1; @@ -269,43 +269,43 @@ class Doku_Renderer_xhtml extends Doku_Renderer { // output the footnote reference and link, incl. onmouseover for insitu footnote popup $this->doc .= '<a href="#fn'.$id.'" name="fnt'.$id.'" id="fnt'.$id.'" class="fn_top" onmouseover="fnt(\''.$id.'\', this, event);">'.$id.')</a>'; } - + function listu_open() { $this->doc .= '<ul>'.DOKU_LF; } - + function listu_close() { $this->doc .= '</ul>'.DOKU_LF; } - + function listo_open() { $this->doc .= '<ol>'.DOKU_LF; } - + function listo_close() { $this->doc .= '</ol>'.DOKU_LF; } - + function listitem_open($level) { $this->doc .= '<li class="level'.$level.'">'; } - + function listitem_close() { $this->doc .= '</li>'.DOKU_LF; } - + function listcontent_open() { $this->doc .= '<div class="li">'; } - + function listcontent_close() { $this->doc .= '</div>'.DOKU_LF; } - + function unformatted($text) { $this->doc .= $this->_xmlEntities($text); } - + /** * Execute PHP code if allowed * @@ -322,7 +322,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $this->file($text); } } - + /** * Insert HTML if allowed * @@ -336,23 +336,23 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $this->file($text); } } - + function preformatted($text) { $this->doc .= '<pre class="code">' . $this->_xmlEntities($text) . '</pre>'. DOKU_LF; } - + function file($text) { $this->doc .= '<pre class="file">' . $this->_xmlEntities($text). '</pre>'. DOKU_LF; } - + function quote_open() { $this->doc .= '<blockquote><div class="no">'.DOKU_LF; } - + function quote_close() { $this->doc .= '</div></blockquote>'.DOKU_LF; } - + /** * Callback for code text * @@ -362,7 +362,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { */ function code($text, $language = NULL) { global $conf; - + if ( is_null($language) ) { $this->preformatted($text); } else { @@ -376,26 +376,26 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $geshi->set_header_type(GESHI_HEADER_PRE); $geshi->set_overall_class("code $language"); $geshi->set_link_target($conf['target']['extern']); - + $text = $geshi->parse_code(); $this->doc .= $text; } } - + function acronym($acronym) { - + if ( array_key_exists($acronym, $this->acronyms) ) { - + $title = $this->_xmlEntities($this->acronyms[$acronym]); - + $this->doc .= '<acronym title="'.$title .'">'.$this->_xmlEntities($acronym).'</acronym>'; - + } else { $this->doc .= $this->_xmlEntities($acronym); } } - + function smiley($smiley) { if ( array_key_exists($smiley, $this->smileys) ) { $title = $this->_xmlEntities($this->smileys[$smiley]); @@ -406,7 +406,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $this->doc .= $this->_xmlEntities($smiley); } } - + /* * not used function wordblock($word) { @@ -417,7 +417,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } } */ - + function entity($entity) { if ( array_key_exists($entity, $this->entities) ) { $this->doc .= $this->entities[$entity]; @@ -425,33 +425,33 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $this->doc .= $this->_xmlEntities($entity); } } - + function multiplyentity($x, $y) { $this->doc .= "$x×$y"; } - + function singlequoteopening() { $this->doc .= "‘"; } - + function singlequoteclosing() { $this->doc .= "’"; } - + function doublequoteopening() { $this->doc .= "“"; } - + function doublequoteclosing() { $this->doc .= "”"; } - + /** */ function camelcaselink($link) { - $this->internallink($link,$link); + $this->internallink($link,$link); } - + function locallink($hash, $name = NULL){ global $ID; @@ -488,10 +488,10 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } else { $class='media'; } - + //keep hash anchor list($id,$hash) = split('#',$id,2); - + //prepare for formating $link['target'] = $conf['target']['wiki']; $link['style'] = ''; @@ -523,7 +523,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $this->doc .= $this->_formatLink($link); } } - + function externallink($url, $name = NULL) { global $conf; @@ -532,13 +532,13 @@ class Doku_Renderer_xhtml extends Doku_Renderer { // add protocol on simple short URLs if(substr($url,0,3) == 'ftp' && (substr($url,0,6) != 'ftp://')) $url = 'ftp://'.$url; if(substr($url,0,3) == 'www') $url = 'http://'.$url; - + if ( !$isImage ) { $class='urlextern'; } else { $class='media'; } - + //prepare for formating $link['target'] = $conf['target']['extern']; $link['style'] = ''; @@ -554,12 +554,12 @@ class Doku_Renderer_xhtml extends Doku_Renderer { //output formatted $this->doc .= $this->_formatLink($link); } - + /** */ function interwikilink($match, $name = NULL, $wikiName, $wikiUri) { global $conf; - + $link = array(); $link['target'] = $conf['target']['interwiki']; $link['pre'] = ''; @@ -615,7 +615,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { //output formatted $this->doc .= $this->_formatLink($link); } - + /** */ function windowssharelink($url, $name = NULL) { @@ -648,7 +648,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { //output formatted $this->doc .= $this->_formatLink($link); } - + function emaillink($address, $name = NULL) { global $conf; //simple setup @@ -658,7 +658,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $link['suf'] = ''; $link['style'] = ''; $link['more'] = ''; - + //we just test for image here - we need to encode the title our self $this->_getLinkTitle($name, $address, $isImage); if ( !$isImage ) { @@ -675,9 +675,9 @@ class Doku_Renderer_xhtml extends Doku_Renderer { }else{ $name = $this->_xmlEntities($name); } - + if($conf['mailguard'] == 'visible') $address = rawurlencode($address); - + $link['url'] = 'mailto:'.$address; $link['name'] = $name; $link['title'] = $title; @@ -685,7 +685,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { //output formatted $this->doc .= $this->_formatLink($link); } - + function internalmedia ($src, $title=NULL, $align=NULL, $width=NULL, $height=NULL, $cache=NULL, $linking=NULL) { global $conf; @@ -719,7 +719,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { if ($linking == 'nolink' || $noLink) $this->doc .= $link['name']; else $this->doc .= $this->_formatLink($link); } - + /** * @todo don't add link for flash */ @@ -759,7 +759,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { /** * Renders an RSS feed using Magpie - * + * * @author Andreas Gohr <andi@splitbrain.org> */ function rss ($url){ @@ -794,19 +794,19 @@ class Doku_Renderer_xhtml extends Doku_Renderer { function table_open($maxcols = NULL, $numrows = NULL){ $this->doc .= '<table class="inline">'.DOKU_LF; } - + function table_close(){ $this->doc .= '</table>'.DOKU_LF.'<br />'.DOKU_LF; } - + function tablerow_open(){ $this->doc .= DOKU_TAB . '<tr>' . DOKU_LF . DOKU_TAB . DOKU_TAB; } - + function tablerow_close(){ $this->doc .= DOKU_LF . DOKU_TAB . '</tr>' . DOKU_LF; } - + function tableheader_open($colspan = 1, $align = NULL){ $this->doc .= '<th'; if ( !is_null($align) ) { @@ -817,11 +817,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } $this->doc .= '>'; } - + function tableheader_close(){ $this->doc .= '</th>'; } - + function tablecell_open($colspan = 1, $align = NULL){ $this->doc .= '<td'; if ( !is_null($align) ) { @@ -832,11 +832,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } $this->doc .= '>'; } - + function tablecell_close(){ $this->doc .= '</td>'; } - + //---------------------------------------------------------- // Utils @@ -898,7 +898,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { /** * Renders internal and external media - * + * * @author Andreas Gohr <andi@splitbrain.org> */ function _media ($src, $title=NULL, $align=NULL, $width=NULL, @@ -911,7 +911,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { //add image tag $ret .= '<img src="'.ml($src,array('w'=>$width,'h'=>$height,'cache'=>$cache)).'"'; $ret .= ' class="media'.$align.'"'; - + if (!is_null($title)) { $ret .= ' title="'.$this->_xmlEntities($title).'"'; $ret .= ' alt="'.$this->_xmlEntities($title).'"'; @@ -927,14 +927,14 @@ class Doku_Renderer_xhtml extends Doku_Renderer { }else{ $ret .= ' alt=""'; } - + if ( !is_null($width) ) $ret .= ' width="'.$this->_xmlEntities($width).'"'; - + if ( !is_null($height) ) $ret .= ' height="'.$this->_xmlEntities($height).'"'; - $ret .= ' />'; + $ret .= ' />'; }elseif($mime == 'application/x-shockwave-flash'){ $ret .= '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'. @@ -962,11 +962,11 @@ class Doku_Renderer_xhtml extends Doku_Renderer { return $ret; } - + function _xmlEntities($string) { return htmlspecialchars($string); } - + /** * Creates a linkid from a headline */ @@ -982,13 +982,13 @@ class Doku_Renderer_xhtml extends Doku_Renderer { * * This is just aplaceholder and gets replace by the button if * section editing is allowed - * + * * @author Andreas Gohr <andi@splitbrain.org> */ function _secedit($f, $t){ $this->doc .= '<!-- SECTION ['.$f.'-'.$t.'] -->'; } - + /** * Construct a title and handle images in titles * @@ -1013,7 +1013,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { return $this->_imageTitle($title); } } - + /** * Returns an HTML code for images used in link titles * diff --git a/inc/parser/xhtmlsummary.php b/inc/parser/xhtmlsummary.php index eeb684e57..669fa46e3 100644 --- a/inc/parser/xhtmlsummary.php +++ b/inc/parser/xhtmlsummary.php @@ -1,85 +1,85 @@ -<?php
-if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
-
-require_once DOKU_INC . 'inc/parser/xhtml.php';
-
-/**
-* The summary XHTML form selects either up to the first two paragraphs
-* it find in a page or the first section (whichever comes first)
-* It strips out the table of contents if one exists
-* Section divs are not used - everything should be nested in a single
-* div with CSS class "page"
-* Headings have their a name link removed and section editing links
-* removed
-* It also attempts to capture the first heading in a page for
-* use as the title of the page.
-*/
-class Doku_Renderer_xhtmlsummary extends Doku_Renderer_xhtml {
-
- // Namespace these variables to
- // avoid clashes with parent classes
- var $sum_paragraphs = 0;
- var $sum_capture = TRUE;
- var $sum_inSection = FALSE;
- var $sum_summary = '';
- var $sum_pageTitle = FALSE;
-
- function document_start() {
- $this->doc .= DOKU_LF.'<div>'.DOKU_LF;
- }
-
- function document_end() {
- $this->doc = $this->sum_summary;
- $this->doc .= DOKU_LF.'</div>'.DOKU_LF;
- }
-
- function toc_open() {
- $this->sum_summary .= $this->doc;
- }
-
- function toc_close() {
- $this->doc = '';
- }
-
- function header($text, $level, $pos) {
- if ( !$this->sum_pageTitle ) {
- $this->info['sum_pagetitle'] = $text;
- $this->sum_pageTitle = TRUE;
- }
- $this->doc .= DOKU_LF.'<h'.$level.'>';
- $this->doc .= $this->_xmlEntities($text);
- $this->doc .= "</h$level>".DOKU_LF;
- }
-
- function section_open($level) {
- if ( $this->sum_capture ) {
- $this->sum_inSection = TRUE;
- }
- }
-
- function section_close() {
- if ( $this->sum_capture && $this->sum_inSection ) {
- $this->sum_summary .= $this->doc;
- $this->sum_capture = FALSE;
- }
- }
-
- function p_open() {
- if ( $this->sum_capture && $this->sum_paragraphs < 2 ) {
- $this->sum_paragraphs++;
- }
- parent :: p_open();
- }
-
- function p_close() {
- parent :: p_close();
- if ( $this->sum_capture && $this->sum_paragraphs >= 2 ) {
- $this->sum_summary .= $this->doc;
- $this->sum_capture = FALSE;
- }
- }
-
-}
-
-
-//Setup VIM: ex: et ts=2 enc=utf-8 :
+<?php +if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); + +require_once DOKU_INC . 'inc/parser/xhtml.php'; + +/** +* The summary XHTML form selects either up to the first two paragraphs +* it find in a page or the first section (whichever comes first) +* It strips out the table of contents if one exists +* Section divs are not used - everything should be nested in a single +* div with CSS class "page" +* Headings have their a name link removed and section editing links +* removed +* It also attempts to capture the first heading in a page for +* use as the title of the page. +*/ +class Doku_Renderer_xhtmlsummary extends Doku_Renderer_xhtml { + + // Namespace these variables to + // avoid clashes with parent classes + var $sum_paragraphs = 0; + var $sum_capture = TRUE; + var $sum_inSection = FALSE; + var $sum_summary = ''; + var $sum_pageTitle = FALSE; + + function document_start() { + $this->doc .= DOKU_LF.'<div>'.DOKU_LF; + } + + function document_end() { + $this->doc = $this->sum_summary; + $this->doc .= DOKU_LF.'</div>'.DOKU_LF; + } + + function toc_open() { + $this->sum_summary .= $this->doc; + } + + function toc_close() { + $this->doc = ''; + } + + function header($text, $level, $pos) { + if ( !$this->sum_pageTitle ) { + $this->info['sum_pagetitle'] = $text; + $this->sum_pageTitle = TRUE; + } + $this->doc .= DOKU_LF.'<h'.$level.'>'; + $this->doc .= $this->_xmlEntities($text); + $this->doc .= "</h$level>".DOKU_LF; + } + + function section_open($level) { + if ( $this->sum_capture ) { + $this->sum_inSection = TRUE; + } + } + + function section_close() { + if ( $this->sum_capture && $this->sum_inSection ) { + $this->sum_summary .= $this->doc; + $this->sum_capture = FALSE; + } + } + + function p_open() { + if ( $this->sum_capture && $this->sum_paragraphs < 2 ) { + $this->sum_paragraphs++; + } + parent :: p_open(); + } + + function p_close() { + parent :: p_close(); + if ( $this->sum_capture && $this->sum_paragraphs >= 2 ) { + $this->sum_summary .= $this->doc; + $this->sum_capture = FALSE; + } + } + +} + + +//Setup VIM: ex: et ts=2 enc=utf-8 : |