diff options
author | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2015-10-15 14:34:39 +0200 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2015-10-15 14:35:02 +0200 |
commit | a78e4ac73f8a7b5fb664c703562717d165ff7760 (patch) | |
tree | 0d50fba29656478d84a7b8aebffa932e2bb3e3a4 /js/codeq | |
parent | 9e75e05583b9ae07e86438c63bcc2dc22be05fea (diff) |
Don't mess with whitespace in HTML templates
Diffstat (limited to 'js/codeq')
-rw-r--r-- | js/codeq/core.js | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/js/codeq/core.js b/js/codeq/core.js index 0976ecc..33c00a4 100644 --- a/js/codeq/core.js +++ b/js/codeq/core.js @@ -144,8 +144,6 @@ regexpBackslash = new RegExp('\\\\', 'g'), regexpWhiteSpaceStart = new RegExp('^[ \r\n\t]+'), regexpWhiteSpaceEnd = new RegExp('[ \r\n\t]+$'), - regexpWhiteSpaceBeforeTag = new RegExp('[ \r\n\t]+(?=<)', 'g'), - regexpWhiteSpaceAfterTag = new RegExp('>[ \r\n\t]+', 'g'), regexpWhiteSpaceTrim = new RegExp('^[ \\t\\r\\n]*(.*[^ \\t\\r\\n])[ \\t\\r\\n]*$', 'm'), regexpAmp = new RegExp('&', 'g'), regexpLt = new RegExp('<', 'g'), @@ -159,12 +157,6 @@ return str.replace(regexpBackslash, '\\\\').replace(regexpQuote, '\\"').replace(regexpCR, '\\r').replace(regexpLF, '\\n').replace(regexpTab, '\\t'); }; - // given a HTML source, remove whitespace among tags - var cleanHtml = function (html) { - // JavaScript doesn't support lookbehind, so we use the split-join trick - return html.replace(regexpWhiteSpaceBeforeTag, '').split(regexpWhiteSpaceAfterTag).join('>'); - }; - var resources = {}; // resource tree, loaded from data/resources.json in the boot sequence // event dispatch @@ -471,7 +463,7 @@ // start processing parts = atoms.join('').split('[%'); - if (parts[0].length > 0) src.push('_result.push("', stringToDef(cleanHtml(parts[0])), '");\n'); // the first part that doesn't begin with '[%' + if (parts[0].length > 0) src.push('_result.push("', stringToDef(parts[0]), '");\n'); // the first part that doesn't begin with '[%' for (i = 1; i < parts.length; i++) { // for every part that begins with '[%' if (parts[i].slice(0, 2) === '--') { // a comment start subparts = parts[i].split('--%]'); // split at comment end @@ -507,7 +499,7 @@ } } if ((subparts.length > 1) && (subparts[1].length > 0)) { // there's a trailing text - src.push('_result.push("', stringToDef(cleanHtml(subparts[1])), '");\n'); + src.push('_result.push("', stringToDef(subparts[1]), '");\n'); } } src.push('return _result.join("");'); |