Skip to content

Commit

Permalink
Update browser.html
Browse files Browse the repository at this point in the history
  • Loading branch information
underpig1 committed Aug 7, 2020
1 parent 4aff349 commit 0cea52d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions docs/browser/browser.html
Expand Up @@ -137,11 +137,15 @@ <h3>NEURON</h3>
setInterval(syntax, 10);

function syntax() {
var selection = saveSelection(document.getElementById("code"));
if (window.getSelection().rangeCount > 0) {
var selection = saveSelection(document.getElementById("code"));
}
for (var i in grammers.patterns) {
highlight(grammers.patterns[i].match, grammers.patterns[i].name);
}
restoreSelection(document.getElementById("code"), selection);
if (window.getSelection().rangeCount > 0) {
restoreSelection(document.getElementById("code"), selection);
}

function highlight(re, cl) {
code.innerHTML = code.innerHTML.replace(re, `<span class = "${cl}">$&</span>`);
Expand Down

0 comments on commit 0cea52d

Please sign in to comment.