User:Electricmuffin11/common.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 */ $.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function {	pathoschild.TemplateScript.add([ { name: '" - " to "—"', script: spacedHyphenToEmDash }, { name: '"--" to "—"', script: doubleHyphenToEmDash } ]); });

function spacedHyphenToEmDash(editor) { editor .replace(/ - /g, '—') .appendEditSummary('replaced " - "s with em dashes ("—")') .clickDiff; }

function doubleHyphenToEmDash(editor) { editor .replace(/( ?)--( ?)/g, '$1—$2') .appendEditSummary('replaced "--"s with em dashes ("—")') .clickDiff; }