Fix highligthing multiple word. Closes #151 (#155)

pull/157/head
Maciej Winnicki 2019-01-09 21:58:01 +01:00 committed by GitHub
parent 26c3957457
commit 57367a2b0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -121,13 +121,16 @@ describe('browser application', () => {
it('should highlight word', () => {
io.emit('options:highlightConfig', {
words: {
line: 'background: black'
foo: 'background: black',
bar: 'background: black'
}
});
io.emit('line', 'line1');
io.emit('line', 'foo bar');
const line = window.document.querySelector('.line');
line.innerHTML.should.containEql('<span style="background: black">line</span>');
line.innerHTML.should.containEql(
'<span style="background: black">foo</span> <span style="background: black">bar</span>'
);
});
it('should highlight line', () => {

View File

@ -177,7 +177,7 @@ window.App = (function app(window, document) {
if (_highlightConfig && _highlightConfig.words) {
Object.keys(_highlightConfig.words).forEach((wordCheck) => {
output = line.replace(
output = output.replace(
wordCheck,
'<span style="' + _highlightConfig.words[wordCheck] + '">' + wordCheck + '</span>'
);