summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--script/highlight.js29
-rw-r--r--script/lib/prism_bash.js4
-rw-r--r--script/lib/prism_osml.js41
-rw-r--r--style/lib/prism_osml.css8
5 files changed, 52 insertions, 32 deletions
diff --git a/Makefile b/Makefile
index c3f5d79..d0b14e3 100644
--- a/Makefile
+++ b/Makefile
@@ -34,7 +34,7 @@ script/ousia.js: script/lib/*.js
uglifyjs \
script/lib/prism.js \
script/lib/prism_bash.js \
- script/highlight.js > script/ousia.js
+ script/lib/prism_osml.js > script/ousia.js
# Compile all osml files to xml
%.xml: %.osml ontology/*.osml
diff --git a/script/highlight.js b/script/highlight.js
deleted file mode 100644
index c50c172..0000000
--- a/script/highlight.js
+++ /dev/null
@@ -1,29 +0,0 @@
-// @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
-
diff --git a/script/lib/prism_bash.js b/script/lib/prism_bash.js
index 24d5025..903eda6 100644
--- a/script/lib/prism_bash.js
+++ b/script/lib/prism_bash.js
@@ -11,10 +11,10 @@
(function () {
"use strict";
Prism.languages.bash = {
- 'comment': /#.*$/,
+ 'comment': /#.*/,
'string': /("|')(\\\n|\\?.)*?\1/,
'url': /http:\/\/[^\s]*/,
- 'keyword': /(^| )(cd|mkdir|git|echo|clone|sudo|yum|apt-get|cmake|make|install)( |$)/
+ 'keyword': /(^| )(ousia|cd|mkdir|git|echo|clone|sudo|yum|apt-get|cmake|make|install)( |$)/
};
})();
diff --git a/script/lib/prism_osml.js b/script/lib/prism_osml.js
new file mode 100644
index 0000000..728ba9b
--- /dev/null
+++ b/script/lib/prism_osml.js
@@ -0,0 +1,41 @@
+// @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";
+Prism.languages.osml = {
+ 'comment': /%.*/,
+ 'keyword': /(\\begin|\\end|\\import)/,
+ 'function': /\\[a-zA-Z]([a-zA-Z0-9-_]*[a-zA-Z0-9])?/,
+ 'selector': /#[a-zA-Z]([a-zA-Z0-9-_]*[a-zA-Z0-9])?/,
+ 'attributes': {
+ 'pattern': /\[.*\]/,
+ 'inside': {
+ 'property': /[a-zA-Z]([a-zA-Z0-9-_]*[a-zA-Z0-9])?=/,
+ 'keyword': /(true|false|string|int|bool)/,
+ 'string': /("|')(\\\n|\\?.)*?\1/,
+ 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee][+-]?\d+)?)\b/
+ }
+ },
+ 'reference': {
+ 'pattern': /::[^:]*::/,
+ 'inside': {
+ 'field': {
+ 'pattern': /{[^}]*}/,
+ 'inside': {
+ 'selector': /[a-zA-Z]([a-zA-Z0-9-_]*[a-zA-Z0-9])?/
+ }
+ }
+ }
+ }
+};
+})();
+
+// @license-end
diff --git a/style/lib/prism_osml.css b/style/lib/prism_osml.css
new file mode 100644
index 0000000..7a4688e
--- /dev/null
+++ b/style/lib/prism_osml.css
@@ -0,0 +1,8 @@
+/**
+ * prism.js extensions for the OSML highlighter
+ */
+
+code span.token.reference {
+ font-style: italic;
+}
+