1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-02 10:13:16 +00:00

Refactored stringily not to add the double quotes

This commit is contained in:
Jeremy Ruston 2012-01-24 18:09:54 +00:00
parent b32826f110
commit b92e011c66
2 changed files with 6 additions and 5 deletions

View File

@ -52,10 +52,10 @@ JavaScriptParseTree.prototype.renderNode = function(output,node) {
var p;
switch(node.type) {
case "StringLiteral":
output.push(utils.stringify(node.value));
output.push('"' + utils.stringify(node.value) + '"');
break;
case "StringLiterals":
output.push(utils.stringify(node.value.join("")));
output.push('"' + utils.stringify(node.value.join("")) + '"');
break;
case "FunctionCall":
output.push("(");

View File

@ -227,12 +227,13 @@ utils.stringify = function(s) {
*
* For portability, we also escape escape all non-ASCII characters.
*/
return '"' + s
return s
.replace(/\\/g, '\\\\') // backslash
.replace(/"/g, '\\"') // closing quote character
.replace(/"/g, '\\"') // double quote character
.replace(/'/g, "\\'") // single quote character
.replace(/\r/g, '\\r') // carriage return
.replace(/\n/g, '\\n') // line feed
.replace(/[\x80-\uFFFF]/g, utils.escape) + '"'; // non-ASCII characters
.replace(/[\x80-\uFFFF]/g, utils.escape); // non-ASCII characters
};
// Creates an HTML element string from these arguments: