Preserve tabs

This commit is contained in:
Mohamed Akram 2019-04-15 20:17:55 +04:00
parent 35f86fe528
commit e4e0df62b9
3 changed files with 5 additions and 7 deletions

View file

@ -18,8 +18,7 @@
.replace(/>/g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''')
.replace(/\//g, '/')
.replace(/\t/g, ' ');
.replace(/\//g, '/');
};
Utils.prototype.startsWith = function(str, start) {

View file

@ -1,5 +1,4 @@
var assert = require('assert');
var Utils = require('../src/utils.js').Utils;
var LineByLinePrinter = require('../src/line-by-line-printer.js').LineByLinePrinter;
@ -109,11 +108,11 @@ describe('LineByLinePrinter', function() {
assert.equal(expected, fileHtml);
});
it('should convert indents into non breakin spaces (one tab)', function() {
it('should preserve tabs', function() {
var diffParser = require('../src/diff-parser.js').DiffParser;
var lineByLinePrinter = new LineByLinePrinter({});
var fileHtml = lineByLinePrinter.makeLineHtml(false,
diffParser.LINE_TYPE.INSERTS, '', 30, Utils.escape('\ttest'), '+');
diffParser.LINE_TYPE.INSERTS, '', 30, '\ttest', '+');
fileHtml = fileHtml.replace(/\n\n+/g, '\n');
var expected = '<tr>\n' +
' <td class="d2h-code-linenumber d2h-ins">\n' +
@ -124,7 +123,7 @@ describe('LineByLinePrinter', function() {
' <td class="d2h-ins">\n' +
' <div class="d2h-code-line d2h-ins">\n' +
' <span class="d2h-code-line-prefix">+</span>\n' +
' <span class="d2h-code-line-ctn"> test</span>\n' +
' <span class="d2h-code-line-ctn">\ttest</span>\n' +
' </div>\n' +
' </td>\n' +
'</tr>';

View file

@ -18,7 +18,7 @@ describe('Utils', function() {
});
it('should escape a string with multiple problematic characters', function() {
var result = Utils.escape('<a href="#">\tlink text</a>');
var expected = '&lt;a href=&quot;#&quot;&gt; link text&lt;&#x2F;a&gt;';
var expected = '&lt;a href=&quot;#&quot;&gt;\tlink text&lt;&#x2F;a&gt;';
assert.equal(expected, result);
});
});