From 985016ff3c9325a148cb38b27a2ec4f6b9d66b98 Mon Sep 17 00:00:00 2001 From: vargenau Date: Tue, 17 Feb 2009 14:47:05 +0000 Subject: [PATCH] Wikicreole placeholder git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@6509 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/BlockParser.php | 31 ++++++++++++++++++++++++++++++- lib/InlineParser.php | 13 ++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/lib/BlockParser.php b/lib/BlockParser.php index 0ca685e58..92a952045 100644 --- a/lib/BlockParser.php +++ b/lib/BlockParser.php @@ -368,7 +368,7 @@ class ParsedBlock extends Block_HtmlElement { if (!is_object($_regexpset)) { // nowiki_wikicreole must be before template_plugin $Block_types = array - ('nowiki_wikicreole', 'template_plugin', 'oldlists', 'list', 'dl', 'table_dl', 'table_wikicreole', 'table_mediawiki', + ('nowiki_wikicreole', 'template_plugin', 'placeholder', 'oldlists', 'list', 'dl', 'table_dl', 'table_wikicreole', 'table_mediawiki', 'blockquote', 'heading', 'heading_wikicreole', 'hr', 'pre', 'email_blockquote', 'plugin', 'plugin_wikicreole', 'p'); // insert it before p! @@ -952,6 +952,35 @@ class Block_pre extends BlockMarkup return true; } } + +// Wikicreole placeholder +// <<>> +class Block_placeholder extends BlockMarkup +{ + var $_re = '<<<'; + + function _match (&$input, $m) { + $endtag = '>>>'; + $text = array(); + $pos = $input->getPos(); + + $line = $m->postmatch; + while (ltrim($line) != $endtag) { + $text[] = $line; + if (($line = $input->nextLine()) === false) { + $input->setPos($pos); + return false; + } + } + $input->advance(); + + $text = join("\n", $text); + $text = '<<<' . $text . '>>>'; + $this->_element = new Block_HtmlElement('div', false, $text); + return true; + } +} + class Block_nowiki_wikicreole extends BlockMarkup { var $_re = '{{{'; diff --git a/lib/InlineParser.php b/lib/InlineParser.php index 9d59a211f..b6cff7285 100644 --- a/lib/InlineParser.php +++ b/lib/InlineParser.php @@ -858,6 +858,17 @@ class Markup_color extends BalancedMarkup { } } +// Wikicreole placeholder +// <<>> +class Markup_placeholder extends SimpleMarkup +{ + var $_match_regexp = '<<<.*?>>>'; + + function markup ($match) { + return HTML::span($match); + } +} + // Single-line HTML comment // class Markup_html_comment extends SimpleMarkup @@ -1056,7 +1067,7 @@ class InlineTransformer $non_default = false; $markup_types = array ('escape', 'wikicreolebracketlink', 'bracketlink', 'url', - 'html_comment', + 'html_comment', 'placeholder', 'interwiki', 'semanticlink', 'wikiword', 'linebreak', 'wikicreole_superscript', 'wikicreole_subscript', -- 2.45.0