User:Inductiveload/LineCollapse.js

$.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType: 'script',  cache: true }).then(function {  // page NS  pathoschild.TemplateScript.add( [ 	  {        name: "Line collapse", position: "cursor", //accessKey: 'c', // enable for use of access-key shortcut // see, e.g. https://en.wikipedia.org/wiki/Wikipedia:Keyboard_shortcuts script: function(editor) { editor

// join words that are hyphenated across a line break // (but leave "|-" table syntax alone) .replace(/([^\|])-\n/g, '$1')

// remove single line breaks; preserve multiple. // not if there's a tag, template, table syntax either side of line break .replace(/([^>}\n])\n([^<{\|\n])/g, '$1 $2'); }     },    ], {      forNamespaces: 'page' } // common fields ); });