summaryrefslogtreecommitdiff
path: root/script/highlight.js
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-03-22 01:14:35 +0100
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-03-22 01:14:35 +0100
commit93119091893c2f2bf396785e6bd7dcbb9b4f207d (patch)
tree408e37ec0bf4ebb1e5427f37b1e12344f70eae9c /script/highlight.js
parentf6fc9fa292e8da56fe7078f9ac5bdfefa55abe94 (diff)
* Implement code highlighting using Prism
* Automatically build ousia.js
Diffstat (limited to 'script/highlight.js')
-rw-r--r--script/highlight.js29
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
+