summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/syntax_highlight.js
diff options
context:
space:
mode:
authorMunken <mm.munk@gmail.com>2016-12-09 00:15:08 +0000
committerMunken <mm.munk@gmail.com>2016-12-14 16:50:54 +0000
commit2d170a20dc4cd3423ac7994c797cae8fbed263ba (patch)
tree273aeac77c48c027600afb2da40eee739dd6872e /app/assets/javascripts/syntax_highlight.js
parente3f5c4c5f66c42ebf3c25c4d23507b56843b006d (diff)
downloadgitlab-ce-2d170a20dc4cd3423ac7994c797cae8fbed263ba.tar.gz
Render math in Asciidoc and Markdown with KaTeX using code blocks
Diffstat (limited to 'app/assets/javascripts/syntax_highlight.js')
-rw-r--r--app/assets/javascripts/syntax_highlight.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/app/assets/javascripts/syntax_highlight.js b/app/assets/javascripts/syntax_highlight.js
new file mode 100644
index 00000000000..f4e9d5af74f
--- /dev/null
+++ b/app/assets/javascripts/syntax_highlight.js
@@ -0,0 +1,28 @@
+/* eslint-disable func-names, space-before-function-paren, consistent-return, no-var, no-undef, no-else-return, prefer-arrow-callback, padded-blocks, max-len */
+// Syntax Highlighter
+//
+// Applies a syntax highlighting color scheme CSS class to any element with the
+// `js-syntax-highlight` class
+//
+// ### Example Markup
+//
+// <div class="js-syntax-highlight"></div>
+//
+(function() {
+
+ $.fn.syntaxHighlight = function() {
+ var $children;
+
+ if ($(this).hasClass('js-syntax-highlight')) {
+ // Given the element itself, apply highlighting
+ return $(this).addClass(gon.user_color_scheme);
+ } else {
+ // Given a parent element, recurse to any of its applicable children
+ $children = $(this).find('.js-syntax-highlight');
+ if ($children.length) {
+ return $children.syntaxHighlight();
+ }
+ }
+ };
+
+}).call(this);