diff options
| author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-04-18 17:22:04 +0200 | 
|---|---|---|
| committer | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-04-18 17:22:04 +0200 | 
| commit | 2a84bfd4ffdadbedeb1d866e0987e9f8450bc768 (patch) | |
| tree | ad9003203cb275e10690be98cd40a03e57e45757 /script | |
| parent | 811ac6f52e1f9d2ac3c5149b3e56a3cc8f2c94d4 (diff) | |
Add simple osml highlighter
Diffstat (limited to 'script')
| -rw-r--r-- | script/highlight.js | 29 | ||||
| -rw-r--r-- | script/lib/prism_bash.js | 4 | ||||
| -rw-r--r-- | script/lib/prism_osml.js | 41 | 
3 files changed, 43 insertions, 31 deletions
| 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 | 
