* Patch by Ivan Krstic to fix a parser test case
authorÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Sun, 26 Mar 2006 02:38:01 +0000 (02:38 +0000)
committerÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Sun, 26 Mar 2006 02:38:01 +0000 (02:38 +0000)
includes/Parser.php

index 00dfae2..a846fc8 100644 (file)
@@ -473,11 +473,9 @@ class Parser
                }
 
                # Comments
-               if($stripcomments) {
-                       $text = Parser::extractTags(STRIP_COMMENTS, $text, $comment_content, $uniq_prefix);
-                       foreach( $comment_content as $marker => $content ){
-                               $comment_content[$marker] = '<!--'.$content.'-->';
-                       }
+               $text = Parser::extractTags(STRIP_COMMENTS, $text, $comment_content, $uniq_prefix);
+               foreach( $comment_content as $marker => $content ){
+                       $comment_content[$marker] = '<!--'.$content.'-->';
                }
 
                # Extensions
@@ -501,6 +499,16 @@ class Parser
                        }
                }
 
+               # Unstrip comments unless explicitly told otherwise.
+               # (The comments are always stripped prior to this point, so as to
+               # not invoke any extension tags / parser hooks contained within
+               # a comment.)
+               if ( !$stripcomments ) {
+                       $tempstate = array( 'comment' => $comment_content );
+                       $text = $this->unstrip( $text, $tempstate );
+                       $comment_content = array();
+               }
+
                # Merge state with the pre-existing state, if there is one
                if ( $state ) {
                        $state['html'] = $state['html'] + $html_content;