- var pagename = window.location.pathname.replace(/\.php$/, '').replace(/\/$/, '/index');
- var data = 'body='+encodeURIComponent(editor.getData());
+ var pagename = window.location.pathname.replace(/\/$/, '/index');
+ var body = editor.getData();
+ body = body.replace(/<br \/>\s*<br \/>/g, '<p>');
+ body = body.replace(/^(\t*).{73,}/mg, function (line, indent) {
+ // wrap long line after each sentence
+ 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);