Enhancement 1485 Automatic rendering of -- as HTML dash
authorJens Frank <jeluf@users.mediawiki.org>
Tue, 15 Mar 2005 06:07:58 +0000 (06:07 +0000)
committerJens Frank <jeluf@users.mediawiki.org>
Tue, 15 Mar 2005 06:07:58 +0000 (06:07 +0000)
RELEASE-NOTES
includes/Parser.php

index be4cb60..37e7a89 100644 (file)
@@ -13,6 +13,7 @@ New exciting things! Need further work and testing...
 * e-mail change notifications
 * 'live preview' reduces preview reload burden on supported browsers
 * Schema reworking: http://meta.wikimedia.org/wiki/Proposed_Database_Schema_Changes/October_2004
+* New WikiSyntax: -- turns into &emdash; or &ndash; depending on context
 * ...and more!
 
 Need to merge:
index f096aa3..596d20b 100644 (file)
@@ -172,15 +172,25 @@ class Parser
                $text = $this->strip( $text, $x );
 
                $text = $this->internalParse( $text, $linestart );
+
+               $dashReplace = array(
+                                                '/ - /' => "&nbsp;&ndash; ", # N dash
+                                                '/(?<=[0-9])-(?=[0-9])/' => "&ndash;", # N dash between numbers
+                                                '/ -- /' => "&nbsp;&mdash; " # M dash
+                                                );
+               $text = preg_replace( array_keys($dashReplace), array_values($dashReplace), $text );
+               
+               
                $text = $this->unstrip( $text, $this->mStripState );
                # Clean up special characters, only run once, next-to-last before doBlockLevels
+               global $wgUseTidy;
                if(!$wgUseTidy) {
                        $fixtags = array(
                                # french spaces, last one Guillemet-left
                                # only if there is something before the space
-                               '/(.) (?=\\?|:|;|!|\\302\\273)/i' => '\\1&nbsp;\\2',
+                               '/(.) (?=\\?|:|;|!|\\302\\273)/' => '\\1&nbsp;\\2',
                                # french spaces, Guillemet-right
-                               '/(\\302\\253) /i' => '\\1&nbsp;',
+                               '/(\\302\\253) /' => '\\1&nbsp;',
                                '/<hr *>/i' => '<hr />',
                                '/<br *>/i' => '<br />',
                                '/<center *>/i' => '<div class="center">',
@@ -191,9 +201,9 @@ class Parser
                } else {
                        $fixtags = array(
                                # french spaces, last one Guillemet-left
-                               '/ (\\?|:|;|!|\\302\\273)/i' => '&nbsp;\\1',
+                               '/ (\\?|:|;|!|\\302\\273)/' => '&nbsp;\\1',
                                # french spaces, Guillemet-right
-                               '/(\\302\\253) /i' => '\\1&nbsp;',
+                               '/(\\302\\253) /' => '\\1&nbsp;',
                                '/<center *>/i' => '<div class="center">',
                                '/<\\/center *>/i' => '</div>'
                        );
@@ -206,7 +216,6 @@ class Parser
                $text = $wgContLang->convert($text);
 
                $text = $this->unstripNoWiki( $text, $this->mStripState );
-               global $wgUseTidy;
                if ($wgUseTidy) {
                        $text = Parser::tidy($text);
                }