Introduce 'R' flag for -{}- tags. The flagged text will not be parsed
authorRobert Stojnić <rainman@users.mediawiki.org>
Wed, 3 Jan 2007 14:37:15 +0000 (14:37 +0000)
committerRobert Stojnić <rainman@users.mediawiki.org>
Wed, 3 Jan 2007 14:37:15 +0000 (14:37 +0000)
for alternatives syntax, but just outputed. Use this to wrap math.

RELEASE-NOTES
languages/LanguageConverter.php
languages/classes/LanguageSr.php
maintenance/parserTests.txt

index 813efea..d18d38d 100644 (file)
@@ -456,6 +456,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   overridden in LocalSettings.php if desired...
 * Attempt to detect redirect loops for the canonical title redirect, and
   give some hints to the poor confused administrator.
+* Introduce new flag 'R' - raw output for language variant escape tags
 
 
 == Languages updated ==
index 37a33fa..afb29a6 100644 (file)
@@ -45,7 +45,7 @@ class LanguageConverter {
                $m = array('begin'=>'-{', 'flagsep'=>'|', 'codesep'=>':',
                                   'varsep'=>';', 'end'=>'}-');
                $this->mMarkup = array_merge($m, $markup);
-               $f = array('A'=>'A', 'T'=>'T');
+               $f = array('A'=>'A', 'T'=>'T', 'R' => 'R');
                $this->mFlags = array_merge($f, $flags);
        }
 
@@ -315,10 +315,12 @@ class LanguageConverter {
                        else
                                $rules = $marked;
 
-                       //FIXME: may cause trouble here...
-                       //strip &nbsp; since it interferes with the parsing, plus,
-                       //all spaces should be stripped in this tag anyway.
-                       $rules = str_replace('&nbsp;', '', $rules);
+                       if( !in_array('R',$flags) ){
+                               //FIXME: may cause trouble here...
+                               //strip &nbsp; since it interferes with the parsing, plus,
+                               //all spaces should be stripped in this tag anyway.
+                               $rules = str_replace('&nbsp;', '', $rules);
+                       }
 
                        return array($rules,$flags);
        }
@@ -398,7 +400,10 @@ class LanguageConverter {
                        // strip the flags from syntax like -{T| ... }-
                        list($rules,$flags) = $this->parseFlags($marked[0]);
 
-                       if( $this->mDoContentConvert){
+                       // proces R flag: output raw content of -{ ... }-
+                       if( in_array('R',$flags) ){
+                               $disp = $rules;
+                       } else if( $this->mDoContentConvert){
                                // parse the contents -{ ... }- 
                                $carray = $this->parseManualRule($rules, $flags);
 
@@ -796,11 +801,11 @@ class LanguageConverter {
 
        /** 
         * Armour rendered math against conversion
-        * Default is do nothing, since the process can interfere with 
-        * parseManualRule() if format -{ alter1 ; alter2 }- is enabled
+        * Wrap math into rawoutput -{R| math }- syntax
         */
        function armourMath($text){ 
-               return $text;
+               $ret = $this->mMarkup['begin'] . 'R|' . $text . $this->mMarkup['end'];
+               return $ret;
        }
 
 
index d7c75ed..59d31ca 100644 (file)
@@ -162,10 +162,6 @@ class SrConverter extends LanguageConverter {
                return $ret;
        }
 
-       function armourMath($text){ 
-               return parent::markNoConversion($text);
-       }
-
 }
 
 class LanguageSr extends LanguageSr_ec {
index 7cd62e0..6a15dd5 100644 (file)
@@ -6350,6 +6350,18 @@ Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
 !! end
 
 
+!! test
+Raw output of variant escape tags (R flag)
+!! options
+language=zh variant=zh-tw
+!! input
+Raw: -{R|zh:China;zh-tw:Taiwan}-
+!! result
+<p>Raw: zh:China;zh-tw:Taiwan
+</p>
+!! end
+
+
 !! test
 Do not convert roman numbers to language variants
 !! options