* Fixed <!-- ~~~~ -->, added parser test
authorTim Starling <tstarling@users.mediawiki.org>
Fri, 25 Jan 2008 04:14:51 +0000 (04:14 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Fri, 25 Jan 2008 04:14:51 +0000 (04:14 +0000)
* Commented out memCheck()

includes/Preprocessor.php
includes/Preprocessor_DOM.php
maintenance/parserTests.txt

index 036cc99..ba788aa 100644 (file)
@@ -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
index f248d00..4e29669 100644 (file)
@@ -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 <onlyinclude>
@@ -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' ) {
index fea30ca..0af0a53 100644 (file)
@@ -6734,6 +6734,16 @@ HHP2.2: Heuristics for headings in preprocessor parenthetical structures
 
 !! end
 
+!! test
+Tildes in comments
+!! options
+pst
+!! input
+<!-- ~~~~ -->
+!! result
+<!-- ~~~~ -->
+!! end
+
 #
 #
 #