r111364 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111363‎ | r111364 | r111365 >
Date:13:35, 13 February 2012
Author:gwicke
Status:deferred
Tags:
Comment:
Add some support for ideographic spaces in external links, support the
int: namespace alias and perform some normalization on the MediaWiki namespace
prefix.
Modified paths:
  • /trunk/extensions/VisualEditor/modules/parser/mediawiki.parser.environment.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt
@@ -455,7 +455,7 @@
456456 }
457457
458458 link_preprocessor_text
459 - = r:( t:[^'<~[{\n\r|!\]}\t &="']+ { return t.join(''); }
 459+ = r:( t:[^'<~[{\n\r|!\]}\t&="' \u00A0\u1680\u180E\u2000-\u200A\u202F\u205F\u3000]+ { return t.join(''); }
460460 / directive
461461 / urlencoded_char
462462 / !inline_breaks no_punctuation_char
@@ -734,7 +734,8 @@
735735 & { return setFlag('extlink'); }
736736 //target:urllink
737737 target:link_preprocessor_text
738 - text:(space* t:inlineline { return t } )?
 738+ text:(( space / [\u00A0\u1680\u180E\u2000-\u200A\u202F\u205F\u3000] )*
 739+ t:inlineline { return t } )?
739740 "]" {
740741 clearFlag('extlink');
741742 if ( text === '' ) {
Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.parser.environment.js
@@ -87,6 +87,17 @@
8888 throw new Error('nooooooooo not a string');
8989 }
9090 name = name.trim().replace(/[\s_]+/g, '_');
 91+
 92+ // Implement int: as alias for MediaWiki:
 93+ if ( name.substr( 0, 4 ) === 'int:' ) {
 94+ name = 'MediaWiki:' + name.substr( 4 );
 95+ }
 96+
 97+ // FIXME: Generalize namespace case normalization
 98+ if ( name.substr( 0, 10 ).toLowerCase() === 'mediawiki:' ) {
 99+ name = 'MediaWiki:' + name.substr( 10 );
 100+ }
 101+
91102 function upperFirst( s ) { return s.substr(0, 1).toUpperCase() + s.substr(1); }
92103 name = name.split(':').map( upperFirst ).join(':');
93104 //if (name === '') {

Status & tagging log