From 23b879b55f7c70d0a56650431e00ff6b6970c785 Mon Sep 17 00:00:00 2001 From: Jens Frank Date: Tue, 15 Mar 2005 06:07:58 +0000 Subject: [PATCH] Enhancement 1485 Automatic rendering of -- as HTML dash --- RELEASE-NOTES | 1 + includes/Parser.php | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index be4cb6069f..37e7a89961 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 – depending on context * ...and more! Need to merge: diff --git a/includes/Parser.php b/includes/Parser.php index f096aa3024..596d20b61b 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -172,15 +172,25 @@ class Parser $text = $this->strip( $text, $x ); $text = $this->internalParse( $text, $linestart ); + + $dashReplace = array( + '/ - /' => " – ", # N dash + '/(?<=[0-9])-(?=[0-9])/' => "–", # N dash between numbers + '/ -- /' => " — " # 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 \\2', + '/(.) (?=\\?|:|;|!|\\302\\273)/' => '\\1 \\2', # french spaces, Guillemet-right - '/(\\302\\253) /i' => '\\1 ', + '/(\\302\\253) /' => '\\1 ', '/
/i' => '
', '/
/i' => '
', '/
/i' => '
', @@ -191,9 +201,9 @@ class Parser } else { $fixtags = array( # french spaces, last one Guillemet-left - '/ (\\?|:|;|!|\\302\\273)/i' => ' \\1', + '/ (\\?|:|;|!|\\302\\273)/' => ' \\1', # french spaces, Guillemet-right - '/(\\302\\253) /i' => '\\1 ', + '/(\\302\\253) /' => '\\1 ', '/
/i' => '
', '/<\\/center *>/i' => '
' ); @@ -206,7 +216,6 @@ class Parser $text = $wgContLang->convert($text); $text = $this->unstripNoWiki( $text, $this->mStripState ); - global $wgUseTidy; if ($wgUseTidy) { $text = Parser::tidy($text); } -- 2.20.1