edit: ignore html elements in sentence wrapping
authorMischa POSLAWSKY <perl@shiar.org>
Fri, 15 Sep 2017 19:59:53 +0000 (21:59 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 18 Sep 2017 18:21:28 +0000 (20:21 +0200)
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

diff --git a/edit.js b/edit.js
index b97ed87611cd8b8299ae03e953d73d48d7835612..4cdc5725cba194d67726c8a8519dfe17d4e944ab 100644 (file)
--- 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);