Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) fixMarkup would rarely destroy markup when useBR was enabled #2532

Merged
merged 4 commits into from May 8, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 13 additions & 3 deletions test/api/fixmarkup.js
Expand Up @@ -5,11 +5,21 @@ const hljs = require('../../build');

describe('.fixmarkup()', () => {
after(() => {
hljs.configure({ useBR: false })
})
hljs.configure({ useBR: false });
});

it('should not strip HTML from beginning of strings', () => {
hljs.configure({ useBR: true });
const value = '<span class="hljs-attr">"some"</span>: \n <span class="hljs-string">"json"</span>';
joshgoebel marked this conversation as resolved.
Show resolved Hide resolved
const result = hljs.fixMarkup(value);

result.should.equal(
'<span class="hljs-attr">"some"</span>: <br> <span class="hljs-string">"json"</span>'
);
});

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

Expand Down