diff options
Diffstat (limited to 'script/highlight.js')
-rw-r--r-- | script/highlight.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/script/highlight.js b/script/highlight.js new file mode 100644 index 0000000..c50c172 --- /dev/null +++ b/script/highlight.js @@ -0,0 +1,29 @@ +// @license magnet:?xt=urn:btih:5305d91886084f776adcf57509a648432709a7c7&dn=x11.txt +/* + * Ousía Website JS + * + * (c) Andreas Stöckel, 2015 + * + * This work is licensed under the X11 (MIT) license. + * http://www.opensource.org/licenses/mit-license.php + */ +(function () { + "use strict"; + + /* Enable code highlighting (this will eventually be natively supported by + Ousía) */ + document.addEventListener("DOMContentLoaded", function(event) { + var codeBlocks = document.querySelectorAll("pre.code[data-lang]"); + for (var i = 0; i < codeBlocks.length; i++) { + var block = codeBlocks[i]; + var lang = block.getAttribute("data-lang"); + var text = block.textContent; + if (lang in Prism.languages) { + var res = Prism.highlight(text, Prism.languages[lang]); + block.innerHTML = res; + } + } + }); +})(); +// @license-end + |