MediaWiki:Common.js: Difference between revisions

From Sanatan Hindu Dharma
(Created page with "→‎Any JavaScript here will be loaded for all users on every page load.: function wikifyText (startString, endString, text, list) { list = list.map( function (str) { return str.replace( /([^a-z0-9_])/g, '\\$1' ); }); list.sort(); list.reverse(); var re = new RegExp( '\\b(' + list.join('|') + ')\\b', 'g' ); return text.replace( re, startString + '$1' + endString ); }")
 
No edit summary
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on every page load. */
function wikifyText (startString, endString, text, list) {
    list = list.map( function (str) {
        return str.replace( /([^a-z0-9_])/g, '\\$1' );
    });
    list.sort();
    list.reverse();
    var re = new RegExp( '\\b(' + list.join('|') + ')\\b', 'g' );
    return text.replace( re, startString + '$1' + endString );
}

Revision as of 15:25, 23 December 2024

/* Any JavaScript here will be loaded for all users on every page load. */