From 863f5f186d0a4c2030b9face109f37ad45c7155a Mon Sep 17 00:00:00 2001 From: thien Date: Fri, 6 May 2016 21:17:47 +0700 Subject: [PATCH 01/12] add plugin custom class name --- components.js | 4 + plugins/custom-class-name/example-0-format.js | 4 + .../custom-class-name/example-0-order.html | 8 ++ .../custom-class-name/example-1-class-map.js | 4 + plugins/custom-class-name/example-1-input.js | 1 + .../custom-class-name/example-1-output.html | 7 ++ plugins/custom-class-name/example-2.js | 13 +++ plugins/custom-class-name/index.html | 102 ++++++++++++++++++ .../prism-custom-class-name.js | 29 +++++ 9 files changed, 172 insertions(+) create mode 100644 plugins/custom-class-name/example-0-format.js create mode 100644 plugins/custom-class-name/example-0-order.html create mode 100644 plugins/custom-class-name/example-1-class-map.js create mode 100644 plugins/custom-class-name/example-1-input.js create mode 100644 plugins/custom-class-name/example-1-output.html create mode 100644 plugins/custom-class-name/example-2.js create mode 100644 plugins/custom-class-name/index.html create mode 100644 plugins/custom-class-name/prism-custom-class-name.js diff --git a/components.js b/components.js index 1a2a881b55..aeccc6101c 100644 --- a/components.js +++ b/components.js @@ -552,6 +552,10 @@ var components = { "show-invisibles": "Show Invisibles", "autolinker": "Autolinker", "wpd": "WebPlatform Docs", + "custom-class-name": { + "title": "Custom Class Name", + "owner": "dvkndn" + }, "file-highlight": { "title": "File Highlight", "noCSS": true diff --git a/plugins/custom-class-name/example-0-format.js b/plugins/custom-class-name/example-0-format.js new file mode 100644 index 0000000000..13a07d2a0c --- /dev/null +++ b/plugins/custom-class-name/example-0-format.js @@ -0,0 +1,4 @@ +myClassMap = { + tokenName: newClassName + // ... +} \ No newline at end of file diff --git a/plugins/custom-class-name/example-0-order.html b/plugins/custom-class-name/example-0-order.html new file mode 100644 index 0000000000..45173e8f88 --- /dev/null +++ b/plugins/custom-class-name/example-0-order.html @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/plugins/custom-class-name/example-1-class-map.js b/plugins/custom-class-name/example-1-class-map.js new file mode 100644 index 0000000000..4eca784777 --- /dev/null +++ b/plugins/custom-class-name/example-1-class-map.js @@ -0,0 +1,4 @@ +var myClassMap = { + keyword: 'my-special-keyword', + string: 'my-string' +} \ No newline at end of file diff --git a/plugins/custom-class-name/example-1-input.js b/plugins/custom-class-name/example-1-input.js new file mode 100644 index 0000000000..9f6197b5f4 --- /dev/null +++ b/plugins/custom-class-name/example-1-input.js @@ -0,0 +1 @@ +var foo = 'bar'; \ No newline at end of file diff --git a/plugins/custom-class-name/example-1-output.html b/plugins/custom-class-name/example-1-output.html new file mode 100644 index 0000000000..0fc6d09521 --- /dev/null +++ b/plugins/custom-class-name/example-1-output.html @@ -0,0 +1,7 @@ + + var + foo + = + 'bar' + ; + \ No newline at end of file diff --git a/plugins/custom-class-name/example-2.js b/plugins/custom-class-name/example-2.js new file mode 100644 index 0000000000..e01fdfa4dd --- /dev/null +++ b/plugins/custom-class-name/example-2.js @@ -0,0 +1,13 @@ +// require prism and plugins +import Prism from 'prismjs'; + +// require the style map using CSS Modules +import tokenStyleMap from 'styles/demo/code-token.css'; + +// apply the style map +Prism.plugins.customClassName.use(tokenStyleMap) + +// now Prism will auto highlight all elements after page loaded. + +// or you can manually use Prism like in API Documentation: +var html = Prism.highlight('var foo = \'bar\'', Prism.languages.javascript); \ No newline at end of file diff --git a/plugins/custom-class-name/index.html b/plugins/custom-class-name/index.html new file mode 100644 index 0000000000..75005530a0 --- /dev/null +++ b/plugins/custom-class-name/index.html @@ -0,0 +1,102 @@ + + + + + + +Custom Class Name ▲ Prism plugins + + + + + + + + + + +
+
+ +

Custom Class Name

+

This plugin allows you to replace Prism default class names (like .comment, .string, .property, etc) with your defined ones (like .editor__comment (BEM style) or ._7sh3a (CSS Modules hashed class)).

+
+ +
+

How to use

+ +

You define new class names in a simple key-value object and pass it to Prism.plugins.customClassName.use(yourObject). + +

Each key of the object is the name of the token (eg: comment) which you want to replace its classes. The value is the class name to replace (eg: my-special-comment).

+ +

+
+	

Please note that this function should be called after Prism and the plugin. For example:

+ +

+
+
+ +
+

Example

+ +

For example, let highlight the following source code:

+

+
+	

Using the following class map object:

+

+
+	

Then the result html should be:

+

+
+	

You can see that the class names of the keyword (var) and string ('bar') was changed. However, the class names of operator (=) and punctuation (;) was not changed because you didn't define their custom class names. + +

You can also inspect-element the input source code above to see how it works.

+
+ +
+

Usage with CSS Modules

+ +

The initial purpose of this plugin is to use with CSS Modules. It works perfectly with the class map object returned by CSS Modules. For example:

+

+
+ +
+

Todo

+ +
+ + + + + + + + + + + + diff --git a/plugins/custom-class-name/prism-custom-class-name.js b/plugins/custom-class-name/prism-custom-class-name.js new file mode 100644 index 0000000000..5ca069e00b --- /dev/null +++ b/plugins/custom-class-name/prism-custom-class-name.js @@ -0,0 +1,29 @@ +(function(){ + +if ( + typeof self !== 'undefined' && !self.Prism || + typeof global !== 'undefined' && !global.Prism +) { + return; +} + +var classMap; +Prism.plugins.customClassName = { + use: function use(map) { + classMap = map; + } +} + +Prism.hooks.add('wrap', function (env) { + if (!classMap) { + return; + } + + var customClassName = classMap[env.type]; + // if style found, then replace + if (typeof customClassName === 'string') { + env.classes = [customClassName]; + } +}); + +})(); From e9355cc4920207dc1b80b15d9c27a8b0646b3bd4 Mon Sep 17 00:00:00 2001 From: dvkndn Date: Mon, 15 Aug 2016 02:43:09 +0700 Subject: [PATCH 02/12] add prefix feature for custom class plugin --- components.js | 4 +- components/prism-markup.min.js | 2 +- plugins/custom-class-name/example-0-format.js | 4 - .../custom-class-name/example-0-order.html | 8 -- .../custom-class-name/example-1-class-map.js | 4 - plugins/custom-class-name/example-1-input.js | 1 - .../custom-class-name/example-1-output.html | 7 - plugins/custom-class-name/example-2.js | 13 -- plugins/custom-class-name/index.html | 102 -------------- .../prism-custom-class-name.js | 29 ---- plugins/custom-class/index.html | 133 ++++++++++++++++++ plugins/custom-class/prism-custom-class.js | 29 ++++ .../custom-class/prism-custom-class.min.js | 1 + prism.js | 2 +- 14 files changed, 167 insertions(+), 172 deletions(-) delete mode 100644 plugins/custom-class-name/example-0-format.js delete mode 100644 plugins/custom-class-name/example-0-order.html delete mode 100644 plugins/custom-class-name/example-1-class-map.js delete mode 100644 plugins/custom-class-name/example-1-input.js delete mode 100644 plugins/custom-class-name/example-1-output.html delete mode 100644 plugins/custom-class-name/example-2.js delete mode 100644 plugins/custom-class-name/index.html delete mode 100644 plugins/custom-class-name/prism-custom-class-name.js create mode 100644 plugins/custom-class/index.html create mode 100644 plugins/custom-class/prism-custom-class.js create mode 100644 plugins/custom-class/prism-custom-class.min.js diff --git a/components.js b/components.js index bbe8b1f18b..0b2b48ad6b 100644 --- a/components.js +++ b/components.js @@ -572,8 +572,8 @@ var components = { "show-invisibles": "Show Invisibles", "autolinker": "Autolinker", "wpd": "WebPlatform Docs", - "custom-class-name": { - "title": "Custom Class Name", + "custom-class": { + "title": "Custom Class", "owner": "dvkndn" }, "file-highlight": { diff --git a/components/prism-markup.min.js b/components/prism-markup.min.js index 6e924b9a1b..edda541209 100644 --- a/components/prism-markup.min.js +++ b/components/prism-markup.min.js @@ -1 +1 @@ -Prism.languages.markup={comment://,prolog:/<\?[\w\W]+?\?>/,doctype://,cdata://i,tag:{pattern:/<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,inside:{punctuation:/[=>"']/}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/&#?[\da-z]{1,8};/i},Prism.hooks.add("wrap",function(a){"entity"===a.type&&(a.attributes.title=a.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; \ No newline at end of file +Prism.languages.markup={comment://,prolog:/<\?[\w\W]+?\?>/,doctype://i,cdata://i,tag:{pattern:/<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,inside:{punctuation:/[=>"']/}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/&#?[\da-z]{1,8};/i},Prism.hooks.add("wrap",function(a){"entity"===a.type&&(a.attributes.title=a.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; \ No newline at end of file diff --git a/plugins/custom-class-name/example-0-format.js b/plugins/custom-class-name/example-0-format.js deleted file mode 100644 index 13a07d2a0c..0000000000 --- a/plugins/custom-class-name/example-0-format.js +++ /dev/null @@ -1,4 +0,0 @@ -myClassMap = { - tokenName: newClassName - // ... -} \ No newline at end of file diff --git a/plugins/custom-class-name/example-0-order.html b/plugins/custom-class-name/example-0-order.html deleted file mode 100644 index 45173e8f88..0000000000 --- a/plugins/custom-class-name/example-0-order.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/plugins/custom-class-name/example-1-class-map.js b/plugins/custom-class-name/example-1-class-map.js deleted file mode 100644 index 4eca784777..0000000000 --- a/plugins/custom-class-name/example-1-class-map.js +++ /dev/null @@ -1,4 +0,0 @@ -var myClassMap = { - keyword: 'my-special-keyword', - string: 'my-string' -} \ No newline at end of file diff --git a/plugins/custom-class-name/example-1-input.js b/plugins/custom-class-name/example-1-input.js deleted file mode 100644 index 9f6197b5f4..0000000000 --- a/plugins/custom-class-name/example-1-input.js +++ /dev/null @@ -1 +0,0 @@ -var foo = 'bar'; \ No newline at end of file diff --git a/plugins/custom-class-name/example-1-output.html b/plugins/custom-class-name/example-1-output.html deleted file mode 100644 index 0fc6d09521..0000000000 --- a/plugins/custom-class-name/example-1-output.html +++ /dev/null @@ -1,7 +0,0 @@ - - var - foo - = - 'bar' - ; - \ No newline at end of file diff --git a/plugins/custom-class-name/example-2.js b/plugins/custom-class-name/example-2.js deleted file mode 100644 index e01fdfa4dd..0000000000 --- a/plugins/custom-class-name/example-2.js +++ /dev/null @@ -1,13 +0,0 @@ -// require prism and plugins -import Prism from 'prismjs'; - -// require the style map using CSS Modules -import tokenStyleMap from 'styles/demo/code-token.css'; - -// apply the style map -Prism.plugins.customClassName.use(tokenStyleMap) - -// now Prism will auto highlight all elements after page loaded. - -// or you can manually use Prism like in API Documentation: -var html = Prism.highlight('var foo = \'bar\'', Prism.languages.javascript); \ No newline at end of file diff --git a/plugins/custom-class-name/index.html b/plugins/custom-class-name/index.html deleted file mode 100644 index 75005530a0..0000000000 --- a/plugins/custom-class-name/index.html +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - -Custom Class Name ▲ Prism plugins - - - - - - - - - - -
-
- -

Custom Class Name

-

This plugin allows you to replace Prism default class names (like .comment, .string, .property, etc) with your defined ones (like .editor__comment (BEM style) or ._7sh3a (CSS Modules hashed class)).

-
- -
-

How to use

- -

You define new class names in a simple key-value object and pass it to Prism.plugins.customClassName.use(yourObject). - -

Each key of the object is the name of the token (eg: comment) which you want to replace its classes. The value is the class name to replace (eg: my-special-comment).

- -

-
-	

Please note that this function should be called after Prism and the plugin. For example:

- -

-
-
- -
-

Example

- -

For example, let highlight the following source code:

-

-
-	

Using the following class map object:

-

-
-	

Then the result html should be:

-

-
-	

You can see that the class names of the keyword (var) and string ('bar') was changed. However, the class names of operator (=) and punctuation (;) was not changed because you didn't define their custom class names. - -

You can also inspect-element the input source code above to see how it works.

-
- -
-

Usage with CSS Modules

- -

The initial purpose of this plugin is to use with CSS Modules. It works perfectly with the class map object returned by CSS Modules. For example:

-

-
- -
-

Todo

-
    -
  • Allow value to be an array of string (eg: {keyword: ['foo', 'bar']})
  • -
  • Allow value to be a string with space delimiter({keyword: 'foo bar'})
  • -
  • Option to keep the default class name (eg: <span class="token keyword custom-class">var</span>)
  • -
  • Allow to custom tokens per language, using nested object (Instruction: Issue #947)
  • -
-
- -
- - - - - - - - - - diff --git a/plugins/custom-class-name/prism-custom-class-name.js b/plugins/custom-class-name/prism-custom-class-name.js deleted file mode 100644 index 5ca069e00b..0000000000 --- a/plugins/custom-class-name/prism-custom-class-name.js +++ /dev/null @@ -1,29 +0,0 @@ -(function(){ - -if ( - typeof self !== 'undefined' && !self.Prism || - typeof global !== 'undefined' && !global.Prism -) { - return; -} - -var classMap; -Prism.plugins.customClassName = { - use: function use(map) { - classMap = map; - } -} - -Prism.hooks.add('wrap', function (env) { - if (!classMap) { - return; - } - - var customClassName = classMap[env.type]; - // if style found, then replace - if (typeof customClassName === 'string') { - env.classes = [customClassName]; - } -}); - -})(); diff --git a/plugins/custom-class/index.html b/plugins/custom-class/index.html new file mode 100644 index 0000000000..3a289eac20 --- /dev/null +++ b/plugins/custom-class/index.html @@ -0,0 +1,133 @@ + + + + + + +Custom Class ▲ Prism plugins + + + + + + + + + +
+
+ +

Custom Class

+

This plugin allows you to prefix Prism default classes (.comment will become .namespace--comment) or replace them with your defined ones (like .editor__comment or .comment_7sh3a).

+
+ +
+

Motivation

+ +

Prism default classes are sensible but fixed and too generic. This plugin provide some ways to customize those classes to suite your needs. Example usages:

+ +
    +
  • + You want to add namespace for all of them (like .prism--comment) to avoid conflict with your existed classes. +
  • +
  • + You use a naming convention (like BEM). You want to write classes like .editor__comment. +
  • +
  • You use + CSS Modules. You want to use your hashed classes, like .comment_7sh3a. +
  • +
+ +

Features

+ +

This plugin currently provides 2 features:

+ +

1. Prefix all Prism classes with a string

+ + Prism.plugins.customClass.prefix('prism--') + +

2. Replace some Prism classes with your defined ones via an object

+ +
Prism.plugins.customClass.map({
+	keyword: 'special-keyword',
+	string: 'string_ch29s',
+	comment: 'comment_93jsa'
+})
+ +

Object's keys are the tokens you want to replace (eg: comment), with its value is the classes you want to use (eg: my-comment). Tokens which are not specified will stay the same.

+ +

Notes

+ +
    +
  • +

    Feature functions must be called AFTER Prism and this plugin. For example:

    + +
    <!-- 1. load prism -->
    +<script src="prism.js"></script>
    +<!-- 2. load the plugin if you don't include it inside prism when download -->
    +<script src="plugins/custom-class/custom-class.js"></script>
    +<!-- 3. call the feature you want to use -->
    +<script>
    +	Prism.plugins.customClass.map(myClassMap);
    +	Prism.plugins.customClass.prefix(myPrefixString);
    +</script>
    + +
  • + +
  • In most cases, using 1 feature is enough. However, it is possible to use both of them together if you want (Result will be like .my-namespace--comment_93jsa).
  • + +
+ +

CSS Modules Usage:

+ +

The initial purpose of this plugin is to use with CSS Modules. It works perfectly with the class map object returned by CSS Modules. For example:

+ +
import Prism from 'prismjs';
+import classMap from 'styles/editor-class-map.css';
+Prism.plugins.customClass.map(classMap)
+ +
+ +
+

Example

+ +

Input

+
<pre class="language-javascript"><code>
+	var foo = 'bar';
+</code></pre>
+ +

Options

+
Prism.plugins.customClass.map({
+	keyword: 'special-keyword',
+	string: 'my-string'
+});
+Prism.plugins.customClass.prefix('pr-');
+ +

Output

+
<pre class="language-javascript"><code>
+	<span class="pr-token pr-special-keyword">var</span>
+	foo
+	<span class="pr-token pr-operator">=</span>
+	<span class="pr-my-string">'bar'</span>
+	<span class="pr-token pr-punctuation">;</span>
+</code></pre>
+
+ +
+

Todo

+ +
+ +
+ + + + + + + + + diff --git a/plugins/custom-class/prism-custom-class.js b/plugins/custom-class/prism-custom-class.js new file mode 100644 index 0000000000..e12f8477d1 --- /dev/null +++ b/plugins/custom-class/prism-custom-class.js @@ -0,0 +1,29 @@ +(function(){ + +if ( + (typeof self === 'undefined' || !self.Prism) && + (typeof global === 'undefined' || !global.Prism) +) { + return; +} + +var options = {}; +Prism.plugins.customClass = { + map: function map(cm) { + options.classMap = cm; + }, + prefix: function prefix(string) { + options.prefixString = string; + } +} + +Prism.hooks.add('wrap', function (env) { + if (!options.classMap && !options.prefixString) { + return; + } + env.classes = env.classes.map(function(c) { + return (options.prefixString || '') + (options.classMap[c] || c); + }); +}); + +})(); diff --git a/plugins/custom-class/prism-custom-class.min.js b/plugins/custom-class/prism-custom-class.min.js new file mode 100644 index 0000000000..9926d87c49 --- /dev/null +++ b/plugins/custom-class/prism-custom-class.min.js @@ -0,0 +1 @@ +!function(){if(("undefined"==typeof self||self.Prism)&&("undefined"==typeof global||global.Prism)){var s;Prism.plugins.customClass={use:function(o){s=o}},Prism.hooks.add("wrap",function(o){if(console.log(o),s){var e=s[o.type];"string"==typeof e&&(o.classes=[e])}})}}(); \ No newline at end of file diff --git a/prism.js b/prism.js index f83bb59ace..feec6269a3 100644 --- a/prism.js +++ b/prism.js @@ -522,7 +522,7 @@ if (typeof global !== 'undefined') { Prism.languages.markup = { 'comment': //, 'prolog': /<\?[\w\W]+?\?>/, - 'doctype': //, + 'doctype': //i, 'cdata': //i, 'tag': { pattern: /<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i, From cda106f97b7941244705050ed87876e4cff44599 Mon Sep 17 00:00:00 2001 From: dvkndn Date: Mon, 15 Aug 2016 02:45:50 +0700 Subject: [PATCH 03/12] update min file and reverse core --- plugins/custom-class/prism-custom-class.min.js | 2 +- prism.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/custom-class/prism-custom-class.min.js b/plugins/custom-class/prism-custom-class.min.js index 9926d87c49..03d34f5b09 100644 --- a/plugins/custom-class/prism-custom-class.min.js +++ b/plugins/custom-class/prism-custom-class.min.js @@ -1 +1 @@ -!function(){if(("undefined"==typeof self||self.Prism)&&("undefined"==typeof global||global.Prism)){var s;Prism.plugins.customClass={use:function(o){s=o}},Prism.hooks.add("wrap",function(o){if(console.log(o),s){var e=s[o.type];"string"==typeof e&&(o.classes=[e])}})}}(); \ No newline at end of file +!function(){if("undefined"!=typeof self&&self.Prism||"undefined"!=typeof global&&global.Prism){var s={};Prism.plugins.customClass={map:function(i){s.classMap=i},prefix:function(i){s.prefixString=i}},Prism.hooks.add("wrap",function(i){(s.classMap||s.prefixString)&&(i.classes=i.classes.map(function(i){return(s.prefixString||"")+(s.classMap[i]||i)}))})}}(); \ No newline at end of file diff --git a/prism.js b/prism.js index feec6269a3..f83bb59ace 100644 --- a/prism.js +++ b/prism.js @@ -522,7 +522,7 @@ if (typeof global !== 'undefined') { Prism.languages.markup = { 'comment': //, 'prolog': /<\?[\w\W]+?\?>/, - 'doctype': //i, + 'doctype': //, 'cdata': //i, 'tag': { pattern: /<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i, From 22cb0187331d9e7239b23431178981bdcc8e1064 Mon Sep 17 00:00:00 2001 From: Masataka Kuwabara Date: Wed, 14 Sep 2016 05:44:22 +0900 Subject: [PATCH 04/12] Fix typo `Fload` to `Float` in prism-ruby.js (#1023) --- components/prism-ruby.js | 2 +- components/prism-ruby.min.js | 2 +- plugins/autoloader/prism-autoloader.min.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/prism-ruby.js b/components/prism-ruby.js index 10e8b5002d..eb3e42939b 100644 --- a/components/prism-ruby.js +++ b/components/prism-ruby.js @@ -64,7 +64,7 @@ }); Prism.languages.insertBefore('ruby', 'number', { - 'builtin': /\b(Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Stat|File|Fixnum|Fload|Hash|Integer|IO|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|String|Struct|TMS|Symbol|ThreadGroup|Thread|Time|TrueClass)\b/, + 'builtin': /\b(Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Stat|File|Fixnum|Float|Hash|Integer|IO|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|String|Struct|TMS|Symbol|ThreadGroup|Thread|Time|TrueClass)\b/, 'constant': /\b[A-Z][a-zA-Z_0-9]*(?:[?!]|\b)/ }); diff --git a/components/prism-ruby.min.js b/components/prism-ruby.min.js index 244c4e2512..a87d311cdc 100644 --- a/components/prism-ruby.min.js +++ b/components/prism-ruby.min.js @@ -1 +1 @@ -!function(e){e.languages.ruby=e.languages.extend("clike",{comment:/#(?!\{[^\r\n]*?\}).*/,keyword:/\b(alias|and|BEGIN|begin|break|case|class|def|define_method|defined|do|each|else|elsif|END|end|ensure|false|for|if|in|module|new|next|nil|not|or|raise|redo|require|rescue|retry|return|self|super|then|throw|true|undef|unless|until|when|while|yield)\b/});var n={pattern:/#\{[^}]+\}/,inside:{delimiter:{pattern:/^#\{|\}$/,alias:"tag"},rest:e.util.clone(e.languages.ruby)}};e.languages.insertBefore("ruby","keyword",{regex:[{pattern:/%r([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1[gim]{0,3}/,inside:{interpolation:n}},{pattern:/%r\((?:[^()\\]|\\[\s\S])*\)[gim]{0,3}/,inside:{interpolation:n}},{pattern:/%r\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}[gim]{0,3}/,inside:{interpolation:n}},{pattern:/%r\[(?:[^\[\]\\]|\\[\s\S])*\][gim]{0,3}/,inside:{interpolation:n}},{pattern:/%r<(?:[^<>\\]|\\[\s\S])*>[gim]{0,3}/,inside:{interpolation:n}},{pattern:/(^|[^\/])\/(?!\/)(\[.+?]|\\.|[^\/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0}],variable:/[@$]+[a-zA-Z_][a-zA-Z_0-9]*(?:[?!]|\b)/,symbol:/:[a-zA-Z_][a-zA-Z_0-9]*(?:[?!]|\b)/}),e.languages.insertBefore("ruby","number",{builtin:/\b(Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Stat|File|Fixnum|Fload|Hash|Integer|IO|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|String|Struct|TMS|Symbol|ThreadGroup|Thread|Time|TrueClass)\b/,constant:/\b[A-Z][a-zA-Z_0-9]*(?:[?!]|\b)/}),e.languages.ruby.string=[{pattern:/%[qQiIwWxs]?([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1/,inside:{interpolation:n}},{pattern:/%[qQiIwWxs]?\((?:[^()\\]|\\[\s\S])*\)/,inside:{interpolation:n}},{pattern:/%[qQiIwWxs]?\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}/,inside:{interpolation:n}},{pattern:/%[qQiIwWxs]?\[(?:[^\[\]\\]|\\[\s\S])*\]/,inside:{interpolation:n}},{pattern:/%[qQiIwWxs]?<(?:[^<>\\]|\\[\s\S])*>/,inside:{interpolation:n}},{pattern:/("|')(#\{[^}]+\}|\\(?:\r?\n|\r)|\\?.)*?\1/,inside:{interpolation:n}}]}(Prism); \ No newline at end of file +!function(e){e.languages.ruby=e.languages.extend("clike",{comment:/#(?!\{[^\r\n]*?\}).*/,keyword:/\b(alias|and|BEGIN|begin|break|case|class|def|define_method|defined|do|each|else|elsif|END|end|ensure|false|for|if|in|module|new|next|nil|not|or|raise|redo|require|rescue|retry|return|self|super|then|throw|true|undef|unless|until|when|while|yield)\b/});var n={pattern:/#\{[^}]+\}/,inside:{delimiter:{pattern:/^#\{|\}$/,alias:"tag"},rest:e.util.clone(e.languages.ruby)}};e.languages.insertBefore("ruby","keyword",{regex:[{pattern:/%r([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1[gim]{0,3}/,inside:{interpolation:n}},{pattern:/%r\((?:[^()\\]|\\[\s\S])*\)[gim]{0,3}/,inside:{interpolation:n}},{pattern:/%r\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}[gim]{0,3}/,inside:{interpolation:n}},{pattern:/%r\[(?:[^\[\]\\]|\\[\s\S])*\][gim]{0,3}/,inside:{interpolation:n}},{pattern:/%r<(?:[^<>\\]|\\[\s\S])*>[gim]{0,3}/,inside:{interpolation:n}},{pattern:/(^|[^\/])\/(?!\/)(\[.+?]|\\.|[^\/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0}],variable:/[@$]+[a-zA-Z_][a-zA-Z_0-9]*(?:[?!]|\b)/,symbol:/:[a-zA-Z_][a-zA-Z_0-9]*(?:[?!]|\b)/}),e.languages.insertBefore("ruby","number",{builtin:/\b(Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Stat|File|Fixnum|Float|Hash|Integer|IO|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|String|Struct|TMS|Symbol|ThreadGroup|Thread|Time|TrueClass)\b/,constant:/\b[A-Z][a-zA-Z_0-9]*(?:[?!]|\b)/}),e.languages.ruby.string=[{pattern:/%[qQiIwWxs]?([^a-zA-Z0-9\s\{\(\[<])(?:[^\\]|\\[\s\S])*?\1/,inside:{interpolation:n}},{pattern:/%[qQiIwWxs]?\((?:[^()\\]|\\[\s\S])*\)/,inside:{interpolation:n}},{pattern:/%[qQiIwWxs]?\{(?:[^#{}\\]|#(?:\{[^}]+\})?|\\[\s\S])*\}/,inside:{interpolation:n}},{pattern:/%[qQiIwWxs]?\[(?:[^\[\]\\]|\\[\s\S])*\]/,inside:{interpolation:n}},{pattern:/%[qQiIwWxs]?<(?:[^<>\\]|\\[\s\S])*>/,inside:{interpolation:n}},{pattern:/("|')(#\{[^}]+\}|\\(?:\r?\n|\r)|\\?.)*?\1/,inside:{interpolation:n}}]}(Prism); \ No newline at end of file diff --git a/plugins/autoloader/prism-autoloader.min.js b/plugins/autoloader/prism-autoloader.min.js index 4a71dd866b..472054b5ff 100644 --- a/plugins/autoloader/prism-autoloader.min.js +++ b/plugins/autoloader/prism-autoloader.min.js @@ -1 +1 @@ -!function(){if("undefined"!=typeof self&&self.Prism&&self.document&&document.createElement){var e={javascript:"clike",actionscript:"javascript",aspnet:"markup",bison:"c",c:"clike",csharp:"clike",cpp:"c",coffeescript:"javascript",crystal:"ruby","css-extras":"css",d:"clike",dart:"clike",fsharp:"clike",glsl:"clike",go:"clike",groovy:"clike",haml:"ruby",handlebars:"markup",haxe:"clike",jade:"javascript",java:"clike",kotlin:"clike",less:"css",markdown:"markup",nginx:"clike",objectivec:"c",parser:"markup",php:"clike","php-extras":"php",processing:"clike",protobuf:"clike",qore:"clike",jsx:["markup","javascript"],ruby:"clike",sass:"css",scss:"css",scala:"java",smarty:"markup",swift:"clike",textile:"markup",twig:"markup",typescript:"javascript",wiki:"markup"},c={},a=["none"],s=Prism.plugins.autoloader={languages_path:"components/",use_minified:!0},n=function(e,c,a){var s=document.createElement("script");s.src=e,s.async=!0,s.onload=function(){document.body.removeChild(s),c&&c()},s.onerror=function(){document.body.removeChild(s),a&&a()},document.body.appendChild(s)},r=function(e){return s.languages_path+"prism-"+e+(s.use_minified?".min":"")+".js"},i=function(e,a){var s=c[e];s||(s=c[e]={});var n=a.getAttribute("data-dependencies");!n&&a.parentNode&&"pre"===a.parentNode.tagName.toLowerCase()&&(n=a.parentNode.getAttribute("data-dependencies")),n=n?n.split(/\s*,\s*/g):[],t(n,function(){l(e,function(){Prism.highlightElement(a)})})},t=function(e,c,a){"string"==typeof e&&(e=[e]);var s=0,n=e.length,r=function(){n>s?l(e[s],function(){s++,r()},function(){a&&a(e[s])}):s===n&&c&&c(e)};r()},l=function(a,s,i){var l=function(){var e=!1;a.indexOf("!")>=0&&(e=!0,a=a.replace("!",""));var t=c[a];if(t||(t=c[a]={}),s&&(t.success_callbacks||(t.success_callbacks=[]),t.success_callbacks.push(s)),i&&(t.error_callbacks||(t.error_callbacks=[]),t.error_callbacks.push(i)),!e&&Prism.languages[a])o(a);else if(!e&&t.error)u(a);else if(e||!t.loading){t.loading=!0;var l=r(a);n(l,function(){t.loading=!1,o(a)},function(){t.loading=!1,t.error=!0,u(a)})}},p=e[a];p&&p.length?t(p,l):l()},o=function(e){c[e]&&c[e].success_callbacks&&c[e].success_callbacks.length&&c[e].success_callbacks.forEach(function(c){c(e)})},u=function(e){c[e]&&c[e].error_callbacks&&c[e].error_callbacks.length&&c[e].error_callbacks.forEach(function(c){c(e)})};Prism.hooks.add("complete",function(e){e.element&&e.language&&!e.grammar&&-1===a.indexOf(e.language)&&i(e.language,e.element)})}}(); \ No newline at end of file +!function(){if("undefined"!=typeof self&&self.Prism&&self.document&&document.createElement){var e={javascript:"clike",actionscript:"javascript",aspnet:"markup",bison:"c",c:"clike",csharp:"clike",cpp:"c",coffeescript:"javascript",crystal:"ruby","css-extras":"css",d:"clike",dart:"clike",fsharp:"clike",glsl:"clike",go:"clike",groovy:"clike",haml:"ruby",handlebars:"markup",haxe:"clike",jade:"javascript",java:"clike",kotlin:"clike",less:"css",markdown:"markup",nginx:"clike",objectivec:"c",parser:"markup",php:"clike","php-extras":"php",processing:"clike",protobuf:"clike",qore:"clike",jsx:["markup","javascript"],ruby:"clike",sass:"css",scss:"css",scala:"java",smarty:"markup",swift:"clike",textile:"markup",twig:"markup",typescript:"javascript",wiki:"markup"},c={},a="none",s=Prism.plugins.autoloader={languages_path:"components/",use_minified:!0},n=function(e,c,a){var s=document.createElement("script");s.src=e,s.async=!0,s.onload=function(){document.body.removeChild(s),c&&c()},s.onerror=function(){document.body.removeChild(s),a&&a()},document.body.appendChild(s)},r=function(e){return s.languages_path+"prism-"+e+(s.use_minified?".min":"")+".js"},i=function(e,a){var s=c[e];s||(s=c[e]={});var n=a.getAttribute("data-dependencies");!n&&a.parentNode&&"pre"===a.parentNode.tagName.toLowerCase()&&(n=a.parentNode.getAttribute("data-dependencies")),n=n?n.split(/\s*,\s*/g):[],t(n,function(){l(e,function(){Prism.highlightElement(a)})})},t=function(e,c,a){"string"==typeof e&&(e=[e]);var s=0,n=e.length,r=function(){n>s?l(e[s],function(){s++,r()},function(){a&&a(e[s])}):s===n&&c&&c(e)};r()},l=function(a,s,i){var l=function(){var e=!1;a.indexOf("!")>=0&&(e=!0,a=a.replace("!",""));var t=c[a];if(t||(t=c[a]={}),s&&(t.success_callbacks||(t.success_callbacks=[]),t.success_callbacks.push(s)),i&&(t.error_callbacks||(t.error_callbacks=[]),t.error_callbacks.push(i)),!e&&Prism.languages[a])o(a);else if(!e&&t.error)u(a);else if(e||!t.loading){t.loading=!0;var l=r(a);n(l,function(){t.loading=!1,o(a)},function(){t.loading=!1,t.error=!0,u(a)})}},p=e[a];p&&p.length?t(p,l):l()},o=function(e){c[e]&&c[e].success_callbacks&&c[e].success_callbacks.length&&c[e].success_callbacks.forEach(function(c){c(e)})},u=function(e){c[e]&&c[e].error_callbacks&&c[e].error_callbacks.length&&c[e].error_callbacks.forEach(function(c){c(e)})};Prism.hooks.add("complete",function(e){e.element&&e.language&&!e.grammar&&e.language!==a&&i(e.language,e.element)})}}(); \ No newline at end of file From 3c5c89ac117aa400b984dc921b1f117956f96fc7 Mon Sep 17 00:00:00 2001 From: jayfoad Date: Thu, 22 Sep 2016 14:32:00 +0100 Subject: [PATCH 05/12] Add iota underbar (#1024) It's used by NARS2000 now, and will be used by Dyalog APL in the future. --- components/prism-apl.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/prism-apl.js b/components/prism-apl.js index 9218331b36..050752b1b0 100644 --- a/components/prism-apl.js +++ b/components/prism-apl.js @@ -8,7 +8,7 @@ Prism.languages.apl = { alias: 'function' }, 'constant': /[⍬⌾#⎕⍞]/, - 'function': /[-+×÷⌈⌊∣|⍳?*⍟○!⌹<≤=>≥≠≡≢∊⍷∪∩~∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⌷⍋⍒⊤⊥⍕⍎⊣⊢⍁⍂≈⍯↗¤→]/, + 'function': /[-+×÷⌈⌊∣|⍳⍸?*⍟○!⌹<≤=>≥≠≡≢∊⍷∪∩~∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⌷⍋⍒⊤⊥⍕⍎⊣⊢⍁⍂≈⍯↗¤→]/, 'monadic-operator': { pattern: /[\\\/⌿⍀¨⍨⌶&∥]/, alias: 'operator' @@ -26,4 +26,4 @@ Prism.languages.apl = { pattern: /[{}⍺⍵⍶⍹∇⍫:]/, alias: 'builtin' } -}; \ No newline at end of file +}; From ac21d33796618a0d550659caf7e63107901670d8 Mon Sep 17 00:00:00 2001 From: Golmote Date: Fri, 23 Sep 2016 22:31:02 +0200 Subject: [PATCH 06/12] Update APL minified file + update test for iota underbar function --- components/prism-apl.min.js | 2 +- tests/languages/apl/function_feature.test | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/prism-apl.min.js b/components/prism-apl.min.js index bfd9dc3680..30866c3afb 100644 --- a/components/prism-apl.min.js +++ b/components/prism-apl.min.js @@ -1 +1 @@ -Prism.languages.apl={comment:/(?:⍝|#[! ]).*$/m,string:/'(?:[^'\r\n]|'')*'/,number:/¯?(?:\d*\.?\d+(?:e[+¯]?\d+)?|¯|∞)(?:j¯?(?:\d*\.?\d+(?:e[\+¯]?\d+)?|¯|∞))?/i,statement:/:[A-Z][a-z][A-Za-z]*\b/,"system-function":{pattern:/⎕[A-Z]+/i,alias:"function"},constant:/[⍬⌾#⎕⍞]/,"function":/[-+×÷⌈⌊∣|⍳?*⍟○!⌹<≤=>≥≠≡≢∊⍷∪∩~∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⌷⍋⍒⊤⊥⍕⍎⊣⊢⍁⍂≈⍯↗¤→]/,"monadic-operator":{pattern:/[\\\/⌿⍀¨⍨⌶&∥]/,alias:"operator"},"dyadic-operator":{pattern:/[.⍣⍠⍤∘⌸]/,alias:"operator"},assignment:{pattern:/←/,alias:"keyword"},punctuation:/[\[;\]()◇⋄]/,dfn:{pattern:/[{}⍺⍵⍶⍹∇⍫:]/,alias:"builtin"}}; \ No newline at end of file +Prism.languages.apl={comment:/(?:⍝|#[! ]).*$/m,string:/'(?:[^'\r\n]|'')*'/,number:/¯?(?:\d*\.?\d+(?:e[+¯]?\d+)?|¯|∞)(?:j¯?(?:\d*\.?\d+(?:e[\+¯]?\d+)?|¯|∞))?/i,statement:/:[A-Z][a-z][A-Za-z]*\b/,"system-function":{pattern:/⎕[A-Z]+/i,alias:"function"},constant:/[⍬⌾#⎕⍞]/,"function":/[-+×÷⌈⌊∣|⍳⍸?*⍟○!⌹<≤=>≥≠≡≢∊⍷∪∩~∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⌷⍋⍒⊤⊥⍕⍎⊣⊢⍁⍂≈⍯↗¤→]/,"monadic-operator":{pattern:/[\\\/⌿⍀¨⍨⌶&∥]/,alias:"operator"},"dyadic-operator":{pattern:/[.⍣⍠⍤∘⌸]/,alias:"operator"},assignment:{pattern:/←/,alias:"keyword"},punctuation:/[\[;\]()◇⋄]/,dfn:{pattern:/[{}⍺⍵⍶⍹∇⍫:]/,alias:"builtin"}}; \ No newline at end of file diff --git a/tests/languages/apl/function_feature.test b/tests/languages/apl/function_feature.test index d663f0ed7a..93be749c5c 100644 --- a/tests/languages/apl/function_feature.test +++ b/tests/languages/apl/function_feature.test @@ -1,6 +1,6 @@ - + × ÷ ⌈ ⌊ ∣ | -⍳ ? * +⍳ ⍸ ? * ⍟ ○ ! ⌹ < ≤ = > ≥ ≠ ≡ ≢ @@ -20,7 +20,7 @@ [ ["function", "-"], ["function", "+"], ["function", "×"], ["function", "÷"], ["function", "⌈"], ["function", "⌊"], ["function", "∣"], ["function", "|"], - ["function", "⍳"], ["function", "?"], ["function", "*"], + ["function", "⍳"], ["function", "⍸"], ["function", "?"], ["function", "*"], ["function", "⍟"], ["function", "○"], ["function", "!"], ["function", "⌹"], ["function", "<"], ["function", "≤"], ["function", "="], ["function", ">"], ["function", "≥"], ["function", "≠"], ["function", "≡"], ["function", "≢"], From 5916430fbed69b400086dcf5f00ac2d77acd7f80 Mon Sep 17 00:00:00 2001 From: Golmote Date: Fri, 23 Sep 2016 23:28:40 +0200 Subject: [PATCH 07/12] Update CHANGELOG --- CHANGELOG.md | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd7c7ef222..c202ba9b84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,78 @@ # Prism Changelog +## Unreleased + +### New components + +* __.properties__ ([#980](https://github.com/PrismJS/prism/issues/980)) [[`be6219a`](https://github.com/PrismJS/prism/commit/be6219a)] +* __Ada__ ([#949](https://github.com/PrismJS/prism/issues/949)) [[`65619f7`](https://github.com/PrismJS/prism/commit/65619f7)] +* __GraphQL__ ([#971](https://github.com/PrismJS/prism/issues/971)) [[`e018087`](https://github.com/PrismJS/prism/commit/e018087)] +* __LiveScript__ ([#982](https://github.com/PrismJS/prism/issues/982)) [[`62e258c`](https://github.com/PrismJS/prism/commit/62e258c)] +* __Xojo__ ([#994](https://github.com/PrismJS/prism/issues/994)) [[`0224b7c`](https://github.com/PrismJS/prism/commit/0224b7c)] + +### Updated components + +* __APL__: + * Add iota underbar ([#1024](https://github.com/PrismJS/prism/issues/1024)) [[`3c5c89a`](https://github.com/PrismJS/prism/commit/3c5c89a), [`ac21d33`](https://github.com/PrismJS/prism/commit/ac21d33)] +* __AsciiDoc__: + * Optimized block regexps to prevent struggling on large files. Fixes [#1001](https://github.com/PrismJS/prism/issues/1001). [[`1a86d34`](https://github.com/PrismJS/prism/commit/1a86d34)] +* __Bash__: + * Add `npm` to function list ([#969](https://github.com/PrismJS/prism/issues/969)) [[`912bdfe`](https://github.com/PrismJS/prism/commit/912bdfe)] +* __CSS__: + * Make CSS strings greedy. Fix [#1013](https://github.com/PrismJS/prism/issues/1013). [[`e57e26d`](https://github.com/PrismJS/prism/commit/e57e26d)] +* __CSS Extras__: + * Match attribute inside selectors [[`13fed76`](https://github.com/PrismJS/prism/commit/13fed76)] +* __JavaScript__: + * Add exponentiation & spread/rest operator ([#991](https://github.com/PrismJS/prism/issues/991)) [[`b2de65a`](https://github.com/PrismJS/prism/commit/b2de65a), [`268d01e`](https://github.com/PrismJS/prism/commit/268d01e)] +* __Markup__ + * Allow for dots in Markup tag names, but not in HTML tags included in Textile. Fixes [#888](https://github.com/PrismJS/prism/issues/888). [[`31ea66b`](https://github.com/PrismJS/prism/commit/31ea66b)] + * Make doctype case-insensitive ([#1009](https://github.com/PrismJS/prism/issues/1009)) [[`3dd7219`](https://github.com/PrismJS/prism/commit/3dd7219)] +* __PHP__ + * Make comments greedy. Fix [#197](https://github.com/PrismJS/prism/issues/197) [[`318aab3`](https://github.com/PrismJS/prism/commit/318aab3)] +* __PowerShell__: + * Fix highlighting of empty comments ([#977](https://github.com/PrismJS/prism/issues/977)) [[`4fda477`](https://github.com/PrismJS/prism/commit/4fda477)] +* __Puppet__: + * Fix over-greedy regexp detection ([#978](https://github.com/PrismJS/prism/issues/978)) [[`105be25`](https://github.com/PrismJS/prism/commit/105be25)] +* __Ruby__: + * Fix typo `Fload` to `Float` in prism-ruby.js ([#1023](https://github.com/PrismJS/prism/issues/1023)) [[`22cb018`](https://github.com/PrismJS/prism/commit/22cb018)] +* __SCSS__: + * Alias statement as keyword. Fix [#246](https://github.com/PrismJS/prism/issues/246) [[`fd09391`](https://github.com/PrismJS/prism/commit/fd09391)] + * Highlight variables inside selectors and properties. [[`d6b5c2f`](https://github.com/PrismJS/prism/commit/d6b5c2f)] + * Highlight parent selector [[`8f5f1fa`](https://github.com/PrismJS/prism/commit/8f5f1fa)] + +### New plugins + +* __Data-URI Highlight__ ([#996](https://github.com/PrismJS/prism/issues/996)) [[`bdca61b`](https://github.com/PrismJS/prism/commit/bdca61b)] + +### Updated plugins + +* __Autoloader__: + * Updated documentation for Autoloader plugin [[`b4f3423`](https://github.com/PrismJS/prism/commit/b4f3423)] + * Download all grammars as a zip from Autoloader plugin page ([#981](https://github.com/PrismJS/prism/issues/981)) [[`0d0a007`](https://github.com/PrismJS/prism/commit/0d0a007), [`5c815d3`](https://github.com/PrismJS/prism/commit/5c815d3)] + * Removed duplicated script on Autoloader plugin page [[`9671996`](https://github.com/PrismJS/prism/commit/9671996)] + * Don't try to load "none" component. Fix [#1000](https://github.com/PrismJS/prism/issues/1000) [[`f89b0b9`](https://github.com/PrismJS/prism/commit/f89b0b9)] +* __WPD__: + * Fix at-rule detection + don't process if language is not handled [[`2626728`](https://github.com/PrismJS/prism/commit/2626728)] + +### Other changes + +* Improvement to greedy-flag ([#967](https://github.com/PrismJS/prism/issues/967)) [[`500121b`](https://github.com/PrismJS/prism/commit/500121b), [`9893489`](https://github.com/PrismJS/prism/commit/9893489)] +* Add setTimeout fallback for requestAnimationFrame. Fixes [#987](https://github.com/PrismJS/prism/issues/987). ([#988](https://github.com/PrismJS/prism/issues/988)) [[`c9bdcd3`](https://github.com/PrismJS/prism/commit/c9bdcd3)] +* Added aria-hidden attributes on elements created by the Line Highlight and Line Numbers plugins. Fixes [#574](https://github.com/PrismJS/prism/issues/574). [[`e5587a7`](https://github.com/PrismJS/prism/commit/e5587a7)] +* Don't insert space before ">" when there is no attributes [[`3dc8c9e`](https://github.com/PrismJS/prism/commit/3dc8c9e)] +* Added missing hooks-related tests for AsciiDoc, Groovy, Handlebars, Markup, PHP and Smarty [[`c1a0c1b`](https://github.com/PrismJS/prism/commit/c1a0c1b)] +* Fix issue when using Line numbers plugin and Normalise whitespace plugin together with Handlebars, PHP or Smarty. Fix [#1018](https://github.com/PrismJS/prism/issues/1018), [#997](https://github.com/PrismJS/prism/issues/997), [#935](https://github.com/PrismJS/prism/issues/935). Revert [#998](https://github.com/PrismJS/prism/issues/998). [[`86aa3d2`](https://github.com/PrismJS/prism/commit/86aa3d2)] +* Optimized logo ([#990](https://github.com/PrismJS/prism/issues/990)) ([#1002](https://github.com/PrismJS/prism/issues/1002)) [[`f69e570`](https://github.com/PrismJS/prism/commit/f69e570), [`218fd25`](https://github.com/PrismJS/prism/commit/218fd25)] +* Remove unneeded prefixed CSS ([#989](https://github.com/PrismJS/prism/issues/989)) [[`5e56833`](https://github.com/PrismJS/prism/commit/5e56833)] +* Optimize images ([#1007](https://github.com/PrismJS/prism/issues/1007)) [[`b2fa6d5`](https://github.com/PrismJS/prism/commit/b2fa6d5)] + + ## 1.5.1 (2016-06-05) ### Updated components * __Normalize Whitespace__: - * FAdd class that disables the normalize whitespace plugin [[`9385c54`](https://github.com/PrismJS/prism/commit/9385c54)] + * Add class that disables the normalize whitespace plugin [[`9385c54`](https://github.com/PrismJS/prism/commit/9385c54)] * __JavaScript Language__: * Rearrange the `string` and `template-string` token in JavaScript [[`1158e46`](https://github.com/PrismJS/prism/commit/1158e46)] * __SQL Language__: @@ -18,7 +85,7 @@ * Allow for asynchronous loading of prism.js ([#959](https://github.com/PrismJS/prism/pull/959)) * Use toLowerCase on language names ([#957](https://github.com/PrismJS/prism/pull/957)) [[`acd9508`](https://github.com/PrismJS/prism/commit/acd9508)] -* link to index for basic usage - fixes #945 ([#946](https://github.com/PrismJS/prism/pull/946)) [[`6c772d8`](https://github.com/PrismJS/prism/commit/6c772d8)] +* link to index for basic usage - fixes [#945](https://github.com/PrismJS/prism/issues/945) ([#946](https://github.com/PrismJS/prism/pull/946)) [[`6c772d8`](https://github.com/PrismJS/prism/commit/6c772d8)] * Fixed monospace typo ([#953](https://github.com/PrismJS/prism/pull/953)) [[`e6c3498`](https://github.com/PrismJS/prism/commit/e6c3498)] ## 1.5.0 (2016-05-01) From fa68f913b716f4a09e2a17c33ce3844c6f6c8aaf Mon Sep 17 00:00:00 2001 From: Thien Do Date: Wed, 28 Sep 2016 15:07:19 +0700 Subject: [PATCH 08/12] Fix grammar in Readme --- plugins/custom-class/index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/custom-class/index.html b/plugins/custom-class/index.html index 3a289eac20..81af18587d 100644 --- a/plugins/custom-class/index.html +++ b/plugins/custom-class/index.html @@ -24,11 +24,11 @@

Custom Class

Motivation

-

Prism default classes are sensible but fixed and too generic. This plugin provide some ways to customize those classes to suite your needs. Example usages:

+

Prism default classes are sensible but fixed and too generic. This plugin provide some ways to customize those classes to suit your needs. Example usages:

  • - You want to add namespace for all of them (like .prism--comment) to avoid conflict with your existed classes. + You want to add namespace for all of them (like .prism--comment) to avoid conflict with your existing classes.
  • You use a naming convention (like BEM). You want to write classes like .editor__comment. @@ -54,7 +54,7 @@

    2. Replace some Prism classes with your defined ones via an object

    comment: 'comment_93jsa' }) -

    Object's keys are the tokens you want to replace (eg: comment), with its value is the classes you want to use (eg: my-comment). Tokens which are not specified will stay the same.

    +

    Object's keys are the tokens you want to replace (eg: comment), with their values being the classes you want to use (eg: my-comment). Tokens which are not specified will stay the same.

    Notes

    @@ -80,7 +80,7 @@

    Notes

    CSS Modules Usage:

    -

    The initial purpose of this plugin is to use with CSS Modules. It works perfectly with the class map object returned by CSS Modules. For example:

    +

    The initial purpose of this plugin is to be used with CSS Modules. It works perfectly with the class map object returned by CSS Modules. For example:

    import Prism from 'prismjs';
     import classMap from 'styles/editor-class-map.css';
    
    From 25a541d6ddae4b5518a61ed72bccaef1efa5a29c Mon Sep 17 00:00:00 2001
    From: Golmote 
    Date: Wed, 28 Sep 2016 21:16:33 +0200
    Subject: [PATCH 09/12] JSON: Fixed issues with properties and strings + added
     tests. Fix #1025
    
    ---
     components/prism-json.js                   |  8 +++---
     components/prism-json.min.js               |  2 +-
     tests/languages/json/boolean_feature.test  | 13 +++++++++
     tests/languages/json/null_feature.test     | 11 ++++++++
     tests/languages/json/number_feature.test   | 21 ++++++++++++++
     tests/languages/json/property_feature.test | 33 ++++++++++++++++++++++
     tests/languages/json/string_feature.test   | 27 ++++++++++++++++++
     7 files changed, 110 insertions(+), 5 deletions(-)
     create mode 100644 tests/languages/json/boolean_feature.test
     create mode 100644 tests/languages/json/null_feature.test
     create mode 100644 tests/languages/json/number_feature.test
     create mode 100644 tests/languages/json/property_feature.test
     create mode 100644 tests/languages/json/string_feature.test
    
    diff --git a/components/prism-json.js b/components/prism-json.js
    index c7634b18ec..a7f54f6f99 100644
    --- a/components/prism-json.js
    +++ b/components/prism-json.js
    @@ -1,11 +1,11 @@
     Prism.languages.json = {
    -    'property': /".*?"(?=\s*:)/ig,
    -    'string': /"(?!:)(\\?[^"])*?"(?!:)/g,
    -    'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/g,
    +    'property': /"(?:\\.|[^|"])*"(?=\s*:)/ig,
    +    'string': /"(?!:)(?:\\.|[^|"])*"(?!:)/g,
    +    'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee][+-]?\d+)?)\b/g,
         'punctuation': /[{}[\]);,]/g,
         'operator': /:/g,
         'boolean': /\b(true|false)\b/gi,
    -    'null': /\bnull\b/gi,
    +    'null': /\bnull\b/gi
     };
     
     Prism.languages.jsonp = Prism.languages.json;
    diff --git a/components/prism-json.min.js b/components/prism-json.min.js
    index adf940323e..a437a3e370 100644
    --- a/components/prism-json.min.js
    +++ b/components/prism-json.min.js
    @@ -1 +1 @@
    -Prism.languages.json={property:/".*?"(?=\s*:)/gi,string:/"(?!:)(\\?[^"])*?"(?!:)/g,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/g,punctuation:/[{}[\]);,]/g,operator:/:/g,"boolean":/\b(true|false)\b/gi,"null":/\bnull\b/gi},Prism.languages.jsonp=Prism.languages.json;
    \ No newline at end of file
    +Prism.languages.json={property:/"(?:\\.|[^|"])*"(?=\s*:)/gi,string:/"(?!:)(?:\\.|[^|"])*"(?!:)/g,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee][+-]?\d+)?)\b/g,punctuation:/[{}[\]);,]/g,operator:/:/g,"boolean":/\b(true|false)\b/gi,"null":/\bnull\b/gi},Prism.languages.jsonp=Prism.languages.json;
    \ No newline at end of file
    diff --git a/tests/languages/json/boolean_feature.test b/tests/languages/json/boolean_feature.test
    new file mode 100644
    index 0000000000..4019c444f8
    --- /dev/null
    +++ b/tests/languages/json/boolean_feature.test
    @@ -0,0 +1,13 @@
    +true
    +false
    +
    +----------------------------------------------------
    +
    +[
    +	["boolean", "true"],
    +	["boolean", "false"]
    +]
    +
    +----------------------------------------------------
    +
    +Checks for booleans.
    \ No newline at end of file
    diff --git a/tests/languages/json/null_feature.test b/tests/languages/json/null_feature.test
    new file mode 100644
    index 0000000000..1283944abe
    --- /dev/null
    +++ b/tests/languages/json/null_feature.test
    @@ -0,0 +1,11 @@
    +null
    +
    +----------------------------------------------------
    +
    +[
    +	["null", "null"]
    +]
    +
    +----------------------------------------------------
    +
    +Checks for null.
    \ No newline at end of file
    diff --git a/tests/languages/json/number_feature.test b/tests/languages/json/number_feature.test
    new file mode 100644
    index 0000000000..ba045ec3d4
    --- /dev/null
    +++ b/tests/languages/json/number_feature.test
    @@ -0,0 +1,21 @@
    +0
    +123
    +3.14159
    +5.0e8
    +0.2E+2
    +47e-5
    +
    +----------------------------------------------------
    +
    +[
    +	["number", "0"],
    +	["number", "123"],
    +	["number", "3.14159"],
    +	["number", "5.0e8"],
    +	["number", "0.2E+2"],
    +	["number", "47e-5"]
    +]
    +
    +----------------------------------------------------
    +
    +Checks for numbers.
    \ No newline at end of file
    diff --git a/tests/languages/json/property_feature.test b/tests/languages/json/property_feature.test
    new file mode 100644
    index 0000000000..3880ad733d
    --- /dev/null
    +++ b/tests/languages/json/property_feature.test
    @@ -0,0 +1,33 @@
    +{"foo\"bar\"baz":1,"foo":2}
    +{
    +	"foo": 1,
    +	"b\"ar": 2
    +}
    +
    +----------------------------------------------------
    +
    +[
    +	["punctuation", "{"],
    +	["property", "\"foo\\\"bar\\\"baz\""],
    +	["operator", ":"],
    +	["number", "1"],
    +	["punctuation", ","],
    +	["property", "\"foo\""],
    +	["operator", ":"],
    +	["number", "2"],
    +	["punctuation", "}"],
    +
    +	["punctuation", "{"],
    +	["property", "\"foo\""],
    +	["operator", ":"],
    +	["number", "1"],
    +	["punctuation", ","],
    +	["property", "\"b\\\"ar\""],
    +	["operator", ":"],
    +	["number", "2"],
    +	["punctuation", "}"]
    +]
    +
    +----------------------------------------------------
    +
    +Checks for features.
    \ No newline at end of file
    diff --git a/tests/languages/json/string_feature.test b/tests/languages/json/string_feature.test
    new file mode 100644
    index 0000000000..08ac8c06f7
    --- /dev/null
    +++ b/tests/languages/json/string_feature.test
    @@ -0,0 +1,27 @@
    +""
    +"foo"
    +"foo\"bar\"baz"
    +"\u2642\\ "
    +{"foo":"bar","baz":"\""}
    +
    +----------------------------------------------------
    +
    +[
    +	["string", "\"\""],
    +	["string", "\"foo\""],
    +	["string", "\"foo\\\"bar\\\"baz\""],
    +	["string", "\"\\u2642\\\\ \""],
    +	["punctuation", "{"],
    +	["property", "\"foo\""],
    +	["operator", ":"],
    +	["string", "\"bar\""],
    +	["punctuation", ","],
    +	["property", "\"baz\""],
    +	["operator", ":"],
    +	["string", "\"\\\"\""],
    +	["punctuation", "}"]
    +]
    +
    +----------------------------------------------------
    +
    +Checks for strings.
    \ No newline at end of file
    
    From 4cbdf4d21183debbcfb5e0515297a7e6bb3bdd21 Mon Sep 17 00:00:00 2001
    From: Thien 
    Date: Fri, 30 Sep 2016 14:50:11 +0700
    Subject: [PATCH 10/12] Reverse prism markup min
    
    ---
     components/prism-markup.min.js | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/components/prism-markup.min.js b/components/prism-markup.min.js
    index edda541209..6e924b9a1b 100644
    --- a/components/prism-markup.min.js
    +++ b/components/prism-markup.min.js
    @@ -1 +1 @@
    -Prism.languages.markup={comment://,prolog:/<\?[\w\W]+?\?>/,doctype://i,cdata://i,tag:{pattern:/<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,inside:{punctuation:/[=>"']/}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/&#?[\da-z]{1,8};/i},Prism.hooks.add("wrap",function(a){"entity"===a.type&&(a.attributes.title=a.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;
    \ No newline at end of file
    +Prism.languages.markup={comment://,prolog:/<\?[\w\W]+?\?>/,doctype://,cdata://i,tag:{pattern:/<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,inside:{punctuation:/[=>"']/}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/&#?[\da-z]{1,8};/i},Prism.hooks.add("wrap",function(a){"entity"===a.type&&(a.attributes.title=a.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;
    \ No newline at end of file
    
    From d1144d0b315d070a95f77ad2f54fd06191047204 Mon Sep 17 00:00:00 2001
    From: Golmote 
    Date: Mon, 10 Oct 2016 22:53:48 +0200
    Subject: [PATCH 11/12] Test suite: fixed missing diff in error message
    
    ---
     tests/run-child.js | 2 +-
     tests/run.js       | 2 +-
     2 files changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/tests/run-child.js b/tests/run-child.js
    index ea93f1fb12..faaca983a3 100644
    --- a/tests/run-child.js
    +++ b/tests/run-child.js
    @@ -15,7 +15,7 @@ if (argv.language) {
     				}
     				process.send({success: true});
     			} catch (e) {
    -				process.send({error: e.message});
    +				process.send({error: JSON.stringify(e)});
     			}
     		}
     	});
    diff --git a/tests/run.js b/tests/run.js
    index 8f7cf279c3..73c4c4acd1 100644
    --- a/tests/run.js
    +++ b/tests/run.js
    @@ -49,7 +49,7 @@ for (var language in testSuite) {
     				                // over and over again.
     				                setTimeout(function() {
     					                if (o.error) {
    -						                throw new Error(o.error);
    +						                throw JSON.parse(o.error);
     					                } else if (o.success) {
     						                done();
     					                }
    
    From 76ba1b83b5ffa7c8a2770c5abe15e137722c5486 Mon Sep 17 00:00:00 2001
    From: "Jan T. Sott" 
    Date: Tue, 11 Oct 2016 08:11:15 +0200
    Subject: [PATCH 12/12] update patterns (#1032)
    
    Updated NSIS
    ---
     components/prism-nsis.js                   | 15 +++++++++++----
     components/prism-nsis.min.js               |  2 +-
     tests/languages/nsis/constant_feature.test | 19 +++++++++++++++++++
     tests/languages/nsis/variable_feature.test |  8 +++-----
     4 files changed, 34 insertions(+), 10 deletions(-)
     create mode 100644 tests/languages/nsis/constant_feature.test
    
    diff --git a/components/prism-nsis.js b/components/prism-nsis.js
    index 66de20a6c8..613c2b5b9b 100644
    --- a/components/prism-nsis.js
    +++ b/components/prism-nsis.js
    @@ -1,7 +1,7 @@
     /**
      * Original by Jan T. Sott (http://github.com/idleberg)
      *
    - * Includes all commands and plug-ins shipped with NSIS 3.0a2
    + * Includes all commands and plug-ins shipped with NSIS 3.0
      */
      Prism.languages.nsis = {
     	'comment': {
    @@ -9,11 +9,18 @@
     		lookbehind: true
     	},
     	'string': /("|')(\\?.)*?\1/,
    -	'keyword': /\b(Abort|Add(BrandingImage|Size)|AdvSplash|Allow(RootDirInstall|SkipFiles)|AutoCloseWindow|Banner|BG(Font|Gradient|Image)|BrandingText|BringToFront|Call(InstDLL)?|Caption|ChangeUI|CheckBitmap|ClearErrors|CompletedText|ComponentText|CopyFiles|CRCCheck|Create(Directory|Font|ShortCut)|Delete(INISec|INIStr|RegKey|RegValue)?|Detail(Print|sButtonText)|Dialer|Dir(Text|Var|Verify)|EnableWindow|Enum(RegKey|RegValue)|Exch|Exec(Shell|Wait)?|ExpandEnvStrings|File(BufSize|Close|ErrorText|Open|Read|ReadByte|ReadUTF16LE|ReadWord|WriteUTF16LE|Seek|Write|WriteByte|WriteWord)?|Find(Close|First|Next|Window)|FlushINI|Get(CurInstType|CurrentAddress|DlgItem|DLLVersion(Local)?|ErrorLevel|FileTime(Local)?|FullPathName|Function(Address|End)?|InstDirError|LabelAddress|TempFileName)|Goto|HideWindow|Icon|If(Abort|Errors|FileExists|RebootFlag|Silent)|InitPluginsDir|Install(ButtonText|Colors|Dir(RegKey)?)|InstProgressFlags|Inst(Type(GetText|SetText)?)|Int(CmpU?|Fmt|Op)|IsWindow|Lang(DLL|String)|License(BkColor|Data|ForceSelection|LangString|Text)|LoadLanguageFile|LockWindow|Log(Set|Text)|Manifest(DPIAware|SupportedOS)|Math|MessageBox|MiscButtonText|Name|Nop|ns(Dialogs|Exec)|NSISdl|OutFile|Page(Callbacks)?|Pop|Push|Quit|Read(EnvStr|INIStr|RegDWORD|RegStr)|Reboot|RegDLL|Rename|RequestExecutionLevel|ReserveFile|Return|RMDir|SearchPath|Section(End|GetFlags|GetInstTypes|GetSize|GetText|Group|In|SetFlags|SetInstTypes|SetSize|SetText)?|SendMessage|Set(AutoClose|BrandingImage|Compress|Compressor(DictSize)?|CtlColors|CurInstType|DatablockOptimize|DateSave|Details(Print|View)|ErrorLevel|Errors|FileAttributes|Font|OutPath|Overwrite|PluginUnload|RebootFlag|RegView|ShellVarContext|Silent)|Show(InstDetails|UninstDetails|Window)|Silent(Install|UnInstall)|Sleep|SpaceTexts|Splash|StartMenu|Str(CmpS?|Cpy|Len)|SubCaption|System|Unicode|Uninstall(ButtonText|Caption|Icon|SubCaption|Text)|UninstPage|UnRegDLL|UserInfo|Var|VI(AddVersionKey|FileVersion|ProductVersion)|VPatch|WindowIcon|Write(INIStr|RegBin|RegDWORD|RegExpandStr|RegStr|Uninstaller)|XPStyle)\b/,
    +	'keyword': {
    +		pattern: /(^\s*)(Abort|Add(BrandingImage|Size)|AdvSplash|Allow(RootDirInstall|SkipFiles)|AutoCloseWindow|Banner|BG(Font|Gradient|Image)|BrandingText|BringToFront|Call(InstDLL)?|Caption|ChangeUI|CheckBitmap|ClearErrors|CompletedText|ComponentText|CopyFiles|CRCCheck|Create(Directory|Font|ShortCut)|Delete(INISec|INIStr|RegKey|RegValue)?|Detail(Print|sButtonText)|Dialer|Dir(Text|Var|Verify)|EnableWindow|Enum(RegKey|RegValue)|Exch|Exec(Shell|Wait)?|ExpandEnvStrings|File(BufSize|Close|ErrorText|Open|Read|ReadByte|ReadUTF16LE|ReadWord|WriteUTF16LE|Seek|Write|WriteByte|WriteWord)?|Find(Close|First|Next|Window)|FlushINI|Get(CurInstType|CurrentAddress|DlgItem|DLLVersion(Local)?|ErrorLevel|FileTime(Local)?|FullPathName|Function(Address|End)?|InstDirError|LabelAddress|TempFileName)|Goto|HideWindow|Icon|If(Abort|Errors|FileExists|RebootFlag|Silent)|InitPluginsDir|Install(ButtonText|Colors|Dir(RegKey)?)|InstProgressFlags|Inst(Type(GetText|SetText)?)|Int(CmpU?|Fmt|Op)|IsWindow|Lang(DLL|String)|License(BkColor|Data|ForceSelection|LangString|Text)|LoadLanguageFile|LockWindow|Log(Set|Text)|Manifest(DPIAware|SupportedOS)|Math|MessageBox|MiscButtonText|Name|Nop|ns(Dialogs|Exec)|NSISdl|OutFile|Page(Callbacks)?|Pop|Push|Quit|Read(EnvStr|INIStr|RegDWORD|RegStr)|Reboot|RegDLL|Rename|RequestExecutionLevel|ReserveFile|Return|RMDir|SearchPath|Section(End|GetFlags|GetInstTypes|GetSize|GetText|Group|In|SetFlags|SetInstTypes|SetSize|SetText)?|SendMessage|Set(AutoClose|BrandingImage|Compress|Compressor(DictSize)?|CtlColors|CurInstType|DatablockOptimize|DateSave|Details(Print|View)|ErrorLevel|Errors|FileAttributes|Font|OutPath|Overwrite|PluginUnload|RebootFlag|RegView|ShellVarContext|Silent)|Show(InstDetails|UninstDetails|Window)|Silent(Install|UnInstall)|Sleep|SpaceTexts|Splash|StartMenu|Str(CmpS?|Cpy|Len)|SubCaption|System|Unicode|Uninstall(ButtonText|Caption|Icon|SubCaption|Text)|UninstPage|UnRegDLL|UserInfo|Var|VI(AddVersionKey|FileVersion|ProductVersion)|VPatch|WindowIcon|Write(INIStr|RegBin|RegDWORD|RegExpandStr|RegStr|Uninstaller)|XPStyle)\b/m,
    +		lookbehind: true
    +	},
     	'property': /\b(admin|all|auto|both|colored|false|force|hide|highest|lastused|leave|listonly|none|normal|notset|off|on|open|print|show|silent|silentlog|smooth|textonly|true|user|ARCHIVE|FILE_(ATTRIBUTE_ARCHIVE|ATTRIBUTE_NORMAL|ATTRIBUTE_OFFLINE|ATTRIBUTE_READONLY|ATTRIBUTE_SYSTEM|ATTRIBUTE_TEMPORARY)|HK(CR|CU|DD|LM|PD|U)|HKEY_(CLASSES_ROOT|CURRENT_CONFIG|CURRENT_USER|DYN_DATA|LOCAL_MACHINE|PERFORMANCE_DATA|USERS)|ID(ABORT|CANCEL|IGNORE|NO|OK|RETRY|YES)|MB_(ABORTRETRYIGNORE|DEFBUTTON1|DEFBUTTON2|DEFBUTTON3|DEFBUTTON4|ICONEXCLAMATION|ICONINFORMATION|ICONQUESTION|ICONSTOP|OK|OKCANCEL|RETRYCANCEL|RIGHT|RTLREADING|SETFOREGROUND|TOPMOST|USERICON|YESNO)|NORMAL|OFFLINE|READONLY|SHCTX|SHELL_CONTEXT|SYSTEM|TEMPORARY)\b/,
    -	'variable': /\$[({]?[-_\w]+[)}]?/i,
    +	'constant': /\${[\w\.:-]+}|\$\([\w\.:-]+\)/i,
    +	'variable': /\$\w+/i,
     	'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,
     	'operator': /--?|\+\+?|<=?|>=?|==?=?|&&?|\|?\||[?*\/~^%]/,
     	'punctuation': /[{}[\];(),.:]/,
    -	'important': /!(addincludedir|addplugindir|appendfile|cd|define|delfile|echo|else|endif|error|execute|finalize|getdllversionsystem|ifdef|ifmacrodef|ifmacrondef|ifndef|if|include|insertmacro|macroend|macro|makensis|packhdr|searchparse|searchreplace|tempfile|undef|verbose|warning)\b/i
    +	'important': {
    +		pattern: /(^\s*)!(addincludedir|addplugindir|appendfile|cd|define|delfile|echo|else|endif|error|execute|finalize|getdllversionsystem|ifdef|ifmacrodef|ifmacrondef|ifndef|if|include|insertmacro|macroend|macro|makensis|packhdr|searchparse|searchreplace|tempfile|undef|verbose|warning)\b/mi,
    +		lookbehind: true
    +	}
     };
    diff --git a/components/prism-nsis.min.js b/components/prism-nsis.min.js
    index bbc510b593..e4a03226e9 100644
    --- a/components/prism-nsis.min.js
    +++ b/components/prism-nsis.min.js
    @@ -1 +1 @@
    -Prism.languages.nsis={comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|[#;].*)/,lookbehind:!0},string:/("|')(\\?.)*?\1/,keyword:/\b(Abort|Add(BrandingImage|Size)|AdvSplash|Allow(RootDirInstall|SkipFiles)|AutoCloseWindow|Banner|BG(Font|Gradient|Image)|BrandingText|BringToFront|Call(InstDLL)?|Caption|ChangeUI|CheckBitmap|ClearErrors|CompletedText|ComponentText|CopyFiles|CRCCheck|Create(Directory|Font|ShortCut)|Delete(INISec|INIStr|RegKey|RegValue)?|Detail(Print|sButtonText)|Dialer|Dir(Text|Var|Verify)|EnableWindow|Enum(RegKey|RegValue)|Exch|Exec(Shell|Wait)?|ExpandEnvStrings|File(BufSize|Close|ErrorText|Open|Read|ReadByte|ReadUTF16LE|ReadWord|WriteUTF16LE|Seek|Write|WriteByte|WriteWord)?|Find(Close|First|Next|Window)|FlushINI|Get(CurInstType|CurrentAddress|DlgItem|DLLVersion(Local)?|ErrorLevel|FileTime(Local)?|FullPathName|Function(Address|End)?|InstDirError|LabelAddress|TempFileName)|Goto|HideWindow|Icon|If(Abort|Errors|FileExists|RebootFlag|Silent)|InitPluginsDir|Install(ButtonText|Colors|Dir(RegKey)?)|InstProgressFlags|Inst(Type(GetText|SetText)?)|Int(CmpU?|Fmt|Op)|IsWindow|Lang(DLL|String)|License(BkColor|Data|ForceSelection|LangString|Text)|LoadLanguageFile|LockWindow|Log(Set|Text)|Manifest(DPIAware|SupportedOS)|Math|MessageBox|MiscButtonText|Name|Nop|ns(Dialogs|Exec)|NSISdl|OutFile|Page(Callbacks)?|Pop|Push|Quit|Read(EnvStr|INIStr|RegDWORD|RegStr)|Reboot|RegDLL|Rename|RequestExecutionLevel|ReserveFile|Return|RMDir|SearchPath|Section(End|GetFlags|GetInstTypes|GetSize|GetText|Group|In|SetFlags|SetInstTypes|SetSize|SetText)?|SendMessage|Set(AutoClose|BrandingImage|Compress|Compressor(DictSize)?|CtlColors|CurInstType|DatablockOptimize|DateSave|Details(Print|View)|ErrorLevel|Errors|FileAttributes|Font|OutPath|Overwrite|PluginUnload|RebootFlag|RegView|ShellVarContext|Silent)|Show(InstDetails|UninstDetails|Window)|Silent(Install|UnInstall)|Sleep|SpaceTexts|Splash|StartMenu|Str(CmpS?|Cpy|Len)|SubCaption|System|Unicode|Uninstall(ButtonText|Caption|Icon|SubCaption|Text)|UninstPage|UnRegDLL|UserInfo|Var|VI(AddVersionKey|FileVersion|ProductVersion)|VPatch|WindowIcon|Write(INIStr|RegBin|RegDWORD|RegExpandStr|RegStr|Uninstaller)|XPStyle)\b/,property:/\b(admin|all|auto|both|colored|false|force|hide|highest|lastused|leave|listonly|none|normal|notset|off|on|open|print|show|silent|silentlog|smooth|textonly|true|user|ARCHIVE|FILE_(ATTRIBUTE_ARCHIVE|ATTRIBUTE_NORMAL|ATTRIBUTE_OFFLINE|ATTRIBUTE_READONLY|ATTRIBUTE_SYSTEM|ATTRIBUTE_TEMPORARY)|HK(CR|CU|DD|LM|PD|U)|HKEY_(CLASSES_ROOT|CURRENT_CONFIG|CURRENT_USER|DYN_DATA|LOCAL_MACHINE|PERFORMANCE_DATA|USERS)|ID(ABORT|CANCEL|IGNORE|NO|OK|RETRY|YES)|MB_(ABORTRETRYIGNORE|DEFBUTTON1|DEFBUTTON2|DEFBUTTON3|DEFBUTTON4|ICONEXCLAMATION|ICONINFORMATION|ICONQUESTION|ICONSTOP|OK|OKCANCEL|RETRYCANCEL|RIGHT|RTLREADING|SETFOREGROUND|TOPMOST|USERICON|YESNO)|NORMAL|OFFLINE|READONLY|SHCTX|SHELL_CONTEXT|SYSTEM|TEMPORARY)\b/,variable:/\$[({]?[-_\w]+[)}]?/i,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,operator:/--?|\+\+?|<=?|>=?|==?=?|&&?|\|?\||[?*\/~^%]/,punctuation:/[{}[\];(),.:]/,important:/!(addincludedir|addplugindir|appendfile|cd|define|delfile|echo|else|endif|error|execute|finalize|getdllversionsystem|ifdef|ifmacrodef|ifmacrondef|ifndef|if|include|insertmacro|macroend|macro|makensis|packhdr|searchparse|searchreplace|tempfile|undef|verbose|warning)\b/i};
    \ No newline at end of file
    +Prism.languages.nsis={comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|[#;].*)/,lookbehind:!0},string:/("|')(\\?.)*?\1/,keyword:{pattern:/(^\s*)(Abort|Add(BrandingImage|Size)|AdvSplash|Allow(RootDirInstall|SkipFiles)|AutoCloseWindow|Banner|BG(Font|Gradient|Image)|BrandingText|BringToFront|Call(InstDLL)?|Caption|ChangeUI|CheckBitmap|ClearErrors|CompletedText|ComponentText|CopyFiles|CRCCheck|Create(Directory|Font|ShortCut)|Delete(INISec|INIStr|RegKey|RegValue)?|Detail(Print|sButtonText)|Dialer|Dir(Text|Var|Verify)|EnableWindow|Enum(RegKey|RegValue)|Exch|Exec(Shell|Wait)?|ExpandEnvStrings|File(BufSize|Close|ErrorText|Open|Read|ReadByte|ReadUTF16LE|ReadWord|WriteUTF16LE|Seek|Write|WriteByte|WriteWord)?|Find(Close|First|Next|Window)|FlushINI|Get(CurInstType|CurrentAddress|DlgItem|DLLVersion(Local)?|ErrorLevel|FileTime(Local)?|FullPathName|Function(Address|End)?|InstDirError|LabelAddress|TempFileName)|Goto|HideWindow|Icon|If(Abort|Errors|FileExists|RebootFlag|Silent)|InitPluginsDir|Install(ButtonText|Colors|Dir(RegKey)?)|InstProgressFlags|Inst(Type(GetText|SetText)?)|Int(CmpU?|Fmt|Op)|IsWindow|Lang(DLL|String)|License(BkColor|Data|ForceSelection|LangString|Text)|LoadLanguageFile|LockWindow|Log(Set|Text)|Manifest(DPIAware|SupportedOS)|Math|MessageBox|MiscButtonText|Name|Nop|ns(Dialogs|Exec)|NSISdl|OutFile|Page(Callbacks)?|Pop|Push|Quit|Read(EnvStr|INIStr|RegDWORD|RegStr)|Reboot|RegDLL|Rename|RequestExecutionLevel|ReserveFile|Return|RMDir|SearchPath|Section(End|GetFlags|GetInstTypes|GetSize|GetText|Group|In|SetFlags|SetInstTypes|SetSize|SetText)?|SendMessage|Set(AutoClose|BrandingImage|Compress|Compressor(DictSize)?|CtlColors|CurInstType|DatablockOptimize|DateSave|Details(Print|View)|ErrorLevel|Errors|FileAttributes|Font|OutPath|Overwrite|PluginUnload|RebootFlag|RegView|ShellVarContext|Silent)|Show(InstDetails|UninstDetails|Window)|Silent(Install|UnInstall)|Sleep|SpaceTexts|Splash|StartMenu|Str(CmpS?|Cpy|Len)|SubCaption|System|Unicode|Uninstall(ButtonText|Caption|Icon|SubCaption|Text)|UninstPage|UnRegDLL|UserInfo|Var|VI(AddVersionKey|FileVersion|ProductVersion)|VPatch|WindowIcon|Write(INIStr|RegBin|RegDWORD|RegExpandStr|RegStr|Uninstaller)|XPStyle)\b/m,lookbehind:!0},property:/\b(admin|all|auto|both|colored|false|force|hide|highest|lastused|leave|listonly|none|normal|notset|off|on|open|print|show|silent|silentlog|smooth|textonly|true|user|ARCHIVE|FILE_(ATTRIBUTE_ARCHIVE|ATTRIBUTE_NORMAL|ATTRIBUTE_OFFLINE|ATTRIBUTE_READONLY|ATTRIBUTE_SYSTEM|ATTRIBUTE_TEMPORARY)|HK(CR|CU|DD|LM|PD|U)|HKEY_(CLASSES_ROOT|CURRENT_CONFIG|CURRENT_USER|DYN_DATA|LOCAL_MACHINE|PERFORMANCE_DATA|USERS)|ID(ABORT|CANCEL|IGNORE|NO|OK|RETRY|YES)|MB_(ABORTRETRYIGNORE|DEFBUTTON1|DEFBUTTON2|DEFBUTTON3|DEFBUTTON4|ICONEXCLAMATION|ICONINFORMATION|ICONQUESTION|ICONSTOP|OK|OKCANCEL|RETRYCANCEL|RIGHT|RTLREADING|SETFOREGROUND|TOPMOST|USERICON|YESNO)|NORMAL|OFFLINE|READONLY|SHCTX|SHELL_CONTEXT|SYSTEM|TEMPORARY)\b/,constant:/\${[\w\.:-]+}|\$\([\w\.:-]+\)/i,variable:/\$\w+/i,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,operator:/--?|\+\+?|<=?|>=?|==?=?|&&?|\|?\||[?*\/~^%]/,punctuation:/[{}[\];(),.:]/,important:{pattern:/(^\s*)!(addincludedir|addplugindir|appendfile|cd|define|delfile|echo|else|endif|error|execute|finalize|getdllversionsystem|ifdef|ifmacrodef|ifmacrondef|ifndef|if|include|insertmacro|macroend|macro|makensis|packhdr|searchparse|searchreplace|tempfile|undef|verbose|warning)\b/im,lookbehind:!0}};
    \ No newline at end of file
    diff --git a/tests/languages/nsis/constant_feature.test b/tests/languages/nsis/constant_feature.test
    new file mode 100644
    index 0000000000..a27666a1c3
    --- /dev/null
    +++ b/tests/languages/nsis/constant_feature.test
    @@ -0,0 +1,19 @@
    +$(myLicenseData)
    +${LANG_ENGLISH}
    +${AtLeastWin8.1}
    +${nsArray_Copy}
    +${xml::CreateNode}
    +
    +----------------------------------------------------
    +
    +[
    +    ["constant", "$(myLicenseData)"],
    +    ["constant", "${LANG_ENGLISH}"],
    +    ["constant", "${AtLeastWin8.1}"],
    +    ["constant", "${nsArray_Copy}"],
    +	["constant", "${xml::CreateNode}"]
    +]
    +
    +----------------------------------------------------
    +
    +Checks for constants.
    \ No newline at end of file
    diff --git a/tests/languages/nsis/variable_feature.test b/tests/languages/nsis/variable_feature.test
    index 0703ec69ae..ba2ced201b 100644
    --- a/tests/languages/nsis/variable_feature.test
    +++ b/tests/languages/nsis/variable_feature.test
    @@ -1,13 +1,11 @@
    +$INTERNET_CACHE
     $LANGUAGE
    -$(myLicenseData)
    -${LANG_ENGLISH}
     
     ----------------------------------------------------
     
     [
    -	["variable", "$LANGUAGE"],
    -	["variable", "$(myLicenseData)"],
    -	["variable", "${LANG_ENGLISH}"]
    +    ["variable", "$INTERNET_CACHE"],
    +    ["variable", "$LANGUAGE"]
     ]
     
     ----------------------------------------------------