diff options
author | Aleš Smodiš <aless@guru.si> | 2015-10-02 16:48:09 +0200 |
---|---|---|
committer | Aleš Smodiš <aless@guru.si> | 2015-10-02 16:48:09 +0200 |
commit | 5d7eabb690941b4de27d48e487c344260fdcf8ad (patch) | |
tree | 8cb02fb9f25f8ef9c00d5a8b9acf652639f62818 | |
parent | 8f368bc83db0b6a938ea6f8650cb30b2c7bef060 (diff) |
Bugfix: don't remove [\n\r\t] from templates.
-rw-r--r-- | js/codeq/core.js | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/js/codeq/core.js b/js/codeq/core.js index f1bd697..b54095f 100644 --- a/js/codeq/core.js +++ b/js/codeq/core.js @@ -144,18 +144,19 @@ regexpBackslash = new RegExp('\\\\', 'g'), regexpWhiteSpaceStart = new RegExp('^[ \r\n\t]+'), regexpWhiteSpaceEnd = new RegExp('[ \r\n\t]+$'), - regexpWhiteSpaceNonPrintable = new RegExp('[\r\n\t]', 'g'), regexpWhiteSpaceBeforeTag = new RegExp('[ \r\n\t]+(?=<)', 'g'), regexpWhiteSpaceAfterTag = new RegExp('>[ \r\n\t]+', 'g'), - regexpWhiteSpace = new RegExp('[ \\r\\n\\t]+'), regexpWhiteSpaceTrim = new RegExp('^[ \\t\\r\\n]*(.*[^ \\t\\r\\n])[ \\t\\r\\n]*$', 'm'), regexpAmp = new RegExp('&', 'g'), regexpLt = new RegExp('<', 'g'), - regexpGt = new RegExp('>', 'g'); + regexpGt = new RegExp('>', 'g'), + regexpCR = new RegExp('\\r', 'g'), + regexpLF = new RegExp('\\n', 'g'), + regexpTab = new RegExp('\\t', 'g'); // convert a string into its definition (javascript literal) var stringToDef = function (str) { - return str.replace(regexpBackslash, '\\\\').replace(regexpQuote, '\\"').replace(regexpWhiteSpaceNonPrintable, ' '); + return str.replace(regexpBackslash, '\\\\').replace(regexpQuote, '\\"').replace(regexpCR, '\\r').replace(regexpLF, '\\n').replace(regexpTab, '\\t'); }; // given a HTML source, remove whitespace among tags |