Skip to content

Commit

Permalink
Merge pull request #1453 from nknapp/master
Browse files Browse the repository at this point in the history
Do not add "undefined" to the beginning of the result of .fixMarkup()
  • Loading branch information
isagalaev authored Feb 18, 2017
2 parents 4b3fdc5 + db5ef50 commit 543b8f8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ https://highlightjs.org/
} else if (options.tabReplace) {
return p1.replace(/\t/g, options.tabReplace);
}
return '';
});
}

Expand Down
21 changes: 21 additions & 0 deletions test/api/fixmarkup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

let should = require('should');
let hljs = require('../../build');

describe('.fixmarkup()', function() {
after(function() {
hljs.configure({ useBR: false })
})

it('should not add "undefined" to the beginning of the result (#1452)', function() {
hljs.configure({ useBR: true })
const value = '{ <span class="hljs-attr">"some"</span>: \n <span class="hljs-string">"json"</span> }';
const result = hljs.fixMarkup(value);


result.should.equal(
'{ <span class="hljs-attr">"some"</span>: <br> <span class="hljs-string">"json"</span> }'
);
});
});
1 change: 1 addition & 0 deletions test/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ describe('hljs', function() {
require('./starters');
require('./getLanguage');
require('./highlight');
require('./fixmarkup');
});

0 comments on commit 543b8f8

Please sign in to comment.