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.
Code that you insert on this page could contain malicious content capable of compromising your account. If you are unsure whether code you are adding to this page is safe, you can ask at the central discussion page, Scriptorium. The code will be executed when previewing this page under some skins, including Monobook. You can in the interim if you wish to refresh the content sooner under another skin. |
The accompanying .css page for this skin is at User:Yodin/common.css. |
mw.loader.load('//en.wikisource.org/w/index.php?title=User:Samwilson/CurlyQuotes.js&action=raw&ctype=text/javascript');
/**
* TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor.
* @see [[meta:TemplateScript]]
* @update-token [[File:Pathoschild/templatescript.js]]
*/
mw.loader.load('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js');
/**
* 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({
name:'Prose format',
forNamespaces: 'page',
script: function(editor) {
editor
.replace(/'''/g, '%#%#%BOLD%#%#%') // replace bold tags while formatting the page
.replace(/''/g, '%#%#%ITALIC%#%#%') // replace italic tags while formatting the page
.replace(/([^\n])\n([^\n])/g, '$1 $2') // remove all single newlines
.replace(/[ ]+/g, ' ') // remove duplicate spaces
.replace(/(\s|^)\"/g, '$1“') // replace typewriter quotation marks with “ when preceded by a space or the start of the document
.replace(/\"/g, '”') // replace remaining typewriter quotation marks with ”
.replace(/(\s|^|“)\'/g, '$1‘') // replace typewriter apostrophes with ‘ when preceded by a space, the start of the document, or “
.replace(/\'/g, '’') // replace remaining typewriter apostrophes with ’
.replace(/([“‘])\s+/g,'$1') // remove whitespace following “ or ‘
.replace(/\s+”/g,'”') // remove whitespace before ”
.replace(/\s+([!?:;,.])/g, '$1') // remove whitespace before punctuation
.replace(/[ ]+(\n)/g, '$1') // remove spaces before newlines
.replace(/[^\S\r\n]*—[^\S\r\n]*/g, '—') // remove whitespace both sides of an em dash
.replace(/^\s+/g, '') // remove leading whitespace at the start of the page
.replace(/\s+$/g, '') // remove trailing whitespace at the end of the page
.replace(/“\s*‘/g,'{{“ ‘}}') // change “‘ to use template
.replace(/“\s*’/g,'{{“ ’}}') // change “’ to use template
.replace(/’\s*”/g,'{{’ ”}}') // change ’” to use template
.replace(/(<[^>]*)[“”]([^>]*>)/g, '$1"$2') // restore typewriter quotation marks within html tags
.replace(/(<[^>]*)[“”]([^>]*>)/g, '$1"$2') // run a second time to replace both quotation marks
.replace(/%#%#%BOLD%#%#%/g, "'''") // restore bold tags
.replace(/%#%#%ITALIC%#%#%/g, "''"); // restore italic tags
}
});
pathoschild.TemplateScript.add({
name:'Poem format (ppoem)',
forNamespaces: 'page',
script: function(editor) {
editor
.replace(/'''/g, '%#%#%BOLD%#%#%') // replace bold tags while formatting the page
.replace(/''/g, '%#%#%ITALIC%#%#%') // replace italic tags while formatting the page
.replace(/[^\S\r\n]*(\d+)[^\S\r\n]*(\n)/g,'{{pline|$1|r}}$2') // add pline template
.replace(/([^\n])[^\S\r\n]*(<br\/>)*[^\S\r\n]*(\n|$)/g, '$1$3') // remove trailing whitespace and <br/> tags from the end of lines
.replace(/[ ]+/g, ' ') // remove duplicate spaces
.replace(/(\s|^)\"/g, '$1“') // replace typewriter quotation marks with “ when preceded by a space or the start of the document
.replace(/\"/g, '”') // replace remaining typewriter quotation marks with ”
.replace(/(\s|^|“)\'/g, '$1‘') // replace typewriter apostrophes with ‘ when preceded by a space, the start of the document, or “
.replace(/\'/g, '’') // replace remaining typewriter apostrophes with ’
.replace(/([“‘])\s+/g,'$1') // remove whitespace following “ or ‘
.replace(/\s+”/g,'”') // remove whitespace before ”
.replace(/\s+([!?:;,.])/g, '$1') // remove whitespace before punctuation
.replace(/[ ]+(\n)/g, '$1') // remove spaces before newlines
.replace(/[^\S\r\n]*—[^\S\r\n]*/g, '—') // remove whitespace both sides of an em dash
.replace(/^\s+/g, '') // remove leading whitespace at the start of the page
.replace(/\s+$/g, '') // remove trailing whitespace at the end of the page
.replace(/“\s*‘/g,'{{“ ‘}}') // change “‘ to use template
.replace(/“\s*’/g,'{{“ ’}}') // change “’ to use template
.replace(/’\s*”/g,'{{’ ”}}') // change ’” to use template
.replace(/<br>(\n\n)/g,'$1') // remove <br> tags at the end of stanzas
.replace(/(<[^>]*)[“”]([^>]*>)/g, '$1"$2') // restore typewriter quotation marks within html tags
.replace(/(<[^>]*)[“”]([^>]*>)/g, '$1"$2') // run a second time to replace both quotation marks
.replace(/%#%#%BOLD%#%#%/g, "'''") // restore bold tags
.replace(/%#%#%ITALIC%#%#%/g, "''"); // restore italic tags
}
});
pathoschild.TemplateScript.add({
name:'Typewriter quotations',
forNamespaces: 'page',
script: function(editor) {
editor
.replace(/[′‘’`]/g, "'")
.replace(/[“”″]/g, '"');
}
});
pathoschild.TemplateScript.add({
name:'Clear footer',
forNamespaces: 'page',
script: function(editor) {
editor.forField('#wpFooterTextbox').set('');
}
});
pathoschild.TemplateScript.add({
name:'Clear all',
forNamespaces: 'page',
script: function(editor) {
editor.forField('#wpHeaderTextbox').set('');
editor.set('');
editor.forField('#wpFooterTextbox').set('');
}
});
});
// </nowiki>