r3013 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r3012‎ | r3013 | r3014 >
Date:17:56, 7 April 2004
Author:gabrielwicke
Status:old
Tags:
Comment:
* doTokenizedParser doesn't assume leading text token anymore, 0 !== false
* pre nesting problem fixed by matching against $uniq_prefix . '-' . $tag, marker changed to this format. If stripped areas shouldn't be nested in p's, add those tags to the $inBlockElem = false; regex in doBlockLevels
Modified paths:
  • /trunk/phase3/includes/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Parser.php
@@ -108,7 +108,7 @@
109109
110110 /* static */ function extractTags($tag, $text, &$content, $uniq_prefix = ""){
111111 $result = array();
112 - $rnd = $uniq_prefix . Parser::getRandomString();
 112+ $rnd = $uniq_prefix . '-' . $tag . Parser::getRandomString();
113113 $content = array( );
114114 $n = 1;
115115 $stripped = "";
@@ -178,9 +178,9 @@
179179 $text = Parser::extractTags("pre", $text, $pre_content, $uniq_prefix);
180180 foreach( $pre_content as $marker => $content ){
181181 if( $render ){
182 - $pre_content[$marker] = "\n<pre>" . wfEscapeHTMLTagsOnly( $content ) . "</pre>";
 182+ $pre_content[$marker] = "<pre>" . wfEscapeHTMLTagsOnly( $content ) . "</pre>";
183183 } else {
184 - $pre_content[$marker] = "\n<pre>$content</pre>";
 184+ $pre_content[$marker] = "<pre>$content</pre>";
185185 }
186186 }
187187
@@ -547,8 +547,8 @@
548548
549549 /* private */ function handle3Quotes( &$state, $token )
550550 {
551 - if ( $state["strong"] ) {
552 - if ( $state["em"] && $state["em"] > $state["strong"] )
 551+ if ( $state["strong"] !== false ) {
 552+ if ( $state["em"] !== false && $state["em"] > $state["strong"] )
553553 {
554554 # ''' lala ''lala '''
555555 $s = "</em></strong><em>";
@@ -565,8 +565,8 @@
566566
567567 /* private */ function handle2Quotes( &$state, $token )
568568 {
569 - if ( $state["em"] ) {
570 - if ( $state["strong"] && $state["strong"] > $state["em"] )
 569+ if ( $state["em"] !== false ) {
 570+ if ( $state["strong"] !== false && $state["strong"] > $state["em"] )
571571 {
572572 # ''lala'''lala'' ....'''
573573 $s = "</strong></em><strong>";
@@ -584,18 +584,18 @@
585585 /* private */ function handle5Quotes( &$state, $token )
586586 {
587587 $s = "";
588 - if ( $state["em"] && $state["strong"] ) {
 588+ if ( $state["em"] !== false && $state["strong"] ) {
589589 if ( $state["em"] < $state["strong"] ) {
590590 $s .= "</strong></em>";
591591 } else {
592592 $s .= "</em></strong>";
593593 }
594594 $state["strong"] = $state["em"] = FALSE;
595 - } elseif ( $state["em"] ) {
 595+ } elseif ( $state["em"] !== false ) {
596596 $s .= "</em><strong>";
597597 $state["em"] = FALSE;
598598 $state["strong"] = $token["pos"];
599 - } elseif ( $state["strong"] ) {
 599+ } elseif ( $state["strong"] !== false ) {
600600 $s .= "</strong><em>";
601601 $state["strong"] = FALSE;
602602 $state["em"] = $token["pos"];
@@ -1027,10 +1027,10 @@
10281028 }
10291029 if ( 0 == $npl ) { # No prefix--go to paragraph mode
10301030 if ( preg_match(
1031 - "/(<table|<blockquote|<h1|<h2|<h3|<h4|<h5|<h6|<div|<pre)/i", $t ) ) {
 1031+ "/(<table|<blockquote|<h1|<h2|<h3|<h4|<h5|<h6|<div)/i", $t ) ) {
10321032 $text .= $this->closeParagraph();
10331033 $inBlockElem = true;
1034 - } else if ( preg_match("/(<hr|<\\/td)/i", $t ) ) {
 1034+ } else if ( preg_match("/(<hr|<\\/td|".$uniq_prefix."-pre)/i", $t ) ) {
10351035 $text .= $this->closeParagraph();
10361036 $inBlockElem = false;
10371037 }
@@ -1057,7 +1057,7 @@
10581058 }
10591059 }
10601060 if ( $inBlockElem &&
1061 - preg_match( "/(<\\/table|<\\/blockquote|<\\/h1|<\\/h2|<\\/h3|<\\/h4|<\\/h5|<\\/h6|<\\/p<\\/div|<\\/pre)/i", $t ) ) {
 1061+ preg_match( "/(<\\/table|<\\/blockquote|<\\/h1|<\\/h2|<\\/h3|<\\/h4|<\\/h5|<\\/h6|<\\/p<\\/div)/i", $t ) ) {
10621062 $inBlockElem = false;
10631063 }
10641064 }

Status & tagging log