From: <var...@us...> - 2014-11-20 17:47:09
|
Revision: 9351 http://sourceforge.net/p/phpwiki/code/9351 Author: vargenau Date: 2014-11-20 17:47:06 +0000 (Thu, 20 Nov 2014) Log Message: ----------- Remove unused code and debug Modified Paths: -------------- trunk/lib/InlineParser.php Modified: trunk/lib/InlineParser.php =================================================================== --- trunk/lib/InlineParser.php 2014-11-20 17:14:06 UTC (rev 9350) +++ trunk/lib/InlineParser.php 2014-11-20 17:47:06 UTC (rev 9351) @@ -89,7 +89,6 @@ { assert($regexps); $this->_regexps = array_unique($regexps); - if (!defined('_INLINE_OPTIMIZATION')) define('_INLINE_OPTIMIZATION', 0); } /** @@ -146,83 +145,29 @@ // s - DOTALL // A - ANCHORED // S - STUDY - function _match($text, $regexps, $repeat) + private function _match($text, $regexps, $repeat) { - // If one of the regexps is an empty string, php will crash here: - // sf.net: Fatal error: Allowed memory size of 8388608 bytes exhausted - // (tried to allocate 634 bytes) - if (_INLINE_OPTIMIZATION) { // disabled, wrong - // So we try to minize memory usage, by looping explicitly, - // and storing only those regexp which actually match. - // There may be more than one, so we have to find the longest, - // and match inside until the shortest is empty. - $matched = array(); - $matched_ind = array(); - for ($i = 0; $i < count($regexps); $i++) { - if (!trim($regexps[$i])) { - trigger_error("empty regexp $i", E_USER_WARNING); - continue; - } - $pat = "/ ( . $repeat ) ( " . $regexps[$i] . " ) /x"; - if (preg_match($pat, $text, $_m)) { - $m = $_m; // FIXME: prematch, postmatch is wrong - $matched[] = $regexps[$i]; - $matched_ind[] = $i; - $regexp_ind = $i; - } - } - // To overcome ANCHORED: - // We could sort by longest match and iterate over these. - if (empty($matched)) - return false; - } $match = new RegexpSet_match; // Optimization: if the matches are only "$" and another, then omit "$" - if (!_INLINE_OPTIMIZATION or count($matched) > 2) { - assert(!empty($repeat)); - assert(!empty($regexps)); - // We could do much better, if we would know the matching markup for the - // longest regexp match: - $hugepat = "/ ( . $repeat ) ( (" . join(')|(', $regexps) . ") ) /Asx"; - // Proposed premature optimization 1: - //$hugepat= "/ ( . $repeat ) ( (" . join(')|(', array_values($matched)) . ") ) /Asx"; - if (!preg_match($hugepat, $text, $m)) { - return false; - } - // Proposed premature optimization 1: - //$match->regexp_ind = $matched_ind[count($m) - 4]; - $match->regexp_ind = count($m) - 4; - } else { - $match->regexp_ind = $regexp_ind; + assert(!empty($repeat)); + assert(!empty($regexps)); + // We could do much better, if we would know the matching markup for the + // longest regexp match: + $hugepat = "/ ( . $repeat ) ( (" . join(')|(', $regexps) . ") ) /Asx"; + // Proposed premature optimization 1: + //$hugepat= "/ ( . $repeat ) ( (" . join(')|(', array_values($matched)) . ") ) /Asx"; + if (!preg_match($hugepat, $text, $m)) { + return false; } + // Proposed premature optimization 1: + //$match->regexp_ind = $matched_ind[count($m) - 4]; + $match->regexp_ind = count($m) - 4; $match->postmatch = substr($text, strlen($m[0])); $match->prematch = $m[1]; $match->match = $m[2]; - /* DEBUGGING */ - if (DEBUG & _DEBUG_PARSER) { - static $_already_dumped = 0; - if (!$_already_dumped) { - var_dump($regexps); - if (_INLINE_OPTIMIZATION) - var_dump($matched); - var_dump($matched_ind); - } - $_already_dumped = 1; - PrintXML(HTML::dl(HTML::dt("input"), - HTML::dd(HTML::pre($text)), - HTML::dt("regexp"), - HTML::dd(HTML::pre($match->regexp_ind, ":", $regexps[$match->regexp_ind])), - HTML::dt("prematch"), - HTML::dd(HTML::pre($match->prematch)), - HTML::dt("match"), - HTML::dd(HTML::pre($match->match)), - HTML::dt("postmatch"), - HTML::dd(HTML::pre($match->postmatch)) - )); - } return $match; } } @@ -622,7 +567,8 @@ function getMatchRegexp() { global $WikiNameRegexp; - if (!trim($WikiNameRegexp)) return " " . WIKI_NAME_REGEXP; + if (!trim($WikiNameRegexp)) + return " " . WIKI_NAME_REGEXP; return " $WikiNameRegexp"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2014-11-20 17:49:56
|
Revision: 9352 http://sourceforge.net/p/phpwiki/code/9352 Author: vargenau Date: 2014-11-20 17:49:49 +0000 (Thu, 20 Nov 2014) Log Message: ----------- Remove Markup_xml_plugin Modified Paths: -------------- trunk/lib/InlineParser.php Modified: trunk/lib/InlineParser.php =================================================================== --- trunk/lib/InlineParser.php 2014-11-20 17:47:06 UTC (rev 9351) +++ trunk/lib/InlineParser.php 2014-11-20 17:49:49 UTC (rev 9352) @@ -1001,47 +1001,6 @@ } } -// Special version for plugins in xml syntax, mediawiki-style -// <name arg=value>body</name> or <name /> => < ? plugin pluginname arg=value body ? > -// PLUGIN_MARKUP_MAP = "html:RawHtml dot:GraphViz toc:CreateToc amath:AsciiMath richtable:RichTable include:IncludePage tex:TexToPng" -class Markup_xml_plugin extends BalancedMarkup -{ - //public $_start_regexp = "<(?: ".join('|',PLUGIN_MARKUP_MAP)." )(?: \s[^>]*)>"; - - function getStartRegexp() - { - global $PLUGIN_MARKUP_MAP; - static $_start_regexp; - if ($_start_regexp) return $_start_regexp; - if (empty($PLUGIN_MARKUP_MAP)) return ''; - //"<(?: html|search|extsearch|dot|toc|math|richtable|include|tex )(?: \s[^>]*)>" - $_start_regexp = "<(?: " . join('|', array_keys($PLUGIN_MARKUP_MAP)) . " )(?: \s[^>]*|\\/ )>"; - return $_start_regexp; - } - - function getEndRegexp($match) - { - return "<\\/" . $match . '>'; - } - - function markup($match, $body) - { - global $PLUGIN_MARKUP_MAP; - $name = substr($match, 2, -2); - $vars = ''; - if (preg_match('/^(\S+)\|(.*)$/', $name, $_m)) { - $name = $_m[1]; - $vars = $_m[2]; //str_replace(' ', '&', $_m[2]); - } - if (!isset($PLUGIN_MARKUP_MAP[$name])) { - trigger_error("No plugin for $name $vars defined.", E_USER_WARNING); - return ""; - } - $plugin = $PLUGIN_MARKUP_MAP[$name]; - return new Cached_PluginInvocation("<" . "?plugin $plugin $vars $body ?" . ">"); - } -} - /** * Mediawiki <nowiki> * <nowiki>...</nowiki> @@ -1283,9 +1242,6 @@ $this->_addMarkup(new Markup_wikicreole_preformatted); if (ENABLE_MARKUP_TEMPLATE and !$non_default) $this->_addMarkup(new Markup_template_plugin); - // This does not work yet - if (PLUGIN_MARKUP_MAP and !$non_default) - $this->_addMarkup(new Markup_xml_plugin); } function _addMarkup($markup) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2015-03-02 17:21:53
|
Revision: 9585 http://sourceforge.net/p/phpwiki/code/9585 Author: vargenau Date: 2015-03-02 17:21:46 +0000 (Mon, 02 Mar 2015) Log Message: ----------- Remove assertions Modified Paths: -------------- trunk/lib/InlineParser.php Modified: trunk/lib/InlineParser.php =================================================================== --- trunk/lib/InlineParser.php 2015-03-02 17:20:45 UTC (rev 9584) +++ trunk/lib/InlineParser.php 2015-03-02 17:21:46 UTC (rev 9585) @@ -453,9 +453,7 @@ function markup($match) { - $link = LinkBracketLink($match); - assert($link->isInlineElement()); - return $link; + return LinkBracketLink($match); } } @@ -465,9 +463,7 @@ function markup($match) { - $link = LinkBracketLink($match); - assert($link->isInlineElement()); - return $link; + return LinkBracketLink($match); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2016-02-16 11:52:26
|
Revision: 9804 http://sourceforge.net/p/phpwiki/code/9804 Author: vargenau Date: 2016-02-16 11:52:24 +0000 (Tue, 16 Feb 2016) Log Message: ----------- Remove html_entities (unused) Modified Paths: -------------- trunk/lib/InlineParser.php Modified: trunk/lib/InlineParser.php =================================================================== --- trunk/lib/InlineParser.php 2016-02-12 11:35:42 UTC (rev 9803) +++ trunk/lib/InlineParser.php 2016-02-16 11:52:24 UTC (rev 9804) @@ -1144,35 +1144,6 @@ } } -// "..." => "…" browser specific display (not cached?) -// Support some HTML::Entities: (C) for copy, --- for mdash, -- for ndash -// TODO: "--" => "&emdash;" browser specific display (not cached?) - -class Markup_html_entities extends SimpleMarkup -{ - //public $_match_regexp = '(: \.\.\.|\-\-|\-\-\-|\(C\) )'; - - function __construct() - { - $this->_entities = array('...' => '…', - '--' => '–', - '---' => '—', - '(C)' => '©', - '©' => '©', - '™' => '™', - ); - $this->_match_regexp = - '(: ' . - join('|', array_map('preg_quote', array_keys($this->_entities))) . - ' )'; - } - - function markup($match) - { - return HTML::raw($this->_entities[$match]); - } -} - class Markup_isonumchars extends SimpleMarkup { public $_match_regexp = '\&\#\d{2,5};'; @@ -1219,7 +1190,7 @@ 'wikicreole_underline', 'old_emphasis', 'nestled_emphasis', 'html_emphasis', 'html_abbr', 'plugin', 'plugin_wikicreole', - 'isonumchars', 'isohexchars', /*'html_entities'*/ + 'isonumchars', 'isohexchars', ); if (defined('DISABLE_MARKUP_WIKIWORD') and DISABLE_MARKUP_WIKIWORD) $markup_types = array_remove($markup_types, 'wikiword'); @@ -1364,7 +1335,7 @@ parent::__construct (array('linebreak', 'html_emphasis', 'html_abbr', 'plugin', 'plugin_wikicreole', - 'isonumchars', 'isohexchars', /*'html_entities',*/ + 'isonumchars', 'isohexchars', )); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2016-02-16 12:00:27
|
Revision: 9805 http://sourceforge.net/p/phpwiki/code/9805 Author: vargenau Date: 2016-02-16 12:00:24 +0000 (Tue, 16 Feb 2016) Log Message: ----------- Remove call to nonexistent setTightness Modified Paths: -------------- trunk/lib/InlineParser.php Modified: trunk/lib/InlineParser.php =================================================================== --- trunk/lib/InlineParser.php 2016-02-16 11:52:24 UTC (rev 9804) +++ trunk/lib/InlineParser.php 2016-02-16 12:00:24 UTC (rev 9805) @@ -1256,7 +1256,6 @@ and is_a($markup, 'Markup_plugin') ) { $current =& $output->_content[count($output->_content) - 1]; - $current->setTightness(true, true); } $output->pushContent($match->prematch); $text = $match->postmatch; @@ -1280,13 +1279,7 @@ else $current = $markup->markup($match->match, $body); $input = $match->postmatch; - if (isset($markup) and is_object($markup) - and is_a($markup, 'Markup_plugin') - ) { - $current->setTightness(true, true); - } $output->pushContent($match->prematch, $current); - $match = $regexps->match($input); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2020-12-26 17:42:29
|
Revision: 10207 http://sourceforge.net/p/phpwiki/code/10207 Author: vargenau Date: 2020-12-26 17:42:28 +0000 (Sat, 26 Dec 2020) Log Message: ----------- Fix image display in Help/Images (no double slash) Modified Paths: -------------- trunk/lib/InlineParser.php Modified: trunk/lib/InlineParser.php =================================================================== --- trunk/lib/InlineParser.php 2020-12-26 16:01:39 UTC (rev 10206) +++ trunk/lib/InlineParser.php 2020-12-26 17:42:28 UTC (rev 10207) @@ -1102,7 +1102,7 @@ if ((strpos($imagename, "http://") === 0) || (strpos($imagename, "https://") === 0)) { return LinkImage($imagename, $alt); } elseif ($imagename[0] == '/') { - return LinkImage(DATA_PATH . '/' . $imagename, $alt); + return LinkImage(DATA_PATH . $imagename, $alt); } else { return LinkImage(getUploadDataPath() . $imagename, $alt); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |