r30142 - Code Review

From MediaWiki.org

Jump to: navigation, search
Repository:MediaWiki
Revision:r30141 | r30142 (on ViewVC) | r30143 >
Date:04:14, 25 January 2008
Author:tstarling
Status:ok
Tags:
Comment:* Fixed <!-- ~~~~ -->, added parser test
* Commented out memCheck()
Modified paths:

Diff [purge]

Index: trunk/phase3/maintenance/parserTests.txt
===================================================================
--- trunk/phase3/maintenance/parserTests.txt	(revision 30141)
+++ trunk/phase3/maintenance/parserTests.txt	(revision 30142)
@@ -6734,6 +6734,16 @@
 
 !! end
 
+!! test
+Tildes in comments
+!! options
+pst
+!! input
+<!-- ~~~~ -->
+!! result
+<!-- ~~~~ -->
+!! end
+
 #
 #
 #
Index: trunk/phase3/includes/Preprocessor_DOM.php
===================================================================
--- trunk/phase3/includes/Preprocessor_DOM.php	(revision 30141)
+++ trunk/phase3/includes/Preprocessor_DOM.php	(revision 30142)
@@ -114,7 +114,7 @@
 		$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 @@
 					}
 				} 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: trunk/phase3/includes/Preprocessor.php
===================================================================
--- trunk/phase3/includes/Preprocessor.php	(revision 30141)
+++ trunk/phase3/includes/Preprocessor.php	(revision 30142)
@@ -11,8 +11,9 @@
 	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
Views
Toolbox