From cef03a4a82864b3f3a99c52bc75bf895d18f9308 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Fri, 15 Sep 2017 21:59:53 +0200 Subject: [PATCH] edit: ignore html elements in sentence wrapping Assume whitespace is safe to be wrapped anywhere. Exceptions could still occur inside of tags, but deemed very unlikely. Rather have large code blobs be counted as separate characters. --- edit.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/edit.js b/edit.js index b97ed87..4cdc572 100644 --- a/edit.js +++ b/edit.js @@ -5,9 +5,8 @@ CKEDITOR.plugins.add('inlinesave', { var pagename = window.location.pathname.replace(/\/$/, '/index'); var body = editor.getData().replace(/^(\t*).{73,}/mg, function (line, indent) { // wrap long line after each sentence - var dot = '(?:[^<]|<[^>]*>)'; // one character - var dots = '(?:'+dot+'{24,72}|'+dot+'{73,}?)'; // chars before punctuation - var wrap = new RegExp('('+dots+'[.;:!?]) (?=[A-Z])', 'g'); // separate lines + var dots = '(?:.{24,72}|.{73,}?)'; // chars before punctuation + var wrap = new RegExp('('+dots+'[.;:!?]) (?=[A-Z(<])', 'g'); // separate lines return line.replace(wrap, '$1\n'+indent+'\t'); }); var data = 'body='+encodeURIComponent(body); -- 2.30.0