fix various issues dont stop random *'s appearing
This commit is contained in:
parent
da246d183d
commit
d3f730e2ba
|
@ -47,58 +47,6 @@ exports.getPadPlainText = function(pad, revNum){
|
||||||
return pieces.join('');
|
return pieces.join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
// copied from ACE
|
|
||||||
exports._processSpaces = function(s){
|
|
||||||
var doesWrap = true;
|
|
||||||
if (s.indexOf("<") < 0 && !doesWrap){
|
|
||||||
// short-cut
|
|
||||||
return s.replace(/ /g, ' ');
|
|
||||||
}
|
|
||||||
var parts = [];
|
|
||||||
s.replace(/<[^>]*>?| |[^ <]+/g, function (m){
|
|
||||||
parts.push(m);
|
|
||||||
});
|
|
||||||
if (doesWrap){
|
|
||||||
var endOfLine = true;
|
|
||||||
var beforeSpace = false;
|
|
||||||
// last space in a run is normal, others are nbsp,
|
|
||||||
// end of line is nbsp
|
|
||||||
for (var i = parts.length - 1; i >= 0; i--){
|
|
||||||
var p = parts[i];
|
|
||||||
if (p == " "){
|
|
||||||
if (endOfLine || beforeSpace) parts[i] = ' ';
|
|
||||||
endOfLine = false;
|
|
||||||
beforeSpace = true;
|
|
||||||
}
|
|
||||||
else if (p.charAt(0) != "<"){
|
|
||||||
endOfLine = false;
|
|
||||||
beforeSpace = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// beginning of line is nbsp
|
|
||||||
for (var i = 0; i < parts.length; i++){
|
|
||||||
var p = parts[i];
|
|
||||||
if (p == " "){
|
|
||||||
parts[i] = ' ';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (p.charAt(0) != "<"){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (var i = 0; i < parts.length; i++){
|
|
||||||
var p = parts[i];
|
|
||||||
if (p == " "){
|
|
||||||
parts[i] = ' ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return parts.join('');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
exports._analyzeLine = function(text, aline, apool){
|
exports._analyzeLine = function(text, aline, apool){
|
||||||
var line = {};
|
var line = {};
|
||||||
|
|
|
@ -22,7 +22,6 @@ var ERR = require("async-stacktrace");
|
||||||
var Security = require('ep_etherpad-lite/static/js/security');
|
var Security = require('ep_etherpad-lite/static/js/security');
|
||||||
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
|
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
|
||||||
var getPadPlainText = require('./ExportHelper').getPadPlainText
|
var getPadPlainText = require('./ExportHelper').getPadPlainText
|
||||||
var _processSpaces = require('./ExportHelper')._processSpaces;
|
|
||||||
var _analyzeLine = require('./ExportHelper')._analyzeLine;
|
var _analyzeLine = require('./ExportHelper')._analyzeLine;
|
||||||
var _encodeWhitespace = require('./ExportHelper')._encodeWhitespace;
|
var _encodeWhitespace = require('./ExportHelper')._encodeWhitespace;
|
||||||
|
|
||||||
|
@ -543,3 +542,57 @@ function _findURLs(text)
|
||||||
|
|
||||||
return urls;
|
return urls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// copied from ACE
|
||||||
|
function _processSpaces(s){
|
||||||
|
var doesWrap = true;
|
||||||
|
if (s.indexOf("<") < 0 && !doesWrap){
|
||||||
|
// short-cut
|
||||||
|
return s.replace(/ /g, ' ');
|
||||||
|
}
|
||||||
|
var parts = [];
|
||||||
|
s.replace(/<[^>]*>?| |[^ <]+/g, function (m){
|
||||||
|
parts.push(m);
|
||||||
|
});
|
||||||
|
if (doesWrap){
|
||||||
|
var endOfLine = true;
|
||||||
|
var beforeSpace = false;
|
||||||
|
// last space in a run is normal, others are nbsp,
|
||||||
|
// end of line is nbsp
|
||||||
|
for (var i = parts.length - 1; i >= 0; i--){
|
||||||
|
var p = parts[i];
|
||||||
|
if (p == " "){
|
||||||
|
if (endOfLine || beforeSpace) parts[i] = ' ';
|
||||||
|
endOfLine = false;
|
||||||
|
beforeSpace = true;
|
||||||
|
}
|
||||||
|
else if (p.charAt(0) != "<"){
|
||||||
|
endOfLine = false;
|
||||||
|
beforeSpace = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// beginning of line is nbsp
|
||||||
|
for (var i = 0; i < parts.length; i++){
|
||||||
|
var p = parts[i];
|
||||||
|
if (p == " "){
|
||||||
|
parts[i] = ' ';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (p.charAt(0) != "<"){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (var i = 0; i < parts.length; i++){
|
||||||
|
var p = parts[i];
|
||||||
|
if (p == " "){
|
||||||
|
parts[i] = ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return parts.join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ var ERR = require("async-stacktrace");
|
||||||
var Security = require('ep_etherpad-lite/static/js/security');
|
var Security = require('ep_etherpad-lite/static/js/security');
|
||||||
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
|
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
|
||||||
var getPadPlainText = require('./ExportHelper').getPadPlainText;
|
var getPadPlainText = require('./ExportHelper').getPadPlainText;
|
||||||
var _processSpaces = require('./ExportHelper')._processSpaces;
|
|
||||||
var _analyzeLine = require('./ExportHelper')._analyzeLine;
|
var _analyzeLine = require('./ExportHelper')._analyzeLine;
|
||||||
var _encodeWhitespace = require('./ExportHelper')._encodeWhitespace;
|
var _encodeWhitespace = require('./ExportHelper')._encodeWhitespace;
|
||||||
|
|
||||||
|
@ -204,12 +203,12 @@ function getTXTFromAtext(pad, atext, authorColors)
|
||||||
{
|
{
|
||||||
if (propVals[i] === ENTER || propVals[i] === STAY)
|
if (propVals[i] === ENTER || propVals[i] === STAY)
|
||||||
{
|
{
|
||||||
emitOpenTag(i);
|
|
||||||
propVals[i] = true;
|
propVals[i] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// propVals is now all {true,false} again
|
// propVals is now all {true,false} again
|
||||||
} // end if (propChanged)
|
} // end if (propChanged)
|
||||||
|
|
||||||
var chars = o.chars;
|
var chars = o.chars;
|
||||||
if (o.lines)
|
if (o.lines)
|
||||||
{
|
{
|
||||||
|
@ -217,16 +216,15 @@ function getTXTFromAtext(pad, atext, authorColors)
|
||||||
}
|
}
|
||||||
|
|
||||||
var s = taker.take(chars);
|
var s = taker.take(chars);
|
||||||
|
|
||||||
//removes the characters with the code 12. Don't know where they come
|
// removes the characters with the code 12. Don't know where they come
|
||||||
//from but they break the abiword parser and are completly useless
|
// from but they break the abiword parser and are completly useless
|
||||||
s = s.replace(String.fromCharCode(12), "");
|
// s = s.replace(String.fromCharCode(12), "");
|
||||||
|
|
||||||
// remove * from s, it's just not needed on a blank line.. This stops
|
// remove * from s, it's just not needed on a blank line.. This stops
|
||||||
// plugins from being able to display * at the beginning of a line
|
// plugins from being able to display * at the beginning of a line
|
||||||
s = s.replace("*", "");
|
// s = s.replace("*", ""); // Then remove it
|
||||||
|
|
||||||
// assem.append(_encodeWhitespace(Security.escapeHTML(s)));
|
|
||||||
assem.append(_encodeWhitespace(s));
|
assem.append(_encodeWhitespace(s));
|
||||||
} // end iteration over spans in line
|
} // end iteration over spans in line
|
||||||
|
|
||||||
|
@ -242,8 +240,7 @@ function getTXTFromAtext(pad, atext, authorColors)
|
||||||
|
|
||||||
} // end processNextChars
|
} // end processNextChars
|
||||||
processNextChars(text.length - idx);
|
processNextChars(text.length - idx);
|
||||||
|
return(assem.toString());
|
||||||
return _processSpaces(assem.toString());
|
|
||||||
} // end getLineHTML
|
} // end getLineHTML
|
||||||
var pieces = [css];
|
var pieces = [css];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue