Skip to content

Instantly share code, notes, and snippets.

@incompl
Created August 8, 2013 15:22
Show Gist options
  • Select an option

  • Save incompl/6185579 to your computer and use it in GitHub Desktop.

Select an option

Save incompl/6185579 to your computer and use it in GitHub Desktop.
Gaunt syntax highlighter. Try running it on http://tinysubversions.com/gaunt/
var code = document.querySelector('code');
code.innerHTML = code.innerHTML.replace(/\u0020/g, '<span class="s">\u0020</span>')
.replace(/\u0009/g, '<span class="t">\u0009</span>');
var styleElem = document.createElement('style');
document.getElementsByTagName('head')[0].appendChild(styleElem);
var stylesheet = document.styleSheets[document.styleSheets.length - 1];
stylesheet.insertRule('.s { background-color: #faf; }', 0);
stylesheet.insertRule('.t { background-color: #afa; }', 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment