/*! * A set of simple tools for partial parsing and formatting of translatable * messages. * * @author Niklas Laxström * @license GPL-2.0-or-later */ ( function () { 'use strict'; mw.translate = mw.translate || {}; mw.translate = $.extend( mw.translate, { /** * Formats some common wikitext elements. * * @param {string} text Message text * @param {string} [key] Message key * @return {string} Formatted text in html */ formatMessageGently: function ( text, key ) { var externals, protocols = mw.config.get( 'wgUrlProtocols' ); // Try to keep simple. text = $( '
' ).text( text ).html(); // Hack for page translation page titles if ( text && key && key.match( /\/Page_display_title$/ ) ) { text = '=' + text + '='; } text = text.replace( /^(=+)(.*?)(=+)/, function ( match, p1, p2, p3 ) { var len = Math.min( p1.length, p3.length, 6 ); return $( '
' ).append( $( '' ).html( p2 ) ).html(); } ); text = text.replace( /(^\*.*(\n|$))+/gm, function ( match ) { match = match.replace( /^\*(.*)/gm, function ( match, p1 ) { return $( '
' ).append( $( '
  • ' ).html( p1 ) ).html(); } ); return $( '
    ' ).append( $( '