Skip to content

Instantly share code, notes, and snippets.

@EbiseLutica
Last active January 30, 2016 04:15
Show Gist options
  • Save EbiseLutica/a032e3748f833bedbb09 to your computer and use it in GitHub Desktop.
Save EbiseLutica/a032e3748f833bedbb09 to your computer and use it in GitHub Desktop.
[].forEach.call(document.querySelectorAll('pre > code'), function(elem){
// highlight.js は <code> 内の先頭と末尾の改行を無視してくれないので、ここで削除
// ※ HTML を書く際、先頭と末尾に改行を入れない方法もある
elem.textContent = elem.textContent.replace(/^[\r\n]+|[\r\n]+$/g, '');
// highlight.js の適用
hljs.highlightBlock(elem);
// highlightjs-line-numbers.js の適用
hljs.lineNumbersBlock(elem);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment