1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-08-08 06:55:26 +02:00

solution through split func

This commit is contained in:
Nikita Melnikov 2019-04-01 15:03:35 +03:00
parent 1d68aade90
commit 7b78ff85a0
4 changed files with 13 additions and 12 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -49,10 +49,11 @@ export default class CodeStyler {
Array.from(codeBlocks).forEach(block => {
hljs.highlightBlock(block);
let temp = block.innerHTML.replace(/\n([+].*)/ig, '\n<span class="diff diff--added">$1</span>');
let temp = block.innerHTML.split('\n');
temp = temp.replace(/\n([-].*)/ig, '\n<span class="diff diff--removed">$1</span>');
block.innerHTML = temp;
temp = temp.map(str => str.replace(/^(\+.*)$/ig, '<span class="diff diff--added">$1</span>'));
temp = temp.map(str => str.replace(/^(-.*)$/ig, '<span class="diff diff--removed">$1</span>'));
block.innerHTML = temp.join('\n');
});
}
}