From 36eac0c7b52016c151454dc2ac90196b25b2daf4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Robert=20Stojni=C4=87?= Date: Wed, 3 Jan 2007 14:37:15 +0000 Subject: [PATCH] Introduce 'R' flag for -{}- tags. The flagged text will not be parsed for alternatives syntax, but just outputed. Use this to wrap math. --- RELEASE-NOTES | 1 + languages/LanguageConverter.php | 23 ++++++++++++++--------- languages/classes/LanguageSr.php | 4 ---- maintenance/parserTests.txt | 12 ++++++++++++ 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 813efea58b..d18d38d1bd 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index 37a33fa4f2..afb29a6ee5 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -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   since it interferes with the parsing, plus, - //all spaces should be stripped in this tag anyway. - $rules = str_replace(' ', '', $rules); + if( !in_array('R',$flags) ){ + //FIXME: may cause trouble here... + //strip   since it interferes with the parsing, plus, + //all spaces should be stripped in this tag anyway. + $rules = str_replace(' ', '', $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; } diff --git a/languages/classes/LanguageSr.php b/languages/classes/LanguageSr.php index d7c75ed191..59d31cab52 100644 --- a/languages/classes/LanguageSr.php +++ b/languages/classes/LanguageSr.php @@ -162,10 +162,6 @@ class SrConverter extends LanguageConverter { return $ret; } - function armourMath($text){ - return parent::markNoConversion($text); - } - } class LanguageSr extends LanguageSr_ec { diff --git a/maintenance/parserTests.txt b/maintenance/parserTests.txt index 7cd62e07ec..6a15dd5058 100644 --- a/maintenance/parserTests.txt +++ b/maintenance/parserTests.txt @@ -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 +

Raw: zh:China;zh-tw:Taiwan +

+!! end + + !! test Do not convert roman numbers to language variants !! options -- 2.20.1