Skip to content

Commit

Permalink
Fix highligthing multiple word. Closes #151
Browse files Browse the repository at this point in the history
  • Loading branch information
mthenw committed Jan 9, 2019
1 parent 8ea0f65 commit 424bea0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions test/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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">fooq</span> <span style="background: black">bar</span>'
);
});

it('should highlight line', () => {
Expand Down
2 changes: 1 addition & 1 deletion web/assets/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>'
);
Expand Down

0 comments on commit 424bea0

Please sign in to comment.