| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
const slice = Array.prototype.slice, |
| 28 |
util = require( 'mediawiki.util' ), |
| 29 |
mwString = require( 'mediawiki.String' ), |
| 30 |
parserDefaults = { |
| 31 |
|
| 32 |
magic: { |
| 33 |
PAGENAME: mw.config.get( 'wgPageName' ), |
| 34 |
PAGENAMEE: util.wikiUrlencode( mw.config.get( 'wgPageName' ) ), |
| 35 |
SERVERNAME: mw.config.get( 'wgServerName' ), |
| 36 |
CONTENTLANGUAGE: mw.config.get( 'wgContentLanguage' ) |
| 37 |
}, |
| 38 |
|
| 39 |
|
| 40 |
allowedHtmlElements: [], |
| 41 |
|
| 42 |
|
| 43 |
allowedSelfClosingHtmlElements: [ |
| 44 |
'br', |
| 45 |
'wbr', |
| 46 |
'hr' |
| 47 |
], |
| 48 |
|
| 49 |
|
| 50 |
allowedHtmlCommonAttributes: [ |
| 51 |
|
| 52 |
'id', |
| 53 |
'class', |
| 54 |
|
| 55 |
'lang', |
| 56 |
'dir', |
| 57 |
'title', |
| 58 |
|
| 59 |
|
| 60 |
'role' |
| 61 |
], |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
allowedHtmlAttributesByElement: {}, |
| 67 |
messages: mw.messages, |
| 68 |
language: mw.language, |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
format: 'parse' |
| 80 |
}; |
| 81 |
|
| 82 |
|
| 83 |
$.extend( true, parserDefaults, require( './parserDefaults.json' ) ); |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
function appendWithoutParsing( $parent, children ) { |
| 100 |
let i, len; |
| 101 |
|
| 102 |
if ( !Array.isArray( children ) ) { |
| 103 |
children = [ children ]; |
| 104 |
} |
| 105 |
|
| 106 |
for ( i = 0, len = children.length; i < len; i++ ) { |
| 107 |
if ( typeof children[ i ] !== 'object' ) { |
| 108 |
children[ i ] = document.createTextNode( children[ i ] ); |
| 109 |
} |
| 110 |
if ( children[ i ] instanceof $ && children[ i ].hasClass( 'mediaWiki_htmlEmitter' ) ) { |
| 111 |
children[ i ] = children[ i ].contents(); |
| 112 |
} |
| 113 |
} |
| 114 |
|
| 115 |
return $parent.append( children ); |
| 116 |
} |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
function decodePrimaryHtmlEntities( encoded ) { |
| 126 |
return encoded |
| 127 |
.replace( /'/g, '\'' ) |
| 128 |
.replace( /"/g, '"' ) |
| 129 |
.replace( /</g, '<' ) |
| 130 |
.replace( />/g, '>' ) |
| 131 |
.replace( /&/g, '&' ); |
| 132 |
} |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
function textify( input ) { |
| 142 |
if ( input instanceof $ ) { |
| 143 |
input = input.text(); |
| 144 |
} |
| 145 |
return String( input ); |
| 146 |
} |
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
function getFailableParserFn( options ) { |
| 162 |
return function ( args ) { |
| 163 |
const parser = new Parser( options ), |
| 164 |
key = args[ 0 ], |
| 165 |
argsArray = Array.isArray( args[ 1 ] ) ? args[ 1 ] : slice.call( args, 1 ); |
| 166 |
try { |
| 167 |
return parser.parse( key, argsArray ); |
| 168 |
} catch ( e ) { |
| 169 |
const fallback = parser.settings.messages.get( key ); |
| 170 |
mw.log.warn( 'mediawiki.jqueryMsg: ' + key + ': ' + e.message ); |
| 171 |
mw.track( 'mediawiki.jqueryMsg.error', { |
| 172 |
messageKey: key, |
| 173 |
errorMessage: e.message |
| 174 |
} ); |
| 175 |
return $( '<span>' ).text( fallback ); |
| 176 |
} |
| 177 |
}; |
| 178 |
} |
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
const setParserDefaults = function ( data ) { |
| 190 |
Object.assign( parserDefaults, data ); |
| 191 |
}; |
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
const getParserDefaults = function () { |
| 202 |
return Object.assign( {}, parserDefaults ); |
| 203 |
}; |
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
const defaultMessageFunction = function ( options ) { |
| 213 |
let failableParserFn, format; |
| 214 |
|
| 215 |
if ( options && options.format !== undefined ) { |
| 216 |
format = options.format; |
| 217 |
} else { |
| 218 |
format = parserDefaults.format; |
| 219 |
} |
| 220 |
|
| 221 |
return function () { |
| 222 |
if ( !failableParserFn ) { |
| 223 |
failableParserFn = getFailableParserFn( options ); |
| 224 |
} |
| 225 |
const $result = failableParserFn( arguments ); |
| 226 |
if ( format === 'text' || format === 'escaped' ) { |
| 227 |
return $result.text(); |
| 228 |
} else { |
| 229 |
return $result.html(); |
| 230 |
} |
| 231 |
}; |
| 232 |
}; |
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
let messageFunction = defaultMessageFunction; |
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
const getMessageFunction = function ( options ) { |
| 245 |
return messageFunction( options ); |
| 246 |
}; |
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
const setMessageFunction = function ( msgFunction ) { |
| 256 |
messageFunction = msgFunction; |
| 257 |
return function () { |
| 258 |
messageFunction = defaultMessageFunction; |
| 259 |
}; |
| 260 |
}; |
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
const getPlugin = function ( options ) { |
| 270 |
let failableParserFn; |
| 271 |
|
| 272 |
return function () { |
| 273 |
if ( !failableParserFn ) { |
| 274 |
failableParserFn = getFailableParserFn( options ); |
| 275 |
} |
| 276 |
const $result = failableParserFn( arguments ); |
| 277 |
return this.empty().append( $result.contents() ); |
| 278 |
}; |
| 279 |
}; |
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
function Parser( options ) { |
| 290 |
this.settings = Object.assign( {}, parserDefaults, options ); |
| 291 |
this.settings.onlyCurlyBraceTransform = ( this.settings.format === 'text' || this.settings.format === 'escaped' ); |
| 292 |
this.astCache = {}; |
| 293 |
|
| 294 |
this.emitter = new HtmlEmitter( this.settings.language, this.settings.magic ); |
| 295 |
} |
| 296 |
|
| 297 |
Parser.prototype = { |
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
parse: function ( key, replacements ) { |
| 308 |
const ast = this.getAst( key, replacements ); |
| 309 |
return this.emitter.emit( ast, replacements ); |
| 310 |
}, |
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
ere. |
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
sing |
| 319 |
|
| 320 |
getAst: function ( key, replacements ) { |
| 321 |
if ( !Object.prototype.hasOwnProperty.call( this.astCache, key ) ) { |
| 322 |
let wikiText = this.settings.messages.get( key ); |
| 323 |
|
| 324 |
if ( |
| 325 |
mw.config.get( 'wgUserLanguage' ) === 'qqx' && |
| 326 |
( !wikiText || wikiText === '(' + key + ')' ) |
| 327 |
) { |
| 328 |
wikiText = '(' + key + '$*)'; |
| 329 |
} else if ( typeof wikiText !== 'string' ) { |
| 330 |
wikiText = 'â§¼' + key + 'â§½'; |
| 331 |
} |
| 332 |
wikiText = mw.internalDoTransformFormatForQqx( wikiText, replacements ); |
| 333 |
this.astCache[ key ] = this.wikiTextToAst( wikiText ); |
| 334 |
} |
| 335 |
return this.astCache[ key ]; |
| 336 |
}, |
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
wikiTextToAst: function ( input ) { |
| 349 |
let nonWhitespaceExpression = null, expression = null, templateContents = null, paramExpression = null, colon = null; |
| 350 |
const settings = this.settings; |
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
let pos = 0; |
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
function choice( ps ) { |
| 368 |
return function () { |
| 369 |
let i, result; |
| 370 |
for ( i = 0; i < ps.length; i++ ) { |
| 371 |
result = ps[ i ](); |
| 372 |
if ( result !== null ) { |
| 373 |
return result; |
| 374 |
} |
| 375 |
} |
| 376 |
return null; |
| 377 |
}; |
| 378 |
} |
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
function sequence( ps ) { |
| 389 |
const originalPos = pos, |
| 390 |
result = []; |
| 391 |
for ( let i = 0; i < ps.length; i++ ) { |
| 392 |
const r = ps[ i ](); |
| 393 |
if ( r === null ) { |
| 394 |
pos = originalPos; |
| 395 |
return null; |
| 396 |
} |
| 397 |
result.push( r ); |
| 398 |
} |
| 399 |
return result; |
| 400 |
} |
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
function nOrMore( n, p ) { |
| 412 |
return function () { |
| 413 |
const originalPos = pos, |
| 414 |
result = []; |
| 415 |
let parsed = p(); |
| 416 |
while ( parsed !== null ) { |
| 417 |
result.push( parsed ); |
| 418 |
parsed = p(); |
| 419 |
} |
| 420 |
if ( result.length < n ) { |
| 421 |
pos = originalPos; |
| 422 |
return null; |
| 423 |
} |
| 424 |
return result; |
| 425 |
}; |
| 426 |
} |
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
function makeStringParser( s ) { |
| 436 |
const len = s.length; |
| 437 |
return function () { |
| 438 |
let result = null; |
| 439 |
if ( input.slice( pos, pos + len ) === s ) { |
| 440 |
result = s; |
| 441 |
pos += len; |
| 442 |
} |
| 443 |
return result; |
| 444 |
}; |
| 445 |
} |
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
function makeRegexParser( regex ) { |
| 457 |
return function () { |
| 458 |
const matches = input.slice( pos ).match( regex ); |
| 459 |
if ( matches === null ) { |
| 460 |
return null; |
| 461 |
} |
| 462 |
pos += matches[ 0 ].length; |
| 463 |
return matches[ 0 ]; |
| 464 |
}; |
| 465 |
} |
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
const regularLiteral = makeRegexParser( /^[^{}\[\]$<\\]/ ); |
| 484 |
const regularLiteralWithoutBar = makeRegexParser( /^[^{}\[\]$\\|]/ ); |
| 485 |
const regularLiteralWithoutSpace = makeRegexParser( /^[^{}\[\]$\s]/ ); |
| 486 |
|
| 487 |
|
| 488 |
const backslash = makeStringParser( '\\' ); |
| 489 |
const anyCharacter = makeRegexParser( /^./ ); |
| 490 |
function escapedLiteral() { |
| 491 |
const result = sequence( [ |
| 492 |
backslash, |
| 493 |
anyCharacter |
| 494 |
] ); |
| 495 |
return result === null ? null : result[ 1 ]; |
| 496 |
} |
| 497 |
const escapedOrLiteralWithoutSpace = choice( [ |
| 498 |
escapedLiteral, |
| 499 |
regularLiteralWithoutSpace |
| 500 |
] ); |
| 501 |
const escapedOrLiteralWithoutBar = choice( [ |
| 502 |
escapedLiteral, |
| 503 |
regularLiteralWithoutBar |
| 504 |
] ); |
| 505 |
const escapedOrRegularLiteral = choice( [ |
| 506 |
escapedLiteral, |
| 507 |
regularLiteral |
| 508 |
] ); |
| 509 |
|
| 510 |
function literalWithoutSpace() { |
| 511 |
const result = nOrMore( 1, escapedOrLiteralWithoutSpace )(); |
| 512 |
return result === null ? null : result.join( '' ); |
| 513 |
} |
| 514 |
|
| 515 |
|
| 516 |
function literalWithoutBar() { |
| 517 |
const result = nOrMore( 1, escapedOrLiteralWithoutBar )(); |
| 518 |
return result === null ? null : result.join( '' ); |
| 519 |
} |
| 520 |
|
| 521 |
function literal() { |
| 522 |
const result = nOrMore( 1, escapedOrRegularLiteral )(); |
| 523 |
return result === null ? null : result.join( '' ); |
| 524 |
} |
| 525 |
|
| 526 |
const asciiAlphabetLiteral = makeRegexParser( /^[A-Za-z]+/ ); |
| 527 |
|
| 528 |
const whitespace = makeRegexParser( /^\s+/ ); |
| 529 |
|
| 530 |
const dollar = makeStringParser( '$' ); |
| 531 |
const digits = makeRegexParser( /^\d+/ ); |
| 532 |
function replacement() { |
| 533 |
const result = sequence( [ |
| 534 |
dollar, |
| 535 |
digits |
| 536 |
] ); |
| 537 |
if ( result === null ) { |
| 538 |
return null; |
| 539 |
} |
| 540 |
return [ 'REPLACE', parseInt( result[ 1 ], 10 ) - 1 ]; |
| 541 |
} |
| 542 |
const openExtlink = makeStringParser( '[' ); |
| 543 |
const closeExtlink = makeStringParser( ']' ); |
| 544 |
|
| 545 |
function extlink() { |
| 546 |
const parsedResult = sequence( [ |
| 547 |
openExtlink, |
| 548 |
nOrMore( 1, nonWhitespaceExpression ), |
| 549 |
whitespace, |
| 550 |
nOrMore( 1, expression ), |
| 551 |
closeExtlink |
| 552 |
] ); |
| 553 |
if ( parsedResult === null ) { |
| 554 |
return null; |
| 555 |
} |
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
const target = parsedResult[ 1 ].length === 1 ? |
| 561 |
parsedResult[ 1 ][ 0 ] : |
| 562 |
[ 'CONCAT' ].concat( parsedResult[ 1 ] ); |
| 563 |
return [ |
| 564 |
'EXTLINK', |
| 565 |
target, |
| 566 |
[ 'CONCAT' ].concat( parsedResult[ 3 ] ) |
| 567 |
]; |
| 568 |
} |
| 569 |
const pipe = makeStringParser( '|' ); |
| 570 |
|
| 571 |
const openTemplate = makeStringParser( '{{' ); |
| 572 |
const closeTemplate = makeStringParser( '}}' ); |
| 573 |
function template() { |
| 574 |
const result = sequence( [ |
| 575 |
openTemplate, |
| 576 |
templateContents, |
| 577 |
closeTemplate |
| 578 |
] ); |
| 579 |
return result === null ? null : result[ 1 ]; |
| 580 |
} |
| 581 |
|
| 582 |
function templateName() { |
| 583 |
|
| 584 |
|
| 585 |
const templateNameRegex = makeRegexParser( /^#?[ !"$&'()*,./0-9;=?@A-Z^_`a-z~\x80-\xFF+-]+/ ); |
| 586 |
const result = templateNameRegex(); |
| 587 |
return result === null ? null : result.toString(); |
| 588 |
} |
| 589 |
|
| 590 |
function templateParam() { |
| 591 |
const result = sequence( [ |
| 592 |
pipe, |
| 593 |
nOrMore( 0, paramExpression ) |
| 594 |
] ); |
| 595 |
if ( result === null ) { |
| 596 |
return null; |
| 597 |
} |
| 598 |
const expr = result[ 1 ]; |
| 599 |
|
| 600 |
return expr.length > 1 ? [ 'CONCAT' ].concat( expr ) : expr[ 0 ]; |
| 601 |
} |
| 602 |
|
| 603 |
function templateNameWithParam() { |
| 604 |
const result = sequence( [ |
| 605 |
templateName, |
| 606 |
colon, |
| 607 |
nOrMore( 0, paramExpression ) |
| 608 |
] ); |
| 609 |
if ( result === null ) { |
| 610 |
return null; |
| 611 |
} |
| 612 |
const expr = result[ 2 ]; |
| 613 |
|
| 614 |
return [ result[ 0 ], expr.length > 1 ? [ 'CONCAT' ].concat( expr ) : expr[ 0 ] ]; |
| 615 |
} |
| 616 |
colon = makeStringParser( ':' ); |
| 617 |
templateContents = choice( [ |
| 618 |
function () { |
| 619 |
const result = sequence( [ |
| 620 |
templateNameWithParam, |
| 621 |
nOrMore( 0, templateParam ) |
| 622 |
] ); |
| 623 |
return result === null ? null : result[ 0 ].concat( result[ 1 ] ); |
| 624 |
}, |
| 625 |
function () { |
| 626 |
const result = sequence( [ |
| 627 |
templateName, |
| 628 |
nOrMore( 0, templateParam ) |
| 629 |
] ); |
| 630 |
if ( result === null ) { |
| 631 |
return null; |
| 632 |
} |
| 633 |
return [ result[ 0 ] ].concat( result[ 1 ] ); |
| 634 |
} |
| 635 |
] ); |
| 636 |
|
| 637 |
function pipedWikilink() { |
| 638 |
const result = sequence( [ |
| 639 |
nOrMore( 1, paramExpression ), |
| 640 |
pipe, |
| 641 |
nOrMore( 1, expression ) |
| 642 |
] ); |
| 643 |
return result === null ? null : [ |
| 644 |
[ 'CONCAT' ].concat( result[ 0 ] ), |
| 645 |
[ 'CONCAT' ].concat( result[ 2 ] ) |
| 646 |
]; |
| 647 |
} |
| 648 |
|
| 649 |
function unpipedWikilink() { |
| 650 |
const result = sequence( [ |
| 651 |
nOrMore( 1, paramExpression ) |
| 652 |
] ); |
| 653 |
return result === null ? null : [ |
| 654 |
[ 'CONCAT' ].concat( result[ 0 ] ) |
| 655 |
]; |
| 656 |
} |
| 657 |
|
| 658 |
const wikilinkContents = choice( [ |
| 659 |
pipedWikilink, |
| 660 |
unpipedWikilink |
| 661 |
] ); |
| 662 |
|
| 663 |
const openWikilink = makeStringParser( '[[' ); |
| 664 |
const closeWikilink = makeStringParser( ']]' ); |
| 665 |
function wikilink() { |
| 666 |
const parsedResult = sequence( [ |
| 667 |
openWikilink, |
| 668 |
wikilinkContents, |
| 669 |
closeWikilink |
| 670 |
] ); |
| 671 |
return parsedResult === null ? null : [ 'WIKILINK' ].concat( parsedResult[ 1 ] ); |
| 672 |
} |
| 673 |
|
| 674 |
|
| 675 |
const doubleQuote = makeStringParser( '"' ); |
| 676 |
const htmlDoubleQuoteAttributeValue = makeRegexParser( /^[^"]*/ ); |
| 677 |
function doubleQuotedHtmlAttributeValue() { |
| 678 |
const parsedResult = sequence( [ |
| 679 |
doubleQuote, |
| 680 |
htmlDoubleQuoteAttributeValue, |
| 681 |
doubleQuote |
| 682 |
] ); |
| 683 |
return parsedResult === null ? null : parsedResult[ 1 ]; |
| 684 |
} |
| 685 |
|
| 686 |
const singleQuote = makeStringParser( '\'' ); |
| 687 |
const htmlSingleQuoteAttributeValue = makeRegexParser( /^[^']*/ ); |
| 688 |
function singleQuotedHtmlAttributeValue() { |
| 689 |
const parsedResult = sequence( [ |
| 690 |
singleQuote, |
| 691 |
htmlSingleQuoteAttributeValue, |
| 692 |
singleQuote |
| 693 |
] ); |
| 694 |
return parsedResult === null ? null : parsedResult[ 1 ]; |
| 695 |
} |
| 696 |
|
| 697 |
const htmlAttributeEquals = makeRegexParser( /^\s*=\s*/ ); |
| 698 |
function htmlAttribute() { |
| 699 |
const parsedResult = sequence( [ |
| 700 |
whitespace, |
| 701 |
asciiAlphabetLiteral, |
| 702 |
htmlAttributeEquals, |
| 703 |
choice( [ |
| 704 |
doubleQuotedHtmlAttributeValue, |
| 705 |
singleQuotedHtmlAttributeValue |
| 706 |
] ) |
| 707 |
] ); |
| 708 |
return parsedResult === null ? null : [ parsedResult[ 1 ], parsedResult[ 3 ] ]; |
| 709 |
} |
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
function isAllowedHtml( startTagName, endTagName, attributes ) { |
| 722 |
startTagName = startTagName.toLowerCase(); |
| 723 |
const isSelfClosing = endTagName === null; |
| 724 |
if ( |
| 725 |
( isSelfClosing && settings.allowedSelfClosingHtmlElements.indexOf( startTagName ) === -1 ) || |
| 726 |
( !isSelfClosing && ( startTagName !== endTagName.toLowerCase() || settings.allowedHtmlElements.indexOf( startTagName ) === -1 ) ) |
| 727 |
) { |
| 728 |
return false; |
| 729 |
} |
| 730 |
|
| 731 |
let attributeName; |
| 732 |
for ( let i = 0, len = attributes.length; i < len; i += 2 ) { |
| 733 |
attributeName = attributes[ i ]; |
| 734 |
if ( settings.allowedHtmlCommonAttributes.indexOf( attributeName ) === -1 && |
| 735 |
( settings.allowedHtmlAttributesByElement[ startTagName ] || [] ).indexOf( attributeName ) === -1 ) { |
| 736 |
return false; |
| 737 |
} |
| 738 |
} |
| 739 |
|
| 740 |
return true; |
| 741 |
} |
| 742 |
|
| 743 |
function htmlAttributes() { |
| 744 |
const parsedResult = nOrMore( 0, htmlAttribute )(); |
| 745 |
|
| 746 |
return [ 'HTMLATTRIBUTES' ].concat( ...parsedResult ); |
| 747 |
} |
| 748 |
|
| 749 |
const openHtmlStartTag = makeStringParser( '<' ); |
| 750 |
const optionalWhitespace = makeRegexParser( /\s*/ ); |
| 751 |
const optionalForwardSlash = makeRegexParser( /^\/?/ ); |
| 752 |
const openHtmlEndTag = makeStringParser( '</' ); |
| 753 |
const closeHtmlTag = makeRegexParser( /^\s*>/ ); |
| 754 |
|
| 755 |
|
| 756 |
function html() { |
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
const startOpenTagPos = pos; |
| 764 |
const parsedOpenTagResult = sequence( [ |
| 765 |
openHtmlStartTag, |
| 766 |
asciiAlphabetLiteral, |
| 767 |
htmlAttributes, |
| 768 |
optionalWhitespace, |
| 769 |
optionalForwardSlash, |
| 770 |
closeHtmlTag |
| 771 |
] ); |
| 772 |
|
| 773 |
if ( parsedOpenTagResult === null ) { |
| 774 |
return null; |
| 775 |
} |
| 776 |
|
| 777 |
const endOpenTagPos = pos; |
| 778 |
const startTagName = parsedOpenTagResult[ 1 ]; |
| 779 |
const wrappedAttributes = parsedOpenTagResult[ 2 ]; |
| 780 |
const attributes = wrappedAttributes.slice( 1 ); |
| 781 |
|
| 782 |
|
| 783 |
if ( settings.allowedSelfClosingHtmlElements.indexOf( startTagName ) !== -1 ) { |
| 784 |
if ( isAllowedHtml( startTagName, null, attributes ) ) { |
| 785 |
return [ 'HTMLELEMENT', startTagName, wrappedAttributes ]; |
| 786 |
} |
| 787 |
return [ 'CONCAT', input.slice( startOpenTagPos, endOpenTagPos ) ]; |
| 788 |
} |
| 789 |
|
| 790 |
const parsedHtmlContents = nOrMore( 0, expression )(); |
| 791 |
|
| 792 |
const startCloseTagPos = pos; |
| 793 |
const parsedCloseTagResult = sequence( [ |
| 794 |
openHtmlEndTag, |
| 795 |
asciiAlphabetLiteral, |
| 796 |
closeHtmlTag |
| 797 |
] ); |
| 798 |
|
| 799 |
if ( parsedCloseTagResult === null ) { |
| 800 |
|
| 801 |
return [ 'CONCAT', input.slice( startOpenTagPos, endOpenTagPos ) ] |
| 802 |
.concat( parsedHtmlContents ); |
| 803 |
} |
| 804 |
|
| 805 |
const endCloseTagPos = pos; |
| 806 |
const endTagName = parsedCloseTagResult[ 1 ]; |
| 807 |
if ( isAllowedHtml( startTagName, endTagName, attributes ) ) { |
| 808 |
return [ 'HTMLELEMENT', startTagName, wrappedAttributes ] |
| 809 |
.concat( parsedHtmlContents ); |
| 810 |
} |
| 811 |
|
| 812 |
|
| 813 |
|
| 814 |
|
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
|
| 820 |
|
| 821 |
|
| 822 |
|
| 823 |
return [ 'CONCAT', input.slice( startOpenTagPos, endOpenTagPos ) ] |
| 824 |
.concat( parsedHtmlContents, input.slice( startCloseTagPos, endCloseTagPos ) ); |
| 825 |
} |
| 826 |
|
| 827 |
|
| 828 |
function nowiki() { |
| 829 |
const parsedResult = sequence( [ |
| 830 |
makeStringParser( '<nowiki>' ), |
| 831 |
|
| 832 |
makeRegexParser( /^.*?(?=<\/nowiki>)/ ), |
| 833 |
makeStringParser( '</nowiki>' ) |
| 834 |
] ); |
| 835 |
return parsedResult === null ? null : [ 'CONCAT' ].concat( parsedResult[ 1 ] ); |
| 836 |
} |
| 837 |
|
| 838 |
nonWhitespaceExpression = choice( [ |
| 839 |
template, |
| 840 |
wikilink, |
| 841 |
extlink, |
| 842 |
replacement, |
| 843 |
literalWithoutSpace |
| 844 |
] ); |
| 845 |
paramExpression = choice( [ |
| 846 |
template, |
| 847 |
wikilink, |
| 848 |
extlink, |
| 849 |
replacement, |
| 850 |
literalWithoutBar |
| 851 |
] ); |
| 852 |
|
| 853 |
expression = choice( [ |
| 854 |
template, |
| 855 |
wikilink, |
| 856 |
extlink, |
| 857 |
replacement, |
| 858 |
nowiki, |
| 859 |
html, |
| 860 |
literal |
| 861 |
] ); |
| 862 |
|
| 863 |
const regularLiteralWithSquareBrackets = makeRegexParser( /^[^{}$\\]/ ); |
| 864 |
function curlyBraceTransformExpressionLiteral() { |
| 865 |
const result = nOrMore( 1, regularLiteralWithSquareBrackets )(); |
| 866 |
return result === null ? null : result.join( '' ); |
| 867 |
} |
| 868 |
|
| 869 |
|
| 870 |
const curlyBraceTransformExpression = choice( [ |
| 871 |
template, |
| 872 |
replacement, |
| 873 |
curlyBraceTransformExpressionLiteral |
| 874 |
] ); |
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
|
| 879 |
|
| 880 |
|
| 881 |
|
| 882 |
|
| 883 |
function start( rootExpression ) { |
| 884 |
const result = nOrMore( 0, rootExpression )(); |
| 885 |
if ( result === null ) { |
| 886 |
return null; |
| 887 |
} |
| 888 |
return [ 'CONCAT' ].concat( result ); |
| 889 |
} |
| 890 |
|
| 891 |
|
| 892 |
|
| 893 |
|
| 894 |
const res = start( this.settings.onlyCurlyBraceTransform ? curlyBraceTransformExpression : expression ); |
| 895 |
|
| 896 |
|
| 897 |
|
| 898 |
|
| 899 |
|
| 900 |
|
| 901 |
if ( res === null || pos !== input.length ) { |
| 902 |
throw new Error( 'Parse error at position ' + pos.toString() + ' in input: ' + input ); |
| 903 |
} |
| 904 |
return res; |
| 905 |
} |
| 906 |
|
| 907 |
}; |
| 908 |
|
| 909 |
|
| 910 |
|
| 911 |
|
| 912 |
|
| 913 |
|
| 914 |
|
| 915 |
|
| 916 |
|
| 917 |
function HtmlEmitter( language, magic ) { |
| 918 |
const jmsg = this; |
| 919 |
this.language = language; |
| 920 |
Object.keys( magic || {} ).forEach( ( key ) => { |
| 921 |
const val = magic[ key ]; |
| 922 |
jmsg[ key.toLowerCase() ] = function () { |
| 923 |
return val; |
| 924 |
}; |
| 925 |
} ); |
| 926 |
|
| 927 |
|
| 928 |
|
| 929 |
|
| 930 |
|
| 931 |
|
| 932 |
|
| 933 |
|
| 934 |
|
| 935 |
this.emit = function ( node, replacements ) { |
| 936 |
switch ( typeof node ) { |
| 937 |
case 'string': |
| 938 |
case 'number': |
| 939 |
return node; |
| 940 |
|
| 941 |
|
| 942 |
case 'object': { |
| 943 |
|
| 944 |
|
| 945 |
const subnodes = $.map( node.slice( 1 ), ( n ) => jmsg.emit( n, replacements ) ); |
| 946 |
const operation = node[ 0 ].toLowerCase(); |
| 947 |
if ( typeof jmsg[ operation ] === 'function' ) { |
| 948 |
return jmsg[ operation ]( subnodes, replacements ); |
| 949 |
} else { |
| 950 |
throw new Error( 'Unknown operation "' + operation + '"' ); |
| 951 |
} |
| 952 |
} |
| 953 |
|
| 954 |
case 'undefined': |
| 955 |
|
| 956 |
|
| 957 |
|
| 958 |
return ''; |
| 959 |
|
| 960 |
default: |
| 961 |
throw new Error( 'Unexpected type in AST: ' + typeof node ); |
| 962 |
} |
| 963 |
}; |
| 964 |
} |
| 965 |
|
| 966 |
|
| 967 |
|
| 968 |
|
| 969 |
|
| 970 |
|
| 971 |
|
| 972 |
|
| 973 |
|
| 974 |
|
| 975 |
|
| 976 |
const strongDirRegExp = new RegExp( |
| 977 |
'(?:' + |
| 978 |
'(' + |
| 979 |
'[\u0041-\u005a\u0061-\u007a\u00aa\u00b5\u00ba\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02b8\u02bb-\u02c1\u02d0\u02d1\u02e0-\u02e4\u02ee\u0370-\u0373\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0482\u048a-\u052f\u0531-\u0556\u0559-\u055f\u0561-\u0587\u0589\u0903-\u0939\u093b\u093d-\u0940\u0949-\u094c\u094e-\u0950\u0958-\u0961\u0964-\u0980\u0982\u0983\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd-\u09c0\u09c7\u09c8\u09cb\u09cc\u09ce\u09d7\u09dc\u09dd\u09df-\u09e1\u09e6-\u09f1\u09f4-\u09fa\u0a03\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a3e-\u0a40\u0a59-\u0a5c\u0a5e\u0a66-\u0a6f\u0a72-\u0a74\u0a83\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd-\u0ac0\u0ac9\u0acb\u0acc\u0ad0\u0ae0\u0ae1\u0ae6-\u0af0\u0af9\u0b02\u0b03\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b3e\u0b40\u0b47\u0b48\u0b4b\u0b4c\u0b57\u0b5c\u0b5d\u0b5f-\u0b61\u0b66-\u0b77\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bbe\u0bbf\u0bc1\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcc\u0bd0\u0bd7\u0be6-\u0bf2\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c41-\u0c44\u0c58-\u0c5a\u0c60\u0c61\u0c66-\u0c6f\u0c7f\u0c82\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd-\u0cc4\u0cc6-\u0cc8\u0cca\u0ccb\u0cd5\u0cd6\u0cde\u0ce0\u0ce1\u0ce6-\u0cef\u0cf1\u0cf2\u0d02\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d40\u0d46-\u0d48\u0d4a-\u0d4c\u0d4e\u0d57\u0d5f-\u0d61\u0d66-\u0d75\u0d79-\u0d7f\u0d82\u0d83\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0dcf-\u0dd1\u0dd8-\u0ddf\u0de6-\u0def\u0df2-\u0df4\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e4f-\u0e5b\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0ed0-\u0ed9\u0edc-\u0edf\u0f00-\u0f17\u0f1a-\u0f34\u0f36\u0f38\u0f3e-\u0f47\u0f49-\u0f6c\u0f7f\u0f85\u0f88-\u0f8c\u0fbe-\u0fc5\u0fc7-\u0fcc\u0fce-\u0fda\u1000-\u102c\u1031\u1038\u103b\u103c\u103f-\u1057\u105a-\u105d\u1061-\u1070\u1075-\u1081\u1083\u1084\u1087-\u108c\u108e-\u109c\u109e-\u10c5\u10c7\u10cd\u10d0-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1360-\u137c\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u167f\u1681-\u169a\u16a0-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1735\u1736\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17b6\u17be-\u17c5\u17c7\u17c8\u17d4-\u17da\u17dc\u17e0-\u17e9\u1810-\u1819\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1923-\u1926\u1929-\u192b\u1930\u1931\u1933-\u1938\u1946-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u19d0-\u19da\u1a00-\u1a16\u1a19\u1a1a\u1a1e-\u1a55\u1a57\u1a61\u1a63\u1a64\u1a6d-\u1a72\u1a80-\u1a89\u1a90-\u1a99\u1aa0-\u1aad\u1b04-\u1b33\u1b35\u1b3b\u1b3d-\u1b41\u1b43-\u1b4b\u1b50-\u1b6a\u1b74-\u1b7c\u1b82-\u1ba1\u1ba6\u1ba7\u1baa\u1bae-\u1be5\u1be7\u1bea-\u1bec\u1bee\u1bf2\u1bf3\u1bfc-\u1c2b\u1c34\u1c35\u1c3b-\u1c49\u1c4d-\u1c7f\u1cc0-\u1cc7\u1cd3\u1ce1\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u200e\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u214f\u2160-\u2188\u2336-\u237a\u2395\u249c-\u24e9\u26ac\u2800-\u28ff\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d70\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u302e\u302f\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u3190-\u31ba\u31f0-\u321c\u3220-\u324f\u3260-\u327b\u327f-\u32b0\u32c0-\u32cb\u32d0-\u32fe\u3300-\u3376\u337b-\u33dd\u33e0-\u33fe\u3400-\u4db5\u4e00-\u9fd5\ua000-\ua48c\ua4d0-\ua60c\ua610-\ua62b\ua640-\ua66e\ua680-\ua69d\ua6a0-\ua6ef\ua6f2-\ua6f7\ua722-\ua787\ua789-\ua7ad\ua7b0-\ua7b7\ua7f7-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua824\ua827\ua830-\ua837\ua840-\ua873\ua880-\ua8c3\ua8ce-\ua8d9\ua8f2-\ua8fd\ua900-\ua925\ua92e-\ua946\ua952\ua953\ua95f-\ua97c\ua983-\ua9b2\ua9b4\ua9b5\ua9ba\ua9bb\ua9bd-\ua9cd\ua9cf-\ua9d9\ua9de-\ua9e4\ua9e6-\ua9fe\uaa00-\uaa28\uaa2f\uaa30\uaa33\uaa34\uaa40-\uaa42\uaa44-\uaa4b\uaa4d\uaa50-\uaa59\uaa5c-\uaa7b\uaa7d-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaaeb\uaaee-\uaaf5\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab65\uab70-\uabe4\uabe6\uabe7\uabe9-\uabec\uabf0-\uabf9\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\ue000-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]|\ud800[\udc00-\udc0b]|\ud800[\udc0d-\udc26]|\ud800[\udc28-\udc3a]|\ud800\udc3c|\ud800\udc3d|\ud800[\udc3f-\udc4d]|\ud800[\udc50-\udc5d]|\ud800[\udc80-\udcfa]|\ud800\udd00|\ud800\udd02|\ud800[\udd07-\udd33]|\ud800[\udd37-\udd3f]|\ud800[\uddd0-\uddfc]|\ud800[\ude80-\ude9c]|\ud800[\udea0-\uded0]|\ud800[\udf00-\udf23]|\ud800[\udf30-\udf4a]|\ud800[\udf50-\udf75]|\ud800[\udf80-\udf9d]|\ud800[\udf9f-\udfc3]|\ud800[\udfc8-\udfd5]|\ud801[\udc00-\udc9d]|\ud801[\udca0-\udca9]|\ud801[\udd00-\udd27]|\ud801[\udd30-\udd63]|\ud801\udd6f|\ud801[\ude00-\udf36]|\ud801[\udf40-\udf55]|\ud801[\udf60-\udf67]|\ud804\udc00|\ud804[\udc02-\udc37]|\ud804[\udc47-\udc4d]|\ud804[\udc66-\udc6f]|\ud804[\udc82-\udcb2]|\ud804\udcb7|\ud804\udcb8|\ud804[\udcbb-\udcc1]|\ud804[\udcd0-\udce8]|\ud804[\udcf0-\udcf9]|\ud804[\udd03-\udd26]|\ud804\udd2c|\ud804[\udd36-\udd43]|\ud804[\udd50-\udd72]|\ud804[\udd74-\udd76]|\ud804[\udd82-\uddb5]|\ud804[\uddbf-\uddc9]|\ud804\uddcd|\ud804[\uddd0-\udddf]|\ud804[\udde1-\uddf4]|\ud804[\ude00-\ude11]|\ud804[\ude13-\ude2e]|\ud804\ude32|\ud804\ude33|\ud804\ude35|\ud804[\ude38-\ude3d]|\ud804[\ude80-\ude86]|\ud804\ude88|\ud804[\ude8a-\ude8d]|\ud804[\ude8f-\ude9d]|\ud804[\ude9f-\udea9]|\ud804[\udeb0-\udede]|\ud804[\udee0-\udee2]|\ud804[\udef0-\udef9]|\ud804\udf02|\ud804\udf03|\ud804[\udf05-\udf0c]|\ud804\udf0f|\ud804\udf10|\ud804[\udf13-\udf28]|\ud804[\udf2a-\udf30]|\ud804\udf32|\ud804\udf33|\ud804[\udf35-\udf39]|\ud804[\udf3d-\udf3f]|\ud804[\udf41-\udf44]|\ud804\udf47|\ud804\udf48|\ud804[\udf4b-\udf4d]|\ud804\udf50|\ud804\udf57|\ud804[\udf5d-\udf63]|\ud805[\udc80-\udcb2]|\ud805\udcb9|\ud805[\udcbb-\udcbe]|\ud805\udcc1|\ud805[\udcc4-\udcc7]|\ud805[\udcd0-\udcd9]|\ud805[\udd80-\uddb1]|\ud805[\uddb8-\uddbb]|\ud805\uddbe|\ud805[\uddc1-\udddb]|\ud805[\ude00-\ude32]|\ud805\ude3b|\ud805\ude3c|\ud805\ude3e|\ud805[\ude41-\ude44]|\ud805[\ude50-\ude59]|\ud805[\ude80-\udeaa]|\ud805\udeac|\ud805\udeae|\ud805\udeaf|\ud805\udeb6|\ud805[\udec0-\udec9]|\ud805[\udf00-\udf19]|\ud805\udf20|\ud805\udf21|\ud805\udf26|\ud805[\udf30-\udf3f]|\ud806[\udca0-\udcf2]|\ud806\udcff|\ud806[\udec0-\udef8]|\ud808[\udc00-\udf99]|\ud809[\udc00-\udc6e]|\ud809[\udc70-\udc74]|\ud809[\udc80-\udd43]|\ud80c[\udc00-\udfff]|\ud80d[\udc00-\udc2e]|\ud811[\udc00-\ude46]|\ud81a[\udc00-\ude38]|\ud81a[\ude40-\ude5e]|\ud81a[\ude60-\ude69]|\ud81a\ude6e|\ud81a\ude6f|\ud81a[\uded0-\udeed]|\ud81a\udef5|\ud81a[\udf00-\udf2f]|\ud81a[\udf37-\udf45]|\ud81a[\udf50-\udf59]|\ud81a[\udf5b-\udf61]|\ud81a[\udf63-\udf77]|\ud81a[\udf7d-\udf8f]|\ud81b[\udf00-\udf44]|\ud81b[\udf50-\udf7e]|\ud81b[\udf93-\udf9f]|\ud82c\udc00|\ud82c\udc01|\ud82f[\udc00-\udc6a]|\ud82f[\udc70-\udc7c]|\ud82f[\udc80-\udc88]|\ud82f[\udc90-\udc99]|\ud82f\udc9c|\ud82f\udc9f|\ud834[\udc00-\udcf5]|\ud834[\udd00-\udd26]|\ud834[\udd29-\udd66]|\ud834[\udd6a-\udd72]|\ud834\udd83|\ud834\udd84|\ud834[\udd8c-\udda9]|\ud834[\uddae-\udde8]|\ud834[\udf60-\udf71]|\ud835[\udc00-\udc54]|\ud835[\udc56-\udc9c]|\ud835\udc9e|\ud835\udc9f|\ud835\udca2|\ud835\udca5|\ud835\udca6|\ud835[\udca9-\udcac]|\ud835[\udcae-\udcb9]|\ud835\udcbb|\ud835[\udcbd-\udcc3]|\ud835[\udcc5-\udd05]|\ud835[\udd07-\udd0a]|\ud835[\udd0d-\udd14]|\ud835[\udd16-\udd1c]|\ud835[\udd1e-\udd39]|\ud835[\udd3b-\udd3e]|\ud835[\udd40-\udd44]|\ud835\udd46|\ud835[\udd4a-\udd50]|\ud835[\udd52-\udea5]|\ud835[\udea8-\udeda]|\ud835[\udedc-\udf14]|\ud835[\udf16-\udf4e]|\ud835[\udf50-\udf88]|\ud835[\udf8a-\udfc2]|\ud835[\udfc4-\udfcb]|\ud836[\udc00-\uddff]|\ud836[\ude37-\ude3a]|\ud836[\ude6d-\ude74]|\ud836[\ude76-\ude83]|\ud836[\ude85-\ude8b]|\ud83c[\udd10-\udd2e]|\ud83c[\udd30-\udd69]|\ud83c[\udd70-\udd9a]|\ud83c[\udde6-\ude02]|\ud83c[\ude10-\ude3a]|\ud83c[\ude40-\ude48]|\ud83c\ude50|\ud83c\ude51|[\ud840-\ud868][\udc00-\udfff]|\ud869[\udc00-\uded6]|\ud869[\udf00-\udfff]|[\ud86a-\ud86c][\udc00-\udfff]|\ud86d[\udc00-\udf34]|\ud86d[\udf40-\udfff]|\ud86e[\udc00-\udc1d]|\ud86e[\udc20-\udfff]|[\ud86f-\ud872][\udc00-\udfff]|\ud873[\udc00-\udea1]|\ud87e[\udc00-\ude1d]|[\udb80-\udbbe][\udc00-\udfff]|\udbbf[\udc00-\udffd]|[\udbc0-\udbfe][\udc00-\udfff]|\udbff[\udc00-\udffd]' + |
| 980 |
')|(' + |
| 981 |
'[\u0590\u05be\u05c0\u05c3\u05c6\u05c8-\u05ff\u07c0-\u07ea\u07f4\u07f5\u07fa-\u0815\u081a\u0824\u0828\u082e-\u0858\u085c-\u089f\u200f\ufb1d\ufb1f-\ufb28\ufb2a-\ufb4f\u0608\u060b\u060d\u061b-\u064a\u066d-\u066f\u0671-\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u0710\u0712-\u072f\u074b-\u07a5\u07b1-\u07bf\u08a0-\u08e2\ufb50-\ufd3d\ufd40-\ufdcf\ufdf0-\ufdfc\ufdfe\ufdff\ufe70-\ufefe]|\ud802[\udc00-\udd1e]|\ud802[\udd20-\ude00]|\ud802\ude04|\ud802[\ude07-\ude0b]|\ud802[\ude10-\ude37]|\ud802[\ude3b-\ude3e]|\ud802[\ude40-\udee4]|\ud802[\udee7-\udf38]|\ud802[\udf40-\udfff]|\ud803[\udc00-\ude5f]|\ud803[\ude7f-\udfff]|\ud83a[\udc00-\udccf]|\ud83a[\udcd7-\udfff]|\ud83b[\udc00-\uddff]|\ud83b[\udf00-\udfff]|\ud83b[\udf00-\udfff]|\ud83b[\udf00-\udfff]|\ud83b[\udf00-\udfff]|\ud83b[\udf00-\udfff]|\ud83b[\udf00-\udfff]|\ud83b[\udf00-\udfff]|\ud83b[\udf00-\udfff]|\ud83b[\udf00-\udfff]|\ud83b[\udf00-\udfff]|\ud83b[\udf00-\udfff]|\ud83b[\udf00-\udfff]|\ud83b[\udf00-\udfff]|\ud83b[\ude00-\udeef]|\ud83b[\udef2-\udeff]' + |
| 982 |
')' + |
| 983 |
')' |
| 984 |
); |
| 985 |
|
| 986 |
|
| 987 |
|
| 988 |
|
| 989 |
|
| 990 |
|
| 991 |
|
| 992 |
|
| 993 |
|
| 994 |
|
| 995 |
|
| 996 |
|
| 997 |
|
| 998 |
|
| 999 |
|
| 1000 |
function strongDirFromContent( text ) { |
| 1001 |
const m = text.match( strongDirRegExp ); |
| 1002 |
if ( !m ) { |
| 1003 |
return null; |
| 1004 |
} |
| 1005 |
if ( m[ 2 ] === undefined ) { |
| 1006 |
return 'ltr'; |
| 1007 |
} |
| 1008 |
return 'rtl'; |
| 1009 |
} |
| 1010 |
|
| 1011 |
|
| 1012 |
|
| 1013 |
|
| 1014 |
|
| 1015 |
|
| 1016 |
|
| 1017 |
HtmlEmitter.prototype = { |
| 1018 |
|
| 1019 |
|
| 1020 |
|
| 1021 |
|
| 1022 |
|
| 1023 |
|
| 1024 |
|
| 1025 |
|
| 1026 |
concat: function ( nodes ) { |
| 1027 |
const $span = $( '<span>' ).addClass( 'mediaWiki_htmlEmitter' ); |
| 1028 |
|
| 1029 |
Array.from( nodes ).forEach( ( node ) => { |
| 1030 |
|
| 1031 |
|
| 1032 |
appendWithoutParsing( $span, node ); |
| 1033 |
} ); |
| 1034 |
return $span; |
| 1035 |
}, |
| 1036 |
|
| 1037 |
|
| 1038 |
|
| 1039 |
|
| 1040 |
|
| 1041 |
|
| 1042 |
|
| 1043 |
|
| 1044 |
|
| 1045 |
|
| 1046 |
|
| 1047 |
|
| 1048 |
|
| 1049 |
|
| 1050 |
|
| 1051 |
|
| 1052 |
|
| 1053 |
|
| 1054 |
|
| 1055 |
replace: function ( nodes, replacements ) { |
| 1056 |
const index = parseInt( nodes[ 0 ], 10 ); |
| 1057 |
|
| 1058 |
if ( index < replacements.length ) { |
| 1059 |
if ( typeof replacements[ index ] === 'object' ) { |
| 1060 |
|
| 1061 |
if ( !replacements[ index ].mwJQueryMsgHasAlreadyBeenUsedAsAReplacement ) { |
| 1062 |
|
| 1063 |
|
| 1064 |
Object.defineProperty( |
| 1065 |
replacements[ index ], |
| 1066 |
'mwJQueryMsgHasAlreadyBeenUsedAsAReplacement', |
| 1067 |
{ |
| 1068 |
value: true, |
| 1069 |
enumerable: false, |
| 1070 |
writable: false |
| 1071 |
} |
| 1072 |
); |
| 1073 |
return replacements[ index ]; |
| 1074 |
} |
| 1075 |
if ( typeof replacements[ index ].clone === 'function' ) { |
| 1076 |
|
| 1077 |
return replacements[ index ].clone( true ); |
| 1078 |
} |
| 1079 |
if ( typeof replacements[ index ].cloneNode === 'function' ) { |
| 1080 |
|
| 1081 |
return replacements[ index ].cloneNode( true ); |
| 1082 |
} |
| 1083 |
return replacements[ index ]; |
| 1084 |
} |
| 1085 |
return replacements[ index ]; |
| 1086 |
} else { |
| 1087 |
|
| 1088 |
return '$' + ( index + 1 ); |
| 1089 |
} |
| 1090 |
}, |
| 1091 |
|
| 1092 |
|
| 1093 |
|
| 1094 |
|
| 1095 |
|
| 1096 |
|
| 1097 |
|
| 1098 |
|
| 1099 |
|
| 1100 |
|
| 1101 |
|
| 1102 |
|
| 1103 |
|
| 1104 |
|
| 1105 |
|
| 1106 |
|
| 1107 |
wikilink: function ( nodes ) { |
| 1108 |
let page = textify( nodes[ 0 ] ); |
| 1109 |
|
| 1110 |
|
| 1111 |
if ( page.charAt( 0 ) === ':' ) { |
| 1112 |
page = page.slice( 1 ); |
| 1113 |
} |
| 1114 |
const title = new mw.Title( page ); |
| 1115 |
|
| 1116 |
let anchor; |
| 1117 |
if ( nodes.length === 1 ) { |
| 1118 |
|
| 1119 |
anchor = page; |
| 1120 |
} else { |
| 1121 |
|
| 1122 |
anchor = nodes[ 1 ]; |
| 1123 |
} |
| 1124 |
|
| 1125 |
const $el = $( '<a>' ).attr( { |
| 1126 |
title: title.getPrefixedText() || null, |
| 1127 |
href: title.getUrl() |
| 1128 |
} ); |
| 1129 |
return appendWithoutParsing( $el, anchor ); |
| 1130 |
}, |
| 1131 |
|
| 1132 |
|
| 1133 |
|
| 1134 |
|
| 1135 |
|
| 1136 |
|
| 1137 |
|
| 1138 |
|
| 1139 |
htmlattributes: function ( nodes ) { |
| 1140 |
const mapping = {}; |
| 1141 |
for ( let i = 0, len = nodes.length; i < len; i += 2 ) { |
| 1142 |
mapping[ nodes[ i ] ] = decodePrimaryHtmlEntities( nodes[ i + 1 ] ); |
| 1143 |
} |
| 1144 |
return mapping; |
| 1145 |
}, |
| 1146 |
|
| 1147 |
|
| 1148 |
|
| 1149 |
|
| 1150 |
|
| 1151 |
|
| 1152 |
|
| 1153 |
htmlelement: function ( nodes ) { |
| 1154 |
const tagName = nodes.shift(); |
| 1155 |
const attributes = nodes.shift(); |
| 1156 |
const contents = nodes; |
| 1157 |
const $element = $( document.createElement( tagName ) ).attr( attributes ); |
| 1158 |
return appendWithoutParsing( $element, contents ); |
| 1159 |
}, |
| 1160 |
|
| 1161 |
|
| 1162 |
|
| 1163 |
|
| 1164 |
|
| 1165 |
|
| 1166 |
|
| 1167 |
|
| 1168 |
|
| 1169 |
|
| 1170 |
|
| 1171 |
|
| 1172 |
|
| 1173 |
|
| 1174 |
extlink: function ( nodes ) { |
| 1175 |
const arg = nodes[ 0 ], |
| 1176 |
contents = nodes[ 1 ]; |
| 1177 |
let $el; |
| 1178 |
if ( arg instanceof $ && !arg.hasClass( 'mediaWiki_htmlEmitter' ) ) { |
| 1179 |
$el = arg; |
| 1180 |
} else { |
| 1181 |
$el = $( '<a>' ); |
| 1182 |
if ( typeof arg === 'function' ) { |
| 1183 |
$el.attr( { |
| 1184 |
role: 'button', |
| 1185 |
tabindex: 0 |
| 1186 |
} ).on( 'click keypress', function ( e ) { |
| 1187 |
if ( |
| 1188 |
e.type === 'click' || |
| 1189 |
e.type === 'keypress' && e.which === 13 |
| 1190 |
) { |
| 1191 |
arg.call( this, e ); |
| 1192 |
} |
| 1193 |
} ); |
| 1194 |
} else { |
| 1195 |
const target = textify( arg ); |
| 1196 |
|
| 1197 |
if ( target.search( new RegExp( '^(/|' + mw.config.get( 'wgUrlProtocols' ) + ')' ) ) !== -1 ) { |
| 1198 |
$el.attr( 'href', target ); |
| 1199 |
if ( target.search( '^' + mw.config.get( 'wgArticlePath' ).replace( /\$1/g, '.+?' ) + '$' ) === -1 ) { |
| 1200 |
$el.addClass( 'external' ); |
| 1201 |
} |
| 1202 |
} else { |
| 1203 |
mw.log( 'External link in message had illegal target ' + target ); |
| 1204 |
return appendWithoutParsing( |
| 1205 |
$( '<span>' ), |
| 1206 |
[ '[' + target + ' ' ].concat( contents ).concat( ']' ) |
| 1207 |
).contents(); |
| 1208 |
} |
| 1209 |
} |
| 1210 |
} |
| 1211 |
return appendWithoutParsing( $el.empty(), contents ); |
| 1212 |
}, |
| 1213 |
|
| 1214 |
|
| 1215 |
|
| 1216 |
|
| 1217 |
|
| 1218 |
|
| 1219 |
|
| 1220 |
'#formal': function ( nodes ) { |
| 1221 |
const formalityIndex = this.language.getData( |
| 1222 |
mw.config.get( 'wgUserLanguage' ), |
| 1223 |
'formalityIndex' |
| 1224 |
); |
| 1225 |
|
| 1226 |
if ( nodes.length === 0 ) { |
| 1227 |
return ''; |
| 1228 |
} else if ( nodes.length === 1 ) { |
| 1229 |
return nodes[ 0 ]; |
| 1230 |
} |
| 1231 |
|
| 1232 |
return nodes[ formalityIndex ]; |
| 1233 |
}, |
| 1234 |
|
| 1235 |
|
| 1236 |
|
| 1237 |
|
| 1238 |
|
| 1239 |
|
| 1240 |
|
| 1241 |
|
| 1242 |
|
| 1243 |
plural: function ( nodes ) { |
| 1244 |
const explicitPluralForms = {}; |
| 1245 |
|
| 1246 |
const count = parseFloat( this.language.convertNumber( textify( nodes[ 0 ] ), true ) ); |
| 1247 |
let forms = nodes.slice( 1 ); |
| 1248 |
for ( let formIndex = 0; formIndex < forms.length; formIndex++ ) { |
| 1249 |
const form = forms[ formIndex ]; |
| 1250 |
|
| 1251 |
if ( form instanceof $ && form.hasClass( 'mediaWiki_htmlEmitter' ) ) { |
| 1252 |
|
| 1253 |
const firstChild = form.contents().get( 0 ); |
| 1254 |
if ( firstChild && firstChild.nodeType === Node.TEXT_NODE ) { |
| 1255 |
const firstChildText = firstChild.textContent; |
| 1256 |
if ( /^\d+=/.test( firstChildText ) ) { |
| 1257 |
const explicitPluralFormNumber = parseInt( firstChildText.split( /=/ )[ 0 ], 10 ); |
| 1258 |
|
| 1259 |
|
| 1260 |
firstChild.textContent = firstChildText.slice( firstChildText.indexOf( '=' ) + 1 ); |
| 1261 |
explicitPluralForms[ explicitPluralFormNumber ] = form; |
| 1262 |
forms[ formIndex ] = undefined; |
| 1263 |
} |
| 1264 |
} |
| 1265 |
} else if ( /^\d+=/.test( form ) ) { |
| 1266 |
|
| 1267 |
const explicitPluralFormNumber = parseInt( form.split( /=/ )[ 0 ], 10 ); |
| 1268 |
explicitPluralForms[ explicitPluralFormNumber ] = form.slice( form.indexOf( '=' ) + 1 ); |
| 1269 |
forms[ formIndex ] = undefined; |
| 1270 |
} |
| 1271 |
} |
| 1272 |
|
| 1273 |
|
| 1274 |
|
| 1275 |
forms = $.map( forms, ( f ) => f ); |
| 1276 |
|
| 1277 |
return this.language.convertPlural( count, forms, explicitPluralForms ); |
| 1278 |
}, |
| 1279 |
|
| 1280 |
|
| 1281 |
|
| 1282 |
|
| 1283 |
|
| 1284 |
|
| 1285 |
|
| 1286 |
|
| 1287 |
|
| 1288 |
|
| 1289 |
|
| 1290 |
|
| 1291 |
|
| 1292 |
|
| 1293 |
|
| 1294 |
gender: function ( nodes ) { |
| 1295 |
const forms = nodes.slice( 1 ); |
| 1296 |
|
| 1297 |
let maybeUser = nodes[ 0 ]; |
| 1298 |
if ( maybeUser === '' ) { |
| 1299 |
maybeUser = mw.user; |
| 1300 |
} |
| 1301 |
|
| 1302 |
let gender; |
| 1303 |
|
| 1304 |
|
| 1305 |
if ( maybeUser && maybeUser.options instanceof mw.Map ) { |
| 1306 |
gender = maybeUser.options.get( 'gender' ); |
| 1307 |
} else { |
| 1308 |
gender = textify( maybeUser ); |
| 1309 |
} |
| 1310 |
|
| 1311 |
return this.language.gender( gender, forms ); |
| 1312 |
}, |
| 1313 |
|
| 1314 |
|
| 1315 |
|
| 1316 |
|
| 1317 |
|
| 1318 |
|
| 1319 |
|
| 1320 |
|
| 1321 |
|
| 1322 |
|
| 1323 |
|
| 1324 |
|
| 1325 |
|
| 1326 |
|
| 1327 |
|
| 1328 |
|
| 1329 |
|
| 1330 |
|
| 1331 |
|
| 1332 |
bidi: function ( nodes ) { |
| 1333 |
const dir = strongDirFromContent( nodes[ 0 ] ); |
| 1334 |
if ( dir === 'ltr' ) { |
| 1335 |
|
| 1336 |
return '\u202A' + nodes[ 0 ] + '\u202C'; |
| 1337 |
} |
| 1338 |
if ( dir === 'rtl' ) { |
| 1339 |
|
| 1340 |
return '\u202B' + nodes[ 0 ] + '\u202C'; |
| 1341 |
} |
| 1342 |
|
| 1343 |
return nodes[ 0 ]; |
| 1344 |
}, |
| 1345 |
|
| 1346 |
|
| 1347 |
|
| 1348 |
|
| 1349 |
|
| 1350 |
|
| 1351 |
|
| 1352 |
|
| 1353 |
grammar: function ( nodes ) { |
| 1354 |
const form = nodes[ 0 ], |
| 1355 |
word = nodes[ 1 ]; |
| 1356 |
|
| 1357 |
|
| 1358 |
if ( typeof form === 'string' && typeof word === 'string' ) { |
| 1359 |
return this.language.convertGrammar( word, form ); |
| 1360 |
} |
| 1361 |
return word; |
| 1362 |
}, |
| 1363 |
|
| 1364 |
|
| 1365 |
|
| 1366 |
|
| 1367 |
|
| 1368 |
|
| 1369 |
|
| 1370 |
|
| 1371 |
|
| 1372 |
|
| 1373 |
int: function ( nodes ) { |
| 1374 |
const msg = textify( nodes[ 0 ] ); |
| 1375 |
return getMessageFunction()( mwString.lcFirst( msg ) ); |
| 1376 |
}, |
| 1377 |
|
| 1378 |
|
| 1379 |
|
| 1380 |
|
| 1381 |
|
| 1382 |
|
| 1383 |
|
| 1384 |
|
| 1385 |
ns: function ( nodes ) { |
| 1386 |
let ns = textify( nodes[ 0 ] ).trim(); |
| 1387 |
if ( !/^\d+$/.test( ns ) ) { |
| 1388 |
ns = mw.config.get( 'wgNamespaceIds' )[ ns.replace( / /g, '_' ).toLowerCase() ]; |
| 1389 |
} |
| 1390 |
ns = mw.config.get( 'wgFormattedNamespaces' )[ ns ]; |
| 1391 |
return ns || ''; |
| 1392 |
}, |
| 1393 |
|
| 1394 |
|
| 1395 |
|
| 1396 |
|
| 1397 |
|
| 1398 |
|
| 1399 |
|
| 1400 |
|
| 1401 |
|
| 1402 |
formatnum: function ( nodes ) { |
| 1403 |
const isInteger = !!nodes[ 1 ] && nodes[ 1 ] === 'R', |
| 1404 |
number = nodes[ 0 ]; |
| 1405 |
|
| 1406 |
|
| 1407 |
|
| 1408 |
if ( typeof number === 'string' || typeof number === 'number' ) { |
| 1409 |
return this.language.convertNumber( number, isInteger ); |
| 1410 |
} |
| 1411 |
return number; |
| 1412 |
}, |
| 1413 |
|
| 1414 |
|
| 1415 |
|
| 1416 |
|
| 1417 |
|
| 1418 |
|
| 1419 |
|
| 1420 |
lc: function ( nodes ) { |
| 1421 |
return textify( nodes[ 0 ] ).toLowerCase(); |
| 1422 |
}, |
| 1423 |
|
| 1424 |
|
| 1425 |
|
| 1426 |
|
| 1427 |
|
| 1428 |
|
| 1429 |
|
| 1430 |
uc: function ( nodes ) { |
| 1431 |
return textify( nodes[ 0 ] ).toUpperCase(); |
| 1432 |
}, |
| 1433 |
|
| 1434 |
|
| 1435 |
|
| 1436 |
|
| 1437 |
|
| 1438 |
|
| 1439 |
|
| 1440 |
lcfirst: function ( nodes ) { |
| 1441 |
const text = textify( nodes[ 0 ] ); |
| 1442 |
return mwString.lcFirst( text ); |
| 1443 |
}, |
| 1444 |
|
| 1445 |
|
| 1446 |
|
| 1447 |
|
| 1448 |
|
| 1449 |
|
| 1450 |
|
| 1451 |
ucfirst: function ( nodes ) { |
| 1452 |
const text = textify( nodes[ 0 ] ); |
| 1453 |
return mwString.ucFirst( text ); |
| 1454 |
} |
| 1455 |
}; |
| 1456 |
|
| 1457 |
|
| 1458 |
|
| 1459 |
|
| 1460 |
|
| 1461 |
|
| 1462 |
|
| 1463 |
|
| 1464 |
|
| 1465 |
|
| 1466 |
|
| 1467 |
|
| 1468 |
|
| 1469 |
|
| 1470 |
|
| 1471 |
|
| 1472 |
|
| 1473 |
|
| 1474 |
|
| 1475 |
|
| 1476 |
|
| 1477 |
|
| 1478 |
|
| 1479 |
|
| 1480 |
|
| 1481 |
|
| 1482 |
|
| 1483 |
|
| 1484 |
$.fn.msg = getPlugin(); |
| 1485 |
|
| 1486 |
|
| 1487 |
const oldParser = mw.Message.prototype.parser; |
| 1488 |
mw.Message.prototype.parser = function ( format ) { |
| 1489 |
|
| 1490 |
if ( |
| 1491 |
|
| 1492 |
format === 'plain' || |
| 1493 |
( |
| 1494 |
|
| 1495 |
!/\{\{|[<>[&]/.test( this.map.get( this.key ) ) && |
| 1496 |
|
| 1497 |
!this.parameters.some( ( param ) => param instanceof $ || ( param && param.nodeType !== undefined ) ) |
| 1498 |
) |
| 1499 |
) { |
| 1500 |
return oldParser.call( this, format ); |
| 1501 |
} |
| 1502 |
|
| 1503 |
if ( !Object.prototype.hasOwnProperty.call( this.map, format ) ) { |
| 1504 |
this.map[ format ] = getMessageFunction( { |
| 1505 |
messages: this.map, |
| 1506 |
|
| 1507 |
format: format |
| 1508 |
} ); |
| 1509 |
} |
| 1510 |
return this.map[ format ]( this.key, this.parameters ); |
| 1511 |
}; |
| 1512 |
|
| 1513 |
|
| 1514 |
|
| 1515 |
|
| 1516 |
|
| 1517 |
|
| 1518 |
|
| 1519 |
|
| 1520 |
|
| 1521 |
|
| 1522 |
|
| 1523 |
|
| 1524 |
|
| 1525 |
|
| 1526 |
|
| 1527 |
|
| 1528 |
|
| 1529 |
|
| 1530 |
|
| 1531 |
|
| 1532 |
mw.Message.prototype.parseDom = ( function () { |
| 1533 |
let failableParserFn; |
| 1534 |
|
| 1535 |
return function () { |
| 1536 |
if ( !failableParserFn ) { |
| 1537 |
failableParserFn = getFailableParserFn(); |
| 1538 |
} |
| 1539 |
const $result = failableParserFn( [ this.key, this.parameters ] ); |
| 1540 |
return $result.contents(); |
| 1541 |
}; |
| 1542 |
}() ); |
| 1543 |
|
| 1544 |
|
| 1545 |
|
| 1546 |
|
| 1547 |
|
| 1548 |
|
| 1549 |
|
| 1550 |
|
| 1551 |
|
| 1552 |
|
| 1553 |
|
| 1554 |
|
| 1555 |
|
| 1556 |
|
| 1557 |
|
| 1558 |
|
| 1559 |
|
| 1560 |
|
| 1561 |
|
| 1562 |
mw.Message.prototype.isParseable = function () { |
| 1563 |
const parser = new Parser(); |
| 1564 |
try { |
| 1565 |
parser.parse( this.key, this.parameters ); |
| 1566 |
return true; |
| 1567 |
} catch ( e ) { |
| 1568 |
return false; |
| 1569 |
} |
| 1570 |
}; |
| 1571 |
|
| 1572 |
|
| 1573 |
|
| 1574 |
|
| 1575 |
|
| 1576 |
|
| 1577 |
|
| 1578 |
mw.jqueryMsg = { |
| 1579 |
Parser |
| 1580 |
}; |
| 1581 |
mw.log.deprecate( mw, 'jqueryMsg', mw.jqueryMsg, 'mw.jqueryMsg is a @private library.' ); |
| 1582 |
|
| 1583 |
module.exports = { |
| 1584 |
test: { |
| 1585 |
getMessageFunction, |
| 1586 |
setMessageFunction, |
| 1587 |
getParserDefaults, |
| 1588 |
setParserDefaults, |
| 1589 |
Parser |
| 1590 |
} |
| 1591 |
}; |