User:Waldyrious/remove-line-breaks.js

function remove_line_breaks { var txt = document.editform.wpTextbox1;

// First, handle lines ending in a hyphen (no space should be added) txt.value = txt.value.replace(/- *\n/g, ''); // Then handle all the others (convert single line breaks into spaces) txt.value = txt.value.replace(/(?<!\n)\n(?!\n)/g, ' '); }

$(function {    if(document.forms.editform) {    	// Documentation: https://www.mediawiki.org/wiki/ResourceLoader/Core_modules#addPortletLink        mw.util.addPortletLink('p-cactions', 'javascript:remove_line_breaks', '↵ → ␣', 'remove-line-breaks', 'Remove line breaks (after OCR)');    } });