ਵਰਤੋਂਕਾਰ:Satdeep Gill/cleanup.js
ਦਿੱਖ
Note: After saving, changes may not occur immediately. Click here to learn how to bypass your browser's cache.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Cmd-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (Cmd-Shift-R on a Mac)
- Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Clear the cache in Tools → Preferences
For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/* global $, pathoschild */
/**
* TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor.
* @see https://meta.wikimedia.org/wiki/TemplateScript
* @update-token [[File:pathoschild/templatescript.js]]
*/
$.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function() {
pathoschild.TemplateScript.add([
{
name: 'clean up',
script: function(editor) {
editor
// remove trailing whitespace at the end of each line
.replace(/ \n/g, '\n')
// Digitized by Google (kill)
.replace(/Digitized[\s\n]+by[^\n]+\n(Google)?/, '')
// remove trailing spaces at the end of each line
.replace(/ +\n/g, '\n')
// remove trailing whitespace preceding a hard line break
.replace(/ +<br *\/?>/g, '<br />')
// remove trailing whitespace at the end of page text
.replace(/\s+$/g, '')
// remove trailing spaces at the end of refs
.replace(/ +<\/ref>/g, '</ref>')
// remove trailing spaces at the end of template calls
.replace(/ +}}/g, '}}')
// join words that are hyphenated across a line break
// (but leave "|-" table syntax alone)
.replace(/([^\|])-\n/g, '$1')
// remove unwanted spaces around punctuation marks
.replace(/ ([);:\।?!,])/g, '$1')
// remove unwanted spaces around ॥
.replace(/ ([॥])/g, '$1')
// – to —
.replace(/–/g, '—')
// ।। to ॥
.replace(/।।/g, '॥')
// remove unwanted spaces around Bengali diactics marks
.replace(/ ([া ি ী ু ূ ৃ ে ৈ ো ৌ])/g, '$1')
// remove unwanted spaces around Bengali ঁা diactics marks
.replace(/ ঁা/g, '$1')
// replace র্তা with তাঁ at the beginning of words like তাঁর তাঁহার etc
.replace(/ র্তা/g, ' তাঁ')
// replace তঁা with তাঁ at the beginning of words like তাঁর তাঁহার etc
.replace(/ তঁা/g, ' তাঁ')
// replace য়৷ with য়া
.replace(/য়৷/g, 'য়া')
// convert double-hyphen to mdash (avoiding breaking HTML comment syntax)
.replace(/([^\!])--([^>])/g, '$1—$2')
// remove trailing whitespace at the end of input
.replace(/\s+$/g, '');
// stuff to do only if the page doesn't contain a <poem> tag:
if (editor.get().indexOf("<poem>") != -1) {
editor
// remove single line breaks; preserve multiple.
.replace(/([^>\n])\n([^<\n])/g, '$1 $2')
// collapse sequences of spaces into a single space
.replace(/ +/g, ' ');
}
}
}
]);
});
/**
* TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor.
* @see https://meta.wikimedia.org/wiki/TemplateScript
* @update-token [[File:Pathoschild/templatescript.js]]
*/
// <nowiki>
$.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function() {
pathoschild.TemplateScript.add([
// add your own templates or scripts here
{ name: 'স্বাগতম', template: '{{subst:স্বাগতম}} ~~~~', position: 'after', editSummary: 'স্বাগতম!', forNamespaces: 'user talk' },
{ name: 'Uw-scan', template: '{{subst:Uw-scan}} ~~~~', position: 'after', editSummary: 'স্ক্যান ছাড়া পাতা ', forNamespaces: 'user talk' },
{ name: 'Uw-van', template: '{{subst:Uw-van}} ~~~~', position: 'after', editSummary: 'ধ্বংসপ্রবণতা ', forNamespaces: 'user talk'},
{ name: 'Uw-test', template: '{{subst:Uw-test}} ~~~~', position: 'after', editSummary: 'পরীক্ষামূলক সম্পাদনা ', forNamespaces: 'user talk'}
]);
});
// </nowiki>