diff options
author | Anika Henke <a.c.henke@arcor.de> | 2007-05-18 01:32:13 +0200 |
---|---|---|
committer | Anika Henke <a.c.henke@arcor.de> | 2007-05-18 01:32:13 +0200 |
commit | 07f89c3c8f7bdf32c835189da7cd6e8393ab8570 (patch) | |
tree | e344aa3f8f4dfe35ae9e7142e0cfef573231644b /inc/parser | |
parent | b27484c2fe1cc1a782f2788b4e3e02f6ef3fa7c8 (diff) | |
download | rpg-07f89c3c8f7bdf32c835189da7cd6e8393ab8570.tar.gz rpg-07f89c3c8f7bdf32c835189da7cd6e8393ab8570.tar.bz2 |
added block mode for embedded html+php (FS#541) -- same syntax but in capital letters (<HTML>+<PHP>)
darcs-hash:20070517233213-d5083-9dbccf77383575912ad75533ca690302557e0f79.gz
Diffstat (limited to 'inc/parser')
-rw-r--r-- | inc/parser/handler.php | 26 | ||||
-rw-r--r-- | inc/parser/metadata.php | 4 | ||||
-rw-r--r-- | inc/parser/parser.php | 6 | ||||
-rw-r--r-- | inc/parser/renderer.php | 4 | ||||
-rw-r--r-- | inc/parser/xhtml.php | 10 |
5 files changed, 48 insertions, 2 deletions
diff --git a/inc/parser/handler.php b/inc/parser/handler.php index 0a021987f..9716bd74f 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -277,6 +277,18 @@ class Doku_Handler { return true; } + function phpblock($match, $state, $pos) { + global $conf; + if ( $state == DOKU_LEXER_UNMATCHED ) { + if ($conf['phpok']) { + $this->_addCall('phpblock',array($match), $pos); + } else { + $this->_addCall('file',array($match), $pos); + } + } + return true; + } + function html($match, $state, $pos) { global $conf; if ( $state == DOKU_LEXER_UNMATCHED ) { @@ -289,6 +301,18 @@ class Doku_Handler { return true; } + function htmlblock($match, $state, $pos) { + global $conf; + if ( $state == DOKU_LEXER_UNMATCHED ) { + if($conf['htmlok']){ + $this->_addCall('htmlblock',array($match), $pos); + } else { + $this->_addCall('file',array($match), $pos); + } + } + return true; + } + function preformatted($match, $state, $pos) { switch ( $state ) { case DOKU_LEXER_ENTER: @@ -1416,6 +1440,7 @@ class Doku_Handler_Block { 'quote_open', 'section_open', // Needed to prevent p_open between header and section_open 'code','file','hr','preformatted','rss', + 'htmlblock','phpblock', ); var $blockClose = array( @@ -1425,6 +1450,7 @@ class Doku_Handler_Block { 'quote_close', 'section_close', // Needed to prevent p_close after section_close 'code','file','hr','preformatted','rss', + 'htmlblock','phpblock', ); // Stacks can contain paragraphs diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php index 846bbff23..5f06865cf 100644 --- a/inc/parser/metadata.php +++ b/inc/parser/metadata.php @@ -195,8 +195,12 @@ class Doku_Renderer_metadata extends Doku_Renderer { function php($text){} + function phpblock($text){} + function html($text){} + function htmlblock($text){} + function preformatted($text){ if ($this->capture) $this->doc .= $text; } diff --git a/inc/parser/parser.php b/inc/parser/parser.php index 709f063da..849c6f0ea 100644 --- a/inc/parser/parser.php +++ b/inc/parser/parser.php @@ -34,7 +34,7 @@ $PARSER_MODES = array( // modes which have a start and end token but inside which // no other modes should be applied - 'protected' => array('preformatted','code','file','php','html'), + 'protected' => array('preformatted','code','file','php','html','htmlblock','phpblock'), // inside this mode no wiki markup should be applied but lineendings // and whitespace isn't preserved @@ -489,10 +489,12 @@ class Doku_Parser_Mode_php extends Doku_Parser_Mode { function connectTo($mode) { $this->Lexer->addEntryPattern('<php>(?=.*</php>)',$mode,'php'); + $this->Lexer->addEntryPattern('<PHP>(?=.*</PHP>)',$mode,'phpblock'); } function postConnect() { $this->Lexer->addExitPattern('</php>','php'); + $this->Lexer->addExitPattern('</PHP>','phpblock'); } function getSort() { @@ -505,10 +507,12 @@ class Doku_Parser_Mode_html extends Doku_Parser_Mode { function connectTo($mode) { $this->Lexer->addEntryPattern('<html>(?=.*</html>)',$mode,'html'); + $this->Lexer->addEntryPattern('<HTML>(?=.*</HTML>)',$mode,'htmlblock'); } function postConnect() { $this->Lexer->addExitPattern('</html>','html'); + $this->Lexer->addExitPattern('</HTML>','htmlblock'); } function getSort() { diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index 808261ddf..dd4974f0d 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -150,8 +150,12 @@ class Doku_Renderer extends DokuWiki_Plugin { function php($text) {} + function phpblock($text) {} + function html($text) {} + function htmlblock($text) {} + function preformatted($text) {} function file($text) {} diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index 102958c9d..827666ef4 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -130,7 +130,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { 'type' => 'ul', 'level' => $level-$conf['toptoclevel']+1); } - } + } function header($text, $level, $pos) { @@ -347,6 +347,10 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } } + function phpblock($text) { + $this->php($text); + } + /** * Insert HTML if allowed * @@ -361,6 +365,10 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } } + function htmlblock($text) { + $this->html($text); + } + function preformatted($text) { $this->doc .= '<pre class="code">' . $this->_xmlEntities($text) . '</pre>'. DOKU_LF; } |