Is it just me, or is something majorly wrong with the CVS server today?
Timwi
Well, the CVS server was working intermittently (stopped working again now), so I've managed to create a patch for my bugfix. This is much shorter than the previous, but it's really just a rearrangement of the code. The only differences to the previous ones are that this input: ''''' text ''' text '' which previously would have output this: <strong><em> text </em></strong><em> text </em> now correctly outputs the expected markup: <em><strong> text </strong> text </em>
At least I hope so. ;-)
Here is the (new) patch. Please let me know if there's still anything I can ameliorate about it.
Greetings, Timwi
------------------------------------------------------------------------
--- OutputPage-orig.php Wed Jul 2 13:04:02 2003 +++ OutputPage.php Wed Jul 2 15:11:52 2003 @@ -658,7 +658,7 @@ $text = preg_replace( "/(^|\n)-----*/", "\1<hr>", $text ); $text = str_replace ( "<HR>", "<hr>", $text );
- $text = $this->doQuotes( $text ); + $text = $this->doQuotes( "", $text, "" ); $text = $this->doHeadings( $text ); $text = $this->doBlockLevels( $text, $linestart ); @@ -677,11 +677,30 @@ return $text; }
- /* private */ function doQuotes( $text ) + /* private */ function doQuotes( $pre, $text, $mode ) { - $text = preg_replace( "/'''(.+)'''/mU", "<strong>$1</strong>", $text ); - $text = preg_replace( "/''(.+)''/mU", "<em>$1</em>", $text ); - return $text; + if ( preg_match( "/^(.*)''(.*)$/mU", $text, $m ) ) { + if ( substr ($m[2], 0, 1) == "'" ) { + $m[2] = substr ($m[2], 1); + return $mode == "em" ? $m[1] == "" ? doQuotes ( "", $m[2], "both" ) : + doQuotes ( $m[1], $m[2], "emstrong" ) : + $mode == "strong" ? "<strong>" . $m[1] . "</strong>" . doQuotes ( "", $m[2], "" ) : + $mode == "emstrong" ? doQuotes ( "", $pre . "<strong>" . $m[1] . "</strong>" . $m[2], "em" ) : + $mode == "strongem" ? "<strong>" . $pre . "<em>" . $m[1] . "</em></strong>" . doQuotes ( "", $m[2], "em" ) : + $mode == "both" ? doQuotes ( "", "<strong>" . $m[1] . "</strong>" . $m[2], "em" ) : + $m[1] . doQuotes ( "", $m[2], "strong" ); + } else { + return $mode == "em" ? "<em>" . $m[1] . "</em>" . doQuotes ( $m[2] ) : + $mode == "strong" ? $m[1] == "" ? doQuotes ( "", $m[2], "both" ) : + doQuotes ( $m[1], $m[2], "strongem" ) : + $mode == "emstrong" ? "<em>" . $pre . "<strong>" . $m[1] . "</strong></em>" . doQuotes ( "", $m[2], "strong" ) : + $mode == "strongem" ? doQuotes ( "", $pre . "<em>" . $m[1] . "</em>" . $m[2], "strong" ) : + $mode == "both" ? doQuotes ( "", "<em>" . $m[1] . "</em>" . $m[2], "strong" ) : + $m[1] . doQuotes ( "", $m[2], "em" ); + } + } else { + return $pre . ($mode == "" ? "" : $mode == "em" ? "''" : $mode == "strong" ? "'''" : "'''''") . $text; + } }
/* private */ function doHeadings( $text )
Timwi wrote:
Well, the CVS server was working intermittently (stopped working again now),
Sourceforge unfortunately sometimes has trouble. :(
so I've managed to create a patch for my bugfix. This is much shorter than the previous, but it's really just a rearrangement of the code. The only differences to the previous ones are that this input: ''''' text ''' text '' which previously would have output this: <strong><em> text </em></strong><em> text </em> now correctly outputs the expected markup: <em><strong> text </strong> text </em>
At least I hope so. ;-)
Cooool. :)
I haven't had a chance yet to look at the new version, I'll try it out tonight hopefully...
-- brion vibber (brion @ pobox.com)
wikitech-l@lists.wikimedia.org