From 4fdc5b2b845308816e99451d25937065e749c533 Mon Sep 17 00:00:00 2001
From: Siavash Safi
Date: Wed, 9 Aug 2017 15:25:37 +0200
Subject: [PATCH] Initial commit
---
.gitignore | 3 +
LICENSE | 21 +
README.md | 45 +
pom.xml | 177 +
.../java/com/catawiki/jira/prism/Code.java | 55 +
.../java/com/catawiki/jira/prism/Init.java | 39 +
.../META-INF/spring/plugin-context.xml | 10 +
src/main/resources/atlassian-plugin.xml | 56 +
src/main/resources/css/prism.css | 139 +
src/main/resources/images/pluginIcon.png | Bin 0 -> 251 bytes
src/main/resources/images/pluginLogo.png | Bin 0 -> 1096 bytes
src/main/resources/js/prism-init.js | 7 +
src/main/resources/js/prism.js | 6659 +++++++++++++++++
src/main/resources/soy/prism.soy | 9 +
14 files changed, 7220 insertions(+)
create mode 100644 .gitignore
create mode 100644 LICENSE
create mode 100644 README.md
create mode 100644 pom.xml
create mode 100644 src/main/java/com/catawiki/jira/prism/Code.java
create mode 100644 src/main/java/com/catawiki/jira/prism/Init.java
create mode 100644 src/main/resources/META-INF/spring/plugin-context.xml
create mode 100644 src/main/resources/atlassian-plugin.xml
create mode 100644 src/main/resources/css/prism.css
create mode 100644 src/main/resources/images/pluginIcon.png
create mode 100644 src/main/resources/images/pluginLogo.png
create mode 100644 src/main/resources/js/prism-init.js
create mode 100644 src/main/resources/js/prism.js
create mode 100644 src/main/resources/soy/prism.soy
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..6103cc2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+target/
+.DS_Store
+
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..b34ad2c
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2017 Catawiki B.V.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..490601d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,45 @@
+Prism is a `{code}` macro plugin for Atlassian JIRA.
+
+## Features
+* Support for many programming languages
+* Client side syntax highlighting using [Prism](http://prismjs.com/)
+
+## Build
+Install **Atlassian Plugin SDK** and run `atlas-package`.
+
+## Usage
+Default language is Ruby:
+
+```
+{code}
+class Bar < Foo
+ def initialize(a)
+ @a = a
+ end
+end
+{code}
+```
+
+You can specify another language:
+
+```
+{code:java}
+public class Bar extends Foo {
+ private int a;
+
+ public Bar(int a) {
+ this.a = a;
+ }
+}
+{code}
+```
+
+## Issues
+Visual editing in Rich Text Editor is not supported. While you don't have to disable Rich Text Editor in JIRA, you cannot use the **visual tab** to do code editing.
+
+## Notes
+This plugin uses a slightly modified version of [Prism](http://prismjs.com/) to fix JS compile issues in Atlassian Plugin SDK.
+
+This plugin is released without any support, if you want to add a new feature or fix a bug feel free to submit a PR.
+
+Also check [this JIRA Server issue](https://jira.atlassian.com/browse/JRASERVER-21067) regarding `{code}` macro limitations and why this plugin was developed.
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..893820d
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,177 @@
+
+
+
+
+ 4.0.0
+ com.catawiki.jira
+ prism
+ 1.0.0
+
+
+ Catawiki B.V.
+ https://www.catawiki.com/
+
+
+ Prism
+ Code syntax highlighting plugin for Atlassian JIRA.
+ atlassian-plugin
+
+
+
+ com.atlassian.jira
+ jira-api
+ ${jira.version}
+ provided
+
+
+ com.atlassian.jira
+ jira-core
+ ${jira.version}
+ provided
+
+
+ junit
+ junit
+ 4.10
+ test
+
+
+
+ com.atlassian.plugin
+ atlassian-spring-scanner-annotation
+ ${atlassian.spring.scanner.version}
+ compile
+
+
+
+ com.atlassian.plugin
+ atlassian-spring-scanner-runtime
+ ${atlassian.spring.scanner.version}
+ runtime
+
+
+
+ javax.inject
+ javax.inject
+ 1
+ provided
+
+
+
+
+ com.atlassian.plugins
+ atlassian-plugins-osgi-testrunner
+ ${plugin.testrunner.version}
+ test
+
+
+ javax.ws.rs
+ jsr311-api
+ 1.1.1
+ provided
+
+
+ com.google.code.gson
+ gson
+ 2.2.2-atlassian-1
+
+
+
+
+
+
+
+
+
+
+ com.atlassian.maven.plugins
+ maven-jira-plugin
+ ${amps.version}
+ true
+
+ ${jira.version}
+ ${jira.version}
+
+
+ true
+ false
+
+
+
+
+
+
+
+
+ com.catawiki.jira.prism,
+
+
+
+
+ org.springframework.osgi.*;resolution:="optional",
+ org.eclipse.gemini.blueprint.*;resolution:="optional",
+ *
+
+
+
+ *
+
+
+
+
+
+ com.atlassian.plugin
+ atlassian-spring-scanner-maven-plugin
+ ${atlassian.spring.scanner.version}
+
+
+
+ atlassian-spring-scanner
+
+ process-classes
+
+
+
+
+
+ com.atlassian.plugin
+ atlassian-spring-scanner-external-jar
+
+
+ false
+
+
+
+
+
+
+ 7.2.2
+ 6.2.11
+ 1.2.3
+ 1.2.13
+
+ ${project.groupId}.${project.artifactId}
+
+ 6.3.11
+
+
+
diff --git a/src/main/java/com/catawiki/jira/prism/Code.java b/src/main/java/com/catawiki/jira/prism/Code.java
new file mode 100644
index 0000000..7d57096
--- /dev/null
+++ b/src/main/java/com/catawiki/jira/prism/Code.java
@@ -0,0 +1,55 @@
+package com.catawiki.jira.prism;
+
+import com.atlassian.jira.template.soy.SoyTemplateRendererProvider;
+import com.atlassian.renderer.RenderContext;
+import com.atlassian.renderer.v2.RenderMode;
+import com.atlassian.renderer.v2.macro.BaseMacro;
+import com.atlassian.renderer.v2.macro.MacroException;
+import com.atlassian.soy.renderer.SoyException;
+import com.atlassian.soy.renderer.SoyTemplateRenderer;
+import com.google.common.collect.ImmutableMap;
+
+import java.util.Map;
+
+public class Code extends BaseMacro {
+
+ private static final String FALLBACK_RENDER_OUTPUT = "{noformat}%s{noformat}";
+
+ private final SoyTemplateRenderer soyTemplateRenderer;
+
+ public Code(final SoyTemplateRendererProvider soyTemplateRendererProvider) {
+ super();
+ this.soyTemplateRenderer = soyTemplateRendererProvider.getRenderer();
+ }
+
+ @Override
+ public boolean hasBody() {
+ return true;
+ }
+
+ @Override
+ public RenderMode getBodyRenderMode() {
+ return RenderMode.allow(RenderMode.F_NONE);
+ }
+
+ @Override
+ public String execute(Map parameters, String body, RenderContext renderContext) throws MacroException {
+
+ ImmutableMap.Builder templateParams = ImmutableMap.builder();
+ templateParams.put("content", body);
+ String language = "ruby";
+ if (parameters.get("0") != null) {
+ language = (String) parameters.get("0");
+ }
+ templateParams.put("language", language);
+
+ try {
+ return this.soyTemplateRenderer.render(
+ "com.catawiki.jira.prism:handler",
+ "Prism.Macros.Code.html",
+ templateParams.build());
+ } catch (SoyException e) {
+ return String.format(FALLBACK_RENDER_OUTPUT, body);
+ }
+ }
+}
diff --git a/src/main/java/com/catawiki/jira/prism/Init.java b/src/main/java/com/catawiki/jira/prism/Init.java
new file mode 100644
index 0000000..c9cc1a1
--- /dev/null
+++ b/src/main/java/com/catawiki/jira/prism/Init.java
@@ -0,0 +1,39 @@
+package com.catawiki.jira.prism;
+
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.beans.factory.InitializingBean;
+
+import com.atlassian.plugin.PluginController;
+
+public class Init implements InitializingBean, DisposableBean {
+
+ private static final String STANDARD_JIRA_CODE_MACRO = "com.atlassian.jira.plugin.system.renderers.wiki.macros:code";
+ private static final String STANDARD_JIRA_NOFORMAT_MACRO = "com.atlassian.jira.plugin.system.renderers.wiki.macros:noformat";
+
+ private final PluginController pluginController;
+
+ public Init(PluginController pc){
+ this.pluginController = pc;
+ }
+
+ /**
+ * Called when JIRA Syntax Highlighter is being disabled or removed. Enables JIRA standard
+ * Wiki Renderer Macro Plugin for {code}.
+ *
+ * @throws Exception
+ */
+ public void destroy() throws Exception {
+ pluginController.enablePluginModule(STANDARD_JIRA_CODE_MACRO);
+ }
+
+ /**
+ * Called when JIRA Syntax Highlighter has been enabled. Disables JIRA standard Wiki Renderer
+ * Macro Plugin for {code}.
+ *
+ * @throws Exception
+ */
+ public void afterPropertiesSet() throws Exception {
+ pluginController.disablePluginModule(STANDARD_JIRA_CODE_MACRO);
+ }
+
+}
diff --git a/src/main/resources/META-INF/spring/plugin-context.xml b/src/main/resources/META-INF/spring/plugin-context.xml
new file mode 100644
index 0000000..b1f0519
--- /dev/null
+++ b/src/main/resources/META-INF/spring/plugin-context.xml
@@ -0,0 +1,10 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/atlassian-plugin.xml b/src/main/resources/atlassian-plugin.xml
new file mode 100644
index 0000000..f78128f
--- /dev/null
+++ b/src/main/resources/atlassian-plugin.xml
@@ -0,0 +1,56 @@
+
+
+ ${project.description}
+ ${project.version}
+
+ images/pluginIcon.png
+ images/pluginLogo.png
+
+
+
+
+ jira.navigator.advanced
+ jira.navigator.simple
+ jira.view.issue
+ gh-rapid
+
+ ${atlassian.plugin.key}:handler
+
+
+
+
+
+
+ jira.rich.editor
+
+ com.atlassian.jira.plugins.jira-editor-plugin:converter
+
+
+
+
+
+
+
+
+
+ jira.navigator.advanced
+ jira.navigator.simple
+ jira.view.issue
+ gh-rapid
+
+
+
+
+
+ Syntax highlighting for code blocks.
+ code-macro
+ Prism.Macros.Code.convert
+
+
+
+ Helper module to automatic disabling / enabling of JIRA standard code macro on
+ installation or enabling / deinstallation or disabling of Prism Syntax Highlighter plugin
+
+
diff --git a/src/main/resources/css/prism.css b/src/main/resources/css/prism.css
new file mode 100644
index 0000000..e58253b
--- /dev/null
+++ b/src/main/resources/css/prism.css
@@ -0,0 +1,139 @@
+/* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript+abap+actionscript+ada+apacheconf+apl+applescript+asciidoc+aspnet+autoit+autohotkey+bash+basic+batch+c+brainfuck+bro+bison+csharp+cpp+coffeescript+ruby+css-extras+d+dart+django+diff+docker+eiffel+elixir+erlang+fsharp+fortran+gherkin+git+glsl+go+graphql+groovy+haml+handlebars+haskell+haxe+http+icon+inform7+ini+j+jade+java+jolie+json+julia+keyman+kotlin+latex+less+livescript+lolcode+lua+makefile+markdown+matlab+mel+mizar+monkey+nasm+nginx+nim+nix+nsis+objectivec+ocaml+oz+parigp+parser+pascal+perl+php+php-extras+powershell+processing+prolog+properties+protobuf+puppet+pure+python+q+qore+r+jsx+reason+rest+rip+roboconf+crystal+rust+sas+sass+scss+scala+scheme+smalltalk+smarty+sql+stylus+swift+tcl+textile+twig+typescript+vbnet+verilog+vhdl+vim+wiki+xojo+yaml */
+/**
+ * prism.js default theme for JavaScript, CSS and HTML
+ * Based on dabblet (http://dabblet.com)
+ * @author Lea Verou
+ */
+
+code[class*="language-"],
+pre[class*="language-"] {
+ color: black;
+ background: none;
+ text-shadow: 0 1px white;
+ font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
+ text-align: left;
+ white-space: pre;
+ word-spacing: normal;
+ word-break: normal;
+ word-wrap: normal;
+ line-height: 1.5;
+
+ -moz-tab-size: 4;
+ -o-tab-size: 4;
+ tab-size: 4;
+
+ -webkit-hyphens: none;
+ -moz-hyphens: none;
+ -ms-hyphens: none;
+ hyphens: none;
+}
+
+pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
+code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
+ text-shadow: none;
+ background: #b3d4fc;
+}
+
+pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
+code[class*="language-"]::selection, code[class*="language-"] ::selection {
+ text-shadow: none;
+ background: #b3d4fc;
+}
+
+@media print {
+ code[class*="language-"],
+ pre[class*="language-"] {
+ text-shadow: none;
+ }
+}
+
+/* Code blocks */
+pre[class*="language-"] {
+ padding: 1em;
+ margin: .5em 0;
+ overflow: auto;
+}
+
+:not(pre) > code[class*="language-"],
+pre[class*="language-"] {
+ background: #f5f2f0;
+}
+
+/* Inline code */
+:not(pre) > code[class*="language-"] {
+ padding: .1em;
+ border-radius: .3em;
+ white-space: normal;
+}
+
+.token.comment,
+.token.prolog,
+.token.doctype,
+.token.cdata {
+ color: slategray;
+}
+
+.token.punctuation {
+ color: #999;
+}
+
+.namespace {
+ opacity: .7;
+}
+
+.token.property,
+.token.tag,
+.token.boolean,
+.token.number,
+.token.constant,
+.token.symbol,
+.token.deleted {
+ color: #905;
+}
+
+.token.selector,
+.token.attr-name,
+.token.string,
+.token.char,
+.token.builtin,
+.token.inserted {
+ color: #690;
+}
+
+.token.operator,
+.token.entity,
+.token.url,
+.language-css .token.string,
+.style .token.string {
+ color: #a67f59;
+ background: hsla(0, 0%, 100%, .5);
+}
+
+.token.atrule,
+.token.attr-value,
+.token.keyword {
+ color: #07a;
+}
+
+.token.function {
+ color: #DD4A68;
+}
+
+.token.regex,
+.token.important,
+.token.variable {
+ color: #e90;
+}
+
+.token.important,
+.token.bold {
+ font-weight: bold;
+}
+.token.italic {
+ font-style: italic;
+}
+
+.token.entity {
+ cursor: help;
+}
+
diff --git a/src/main/resources/images/pluginIcon.png b/src/main/resources/images/pluginIcon.png
new file mode 100644
index 0000000000000000000000000000000000000000..1520c5bb0fc9d97bfe10a18bcdad0ff65abc58e9
GIT binary patch
literal 251
zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`hdf;zLoEEKPHyBqWWd96U)q34
znnBpXJb^hZg?STW4}Cf)NDWX!5&+@WdZkiZ{Y!Ejz~*$?J3H|~n)CZv=H
z|6$;M8`~wd;mEzECmK%uV=Q1T*jAb^E6q?Nx9uInlbsq3N$L;y9xybd=iIvWkLdyD
zgH+*J&z;!H>%+^;gpNG2Jh+A@qWJr_vw5QHBR{1T#9)aA?bG
zCqh;^v@LA%!YHFHZP6_&C=|9P$K@z#;C>;lpH_L_04c9%y&qD*Zs_sklN8BtyrRb_ZhPIuX9?~01s
z;lgqQaMax;qe0N@Hf@m4$+;eX?k15bW_YFr?0ae!HT{s6m>lF8H|QNq&IQiONFfpq
z>4t9yT6Da{<@j^DK&D{Bwuj>@buPV{5@ZqA$_S^sTT&m3o5{u2iJXZ*Gy()Da_W&Z
z*s03lBM)Gw0%sN^DY2gr2Gq-O(m;|1>p&g=y$WXx1}m{9gaOoYoRctEgP}+#RI6~t
zK(P|LkI><|9Oon`)?n>OCs
zpmk&4BWjSV#OZ)EHP(m(gIpC(2cY#})kq%9)!;nh9nPHi0-XfY<%|w`fSKxG>FG0x
zM9zr~nUd+v#3eJFPj>wx5=YVZ&~|5dawS74Yl8U?vt_+AtX>3B^~|2>4tC6ua^J5C$uL_
zGDtkppP6rtU9{t6=WqVH-Q^0JU&@dZJkhcMu7-G+E%dzVQv80)o8nfP-|OH$Z+sCs
zF5A2N%YS6yS4`KOsx@cO7M_z)0Jjzn51g(7K3uu3p5@jQZtDljB@#b#Pxf}ivE&M^
zWt%gzn>+@OE3QGGNz{tEio
z>K3aAzm@F26fIW+OF9t_E37NRN}Vf{WKxoolDkE@MY#k3@qGUcPwUN_MJANGVtOqN
z?KABOS{il2QX text.length) {
+ // Something went terribly wrong, ABORT, ABORT!
+ return;
+ }
+
+ if (str instanceof Token) {
+ continue;
+ }
+
+ pattern.lastIndex = 0;
+
+ var match = pattern.exec(str),
+ delNum = 1;
+
+ // Greedy patterns can override/remove up to two previously matched tokens
+ if (!match && greedy && i != strarr.length - 1) {
+ pattern.lastIndex = pos;
+ match = pattern.exec(text);
+ if (!match) {
+ break;
+ }
+
+ var from = match.index + (lookbehind ? match[1].length : 0),
+ to = match.index + match[0].length,
+ k = i,
+ p = pos;
+
+ for (var len = strarr.length; k < len && (p < to || (!strarr[k].type && !strarr[k - 1].greedy)); ++k) {
+ p += strarr[k].length;
+ // Move the index i to the element in strarr that is closest to from
+ if (from >= p) {
+ ++i;
+ pos = p;
+ }
+ }
+
+ /*
+ * If strarr[i] is a Token, then the match starts inside another Token, which is invalid
+ * If strarr[k - 1] is greedy we are in conflict with another greedy pattern
+ */
+ if (strarr[i] instanceof Token || strarr[k - 1].greedy) {
+ continue;
+ }
+
+ // Number of tokens to delete and replace with the new match
+ delNum = k - i;
+ str = text.slice(pos, p);
+ match.index -= pos;
+ }
+
+ if (!match) {
+ if (oneshot) {
+ break;
+ }
+
+ continue;
+ }
+
+ if(lookbehind) {
+ lookbehindLength = match[1].length;
+ }
+
+ var from = match.index + lookbehindLength,
+ match = match[0].slice(lookbehindLength),
+ to = from + match.length,
+ before = str.slice(0, from),
+ after = str.slice(to);
+
+ var args = [i, delNum];
+
+ if (before) {
+ ++i;
+ pos += before.length;
+ args.push(before);
+ }
+
+ var wrapped = new Token(token, inside? _.tokenize(match, inside) : match, alias, match, greedy);
+
+ args.push(wrapped);
+
+ if (after) {
+ args.push(after);
+ }
+
+ Array.prototype.splice.apply(strarr, args);
+
+ if (delNum != 1)
+ _.matchGrammar(text, strarr, grammar, i, pos, true, token);
+
+ if (oneshot)
+ break;
+ }
+ }
+ }
+ },
+
+ tokenize: function(text, grammar, language) {
+ var strarr = [text];
+
+ var rest = grammar.rest;
+
+ if (rest) {
+ for (var token in rest) {
+ grammar[token] = rest[token];
+ }
+
+ delete grammar.rest;
+ }
+
+ _.matchGrammar(text, strarr, grammar, 0, 0, false);
+
+ return strarr;
+ },
+
+ hooks: {
+ all: {},
+
+ add: function (name, callback) {
+ var hooks = _.hooks.all;
+
+ hooks[name] = hooks[name] || [];
+
+ hooks[name].push(callback);
+ },
+
+ run: function (name, env) {
+ var callbacks = _.hooks.all[name];
+
+ if (!callbacks || !callbacks.length) {
+ return;
+ }
+
+ for (var i=0, callback; callback = callbacks[i++];) {
+ callback(env);
+ }
+ }
+ }
+};
+
+var Token = _.Token = function(type, content, alias, matchedStr, greedy) {
+ this.type = type;
+ this.content = content;
+ this.alias = alias;
+ // Copy of the full string this token was created from
+ this.length = (matchedStr || "").length|0;
+ this.greedy = !!greedy;
+};
+
+Token.stringify = function(o, language, parent) {
+ if (typeof o == 'string') {
+ return o;
+ }
+
+ if (_.util.type(o) === 'Array') {
+ return o.map(function(element) {
+ return Token.stringify(element, language, o);
+ }).join('');
+ }
+
+ var env = {
+ type: o.type,
+ content: Token.stringify(o.content, language, parent),
+ tag: 'span',
+ classes: ['token', o.type],
+ attributes: {},
+ language: language,
+ parent: parent
+ };
+
+ if (env.type == 'comment') {
+ env.attributes['spellcheck'] = 'true';
+ }
+
+ if (o.alias) {
+ var aliases = _.util.type(o.alias) === 'Array' ? o.alias : [o.alias];
+ Array.prototype.push.apply(env.classes, aliases);
+ }
+
+ _.hooks.run('wrap', env);
+
+ var attributes = Object.keys(env.attributes).map(function(name) {
+ return name + '="' + (env.attributes[name] || '').replace(/"/g, '"') + '"';
+ }).join(' ');
+
+ return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + (attributes ? ' ' + attributes : '') + '>' + env.content + '';
+
+};
+
+if (!_self.document) {
+ if (!_self.addEventListener) {
+ // in Node.js
+ return _self.Prism;
+ }
+ // In worker
+ _self.addEventListener('message', function(evt) {
+ var message = JSON.parse(evt.data),
+ lang = message.language,
+ code = message.code,
+ immediateClose = message.immediateClose;
+
+ _self.postMessage(_.highlight(code, _.languages[lang], lang));
+ if (immediateClose) {
+ _self.close();
+ }
+ }, false);
+
+ return _self.Prism;
+}
+
+//Get current script and highlight
+var script = document.currentScript || [].slice.call(document.getElementsByTagName("script")).pop();
+
+if (script) {
+ _.filename = script.src;
+
+ if (document.addEventListener && !_.manual && !script.hasAttribute('data-manual')) {
+ if(document.readyState !== "loading") {
+ if (window.requestAnimationFrame) {
+ window.requestAnimationFrame(_.highlightAll);
+ } else {
+ window.setTimeout(_.highlightAll, 16);
+ }
+ }
+ else {
+ document.addEventListener('DOMContentLoaded', _.highlightAll);
+ }
+ }
+}
+
+return _self.Prism;
+
+})();
+
+if (typeof module !== 'undefined' && module.exports) {
+ module.exports = Prism;
+}
+
+// hack for components to work correctly in node.js
+if (typeof global !== 'undefined') {
+ global.Prism = Prism;
+}
+;
+Prism.languages.markup = {
+ 'comment': //,
+ 'prolog': /<\?[\s\S]+?\?>/,
+ 'doctype': //i,
+ 'cdata': //i,
+ 'tag': {
+ pattern: /<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\s\S])*\1|[^\s'">=]+))?)*\s*\/?>/i,
+ inside: {
+ 'tag': {
+ pattern: /^<\/?[^\s>\/]+/i,
+ inside: {
+ 'punctuation': /^<\/?/,
+ 'namespace': /^[^\s>\/:]+:/
+ }
+ },
+ 'attr-value': {
+ pattern: /=(?:('|")[\s\S]*?(\1)|[^\s>]+)/i,
+ inside: {
+ 'punctuation': /[=>"']/
+ }
+ },
+ 'punctuation': /\/?>/,
+ 'attr-name': {
+ pattern: /[^\s>\/]+/,
+ inside: {
+ 'namespace': /^[^\s>\/:]+:/
+ }
+ }
+
+ }
+ },
+ 'entity': /&#?[\da-z]{1,8};/i
+};
+
+Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
+ Prism.languages.markup['entity'];
+
+// Plugin to make entity title show the real entity, idea by Roman Komarov
+Prism.hooks.add('wrap', function(env) {
+
+ if (env.type === 'entity') {
+ env.attributes['title'] = env.content.replace(/&/, '&');
+ }
+});
+
+Prism.languages.xml = Prism.languages.markup;
+Prism.languages.html = Prism.languages.markup;
+Prism.languages.mathml = Prism.languages.markup;
+Prism.languages.svg = Prism.languages.markup;
+
+Prism.languages.css = {
+ 'comment': /\/\*[\s\S]*?\*\//,
+ 'atrule': {
+ pattern: /@[\w-]+?.*?(;|(?=\s*\{))/i,
+ inside: {
+ 'rule': /@[\w-]+/
+ // See rest below
+ }
+ },
+ 'url': /url\((?:(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,
+ 'selector': /[^\{\}\s][^\{\};]*?(?=\s*\{)/,
+ 'string': {
+ pattern: /("|')(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
+ greedy: true
+ },
+ 'property': /(\b|\B)[\w-]+(?=\s*:)/i,
+ 'important': /\B!important\b/i,
+ 'function': /[-a-z0-9]+(?=\()/i,
+ 'punctuation': /[(){};:]/
+};
+
+Prism.languages.css['atrule'].inside.rest = Prism.util.clone(Prism.languages.css);
+
+if (Prism.languages.markup) {
+ Prism.languages.insertBefore('markup', 'tag', {
+ 'style': {
+ pattern: /(