return result;
}
+ // <nowiki>...</nowiki> tag. The tags are stripped and the contents are returned unparsed.
+ function nowiki() {
+ var parsedResult, plainText,
+ result = null;
+
+ parsedResult = sequence( [
+ makeStringParser( '<nowiki>' ),
+ // We use a greedy non-backtracking parser, so we must ensure here that we don't take too much
+ makeRegexParser( /^.*?(?=<\/nowiki>)/ ),
+ makeStringParser( '</nowiki>' )
+ ] );
+ if ( parsedResult !== null ) {
+ plainText = parsedResult[ 1 ];
+ result = [ 'CONCAT' ].concat( plainText );
+ }
+
+ return result;
+ }
+
templateName = transform(
// see $wgLegalTitleChars
// not allowing : due to the need to catch "PLURAL:$1"
wikilink,
extlink,
replacement,
+ nowiki,
html,
literal
] );
);
} );
+ QUnit.test( 'Nowiki', 3, function ( assert ) {
+ mw.messages.set( 'jquerymsg-nowiki-link', 'Foo <nowiki>[[bar]]</nowiki> baz.' );
+ assert.equal(
+ formatParse( 'jquerymsg-nowiki-link' ),
+ 'Foo [[bar]] baz.',
+ 'Link inside nowiki is not parsed'
+ );
+
+ mw.messages.set( 'jquerymsg-nowiki-htmltag', 'Foo <nowiki><b>bar</b></nowiki> baz.' );
+ assert.equal(
+ formatParse( 'jquerymsg-nowiki-htmltag' ),
+ 'Foo <b>bar</b> baz.',
+ 'HTML inside nowiki is not parsed and escaped'
+ );
+
+ mw.messages.set( 'jquerymsg-nowiki-template', 'Foo <nowiki>{{bar}}</nowiki> baz.' );
+ assert.equal(
+ formatParse( 'jquerymsg-nowiki-template' ),
+ 'Foo {{bar}} baz.',
+ 'Template inside nowiki is not parsed and does not cause a parse error'
+ );
+ } );
+
QUnit.test( 'Behavior in case of invalid wikitext', 3, function ( assert ) {
mw.messages.set( 'invalid-wikitext', '<b>{{FAIL}}</b>' );