From db89122b8903bb325fc6818033ca11be9e638e89 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Fri, 25 Jan 2008 04:14:51 +0000 Subject: [PATCH] * Fixed , added parser test * Commented out memCheck() --- includes/Preprocessor.php | 3 ++- includes/Preprocessor_DOM.php | 12 ++++++++++-- maintenance/parserTests.txt | 10 ++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/includes/Preprocessor.php b/includes/Preprocessor.php index 036cc99d16..ba788aa80b 100644 --- a/includes/Preprocessor.php +++ b/includes/Preprocessor.php @@ -11,8 +11,9 @@ interface PPFrame { const NO_TEMPLATES = 2; const STRIP_COMMENTS = 4; const NO_IGNORE = 8; + const RECOVER_COMMENTS = 16; - const RECOVER_ORIG = 11; + const RECOVER_ORIG = 27; // = 1|2|8|16 no constant expression support in PHP yet /** * Create a child frame diff --git a/includes/Preprocessor_DOM.php b/includes/Preprocessor_DOM.php index f248d005e4..4e29669b77 100644 --- a/includes/Preprocessor_DOM.php +++ b/includes/Preprocessor_DOM.php @@ -114,7 +114,7 @@ class Preprocessor_DOM implements Preprocessor { $fakeLineStart = true; # Do a line-start run without outputting an LF character while ( true ) { - if ( ! ($i % 10) ) $this->memCheck(); + //$this->memCheck(); if ( $findOnlyinclude ) { // Ignore all input up to the next @@ -911,12 +911,20 @@ class PPFrame_DOM implements PPFrame { } } elseif ( $contextNode->nodeName == 'comment' ) { # HTML-style comment + # Remove it in HTML, pre+remove and STRIP_COMMENTS modes if ( $this->parser->ot['html'] || ( $this->parser->ot['pre'] && $this->parser->mOptions->getRemoveComments() ) || ( $flags & self::STRIP_COMMENTS ) ) { $out .= ''; - } else { + } + # Add a strip marker in PST mode so that pstPass2() can run some old-fashioned regexes on the result + # Not in RECOVER_COMMENTS mode (extractSections) though + elseif ( $this->parser->ot['wiki'] && ! ( $flags & self::RECOVER_COMMENTS ) ) { + $out .= $this->parser->insertStripItem( $contextNode->textContent ); + } + # Recover the literal comment in RECOVER_COMMENTS and pre+no-remove + else { $out .= $contextNode->textContent; } } elseif ( $contextNode->nodeName == 'ignore' ) { diff --git a/maintenance/parserTests.txt b/maintenance/parserTests.txt index fea30ca9b3..0af0a5383d 100644 --- a/maintenance/parserTests.txt +++ b/maintenance/parserTests.txt @@ -6734,6 +6734,16 @@ HHP2.2: Heuristics for headings in preprocessor parenthetical structures !! end +!! test +Tildes in comments +!! options +pst +!! input + +!! result + +!! end + # # # -- 2.20.1