From 2aeed5ccb58d42873ea75dd44835a132bed2b46d Mon Sep 17 00:00:00 2001 From: Fabian Giesen Date: Thu, 25 Jul 2013 19:19:15 -0700 Subject: [PATCH 001/310] Refine C number regexp. - Exponent may contain '+', not just '-'. - Numbers may have "float" (f), "unsigned" (u), "long" (l) or "long long" (ll) suffixes. The set of suffixes described by this regexp is somewhat larger than what a real C compiler would accept. --- components/prism-c.js | 3 ++- components/prism-c.min.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/components/prism-c.js b/components/prism-c.js index a0a8933ecd..c449a29653 100644 --- a/components/prism-c.js +++ b/components/prism-c.js @@ -1,6 +1,7 @@ Prism.languages.c = Prism.languages.extend('clike', { 'keyword': /\b(asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/g, - 'operator': /[-+]{1,2}|!=?|<{1,2}=?|>{1,2}=?|\->|={1,2}|\^|~|%|(&){1,2}|\|?\||\?|\*|\//g + 'operator': /[-+]{1,2}|!=?|<{1,2}=?|>{1,2}=?|\->|={1,2}|\^|~|%|(&){1,2}|\|?\||\?|\*|\//g, + 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee][+-]?\d+)?)[fFuUlL]*\b/g }); Prism.languages.insertBefore('c', 'keyword', { diff --git a/components/prism-c.min.js b/components/prism-c.min.js index 1cb1b16deb..61e5a3538d 100644 --- a/components/prism-c.min.js +++ b/components/prism-c.min.js @@ -1 +1 @@ -Prism.languages.c=Prism.languages.extend("clike",{keyword:/\b(asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/g,operator:/[-+]{1,2}|!=?|<{1,2}=?|>{1,2}=?|\->|={1,2}|\^|~|%|(&){1,2}|\|?\||\?|\*|\//g});Prism.languages.insertBefore("c","keyword",{property:/#\s*[a-zA-Z]+/g}); +Prism.languages.c=Prism.languages.extend("clike",{keyword:/\b(asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/g,operator:/[-+]{1,2}|!=?|<{1,2}=?|>{1,2}=?|\->|={1,2}|\^|~|%|(&){1,2}|\|?\||\?|\*|\//g,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee][+-]?\d+)?)[fFuUlL]*\b/g});Prism.languages.insertBefore("c","keyword",{property:/#\s*[a-zA-Z]+/g}); \ No newline at end of file From a418b1a81fa362764018d8efab4e4c366678a3d8 Mon Sep 17 00:00:00 2001 From: Fabian Giesen Date: Thu, 25 Jul 2013 19:25:51 -0700 Subject: [PATCH 002/310] C-like: Allow '+' in exponents. --- components/prism-clike.js | 4 ++-- components/prism-clike.min.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/prism-clike.js b/components/prism-clike.js index 89f949294f..31e2c25496 100644 --- a/components/prism-clike.js +++ b/components/prism-clike.js @@ -19,8 +19,8 @@ Prism.languages.clike = { punctuation: /\(/ } }, - 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/g, + 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee][+-]?\d+)?)\b/g, 'operator': /[-+]{1,2}|!|<=?|>=?|={1,3}|(&){1,2}|\|?\||\?|\*|\/|\~|\^|\%/g, 'ignore': /&(lt|gt|amp);/gi, 'punctuation': /[{}[\];(),.:]/g -}; \ No newline at end of file +}; diff --git a/components/prism-clike.min.js b/components/prism-clike.min.js index 22c8cff628..80077beda6 100644 --- a/components/prism-clike.min.js +++ b/components/prism-clike.min.js @@ -1 +1 @@ -Prism.languages.clike={comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|(^|[^:])\/\/.*?(\r?\n|$))/g,lookbehind:!0},string:/("|')(\\?.)*?\1/g,"class-name":{pattern:/((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/ig,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|catch|finally|null|break|continue)\b/g,"boolean":/\b(true|false)\b/g,"function":{pattern:/[a-z0-9_]+\(/ig,inside:{punctuation:/\(/}}, number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/g,operator:/[-+]{1,2}|!|<=?|>=?|={1,3}|(&){1,2}|\|?\||\?|\*|\/|\~|\^|\%/g,ignore:/&(lt|gt|amp);/gi,punctuation:/[{}[\];(),.:]/g}; \ No newline at end of file +Prism.languages.clike={comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|(^|[^:])\/\/.*?(\r?\n|$))/g,lookbehind:!0},string:/("|')(\\?.)*?\1/g,"class-name":{pattern:/((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/gi,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|catch|finally|null|break|continue)\b/g,"boolean":/\b(true|false)\b/g,"function":{pattern:/[a-z0-9_]+\(/gi,inside:{punctuation:/\(/}},number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee][+-]?\d+)?)\b/g,operator:/[-+]{1,2}|!|<=?|>=?|={1,3}|(&){1,2}|\|?\||\?|\*|\/|\~|\^|\%/g,ignore:/&(lt|gt|amp);/gi,punctuation:/[{}[\];(),.:]/g}; \ No newline at end of file From c9ec813b6660e3ef9e58bafbc5dcca5a44c90a4a Mon Sep 17 00:00:00 2001 From: Andreas Rohner Date: Sun, 10 Aug 2014 14:53:23 +0200 Subject: [PATCH 003/310] Extend Latex support This patch extends the support for Latex in the following way: * Support for various equation environments and for the verbatim environment * Certain functions like `\ref` or `\begin` always contain a reference or a keyword and they are highlighted as such. * Chapter and section headlines are written in bold to make them stand out more, because they structure the document. * Since `selector` and `string` have the same color in the default theme, the token type `function` is used to highlight Latex commands. * Add support for the `\url` command * Add alias support --- components/prism-latex.js | 67 +++++++++++++++++++++++++++++++---- components/prism-latex.min.js | 2 +- 2 files changed, 62 insertions(+), 7 deletions(-) diff --git a/components/prism-latex.js b/components/prism-latex.js index c8902f6c5a..5e0a0e6312 100644 --- a/components/prism-latex.js +++ b/components/prism-latex.js @@ -1,6 +1,61 @@ -Prism.languages.latex = { - 'comment': /%.*?(\r?\n|$)$/m, - 'string': /(\$)(\\?.)*?\1/g, - 'punctuation': /[{}]/g, - 'selector': /\\[a-z;,:\.]*/i -} \ No newline at end of file +(function(Prism) { + var funcPattern = /\\([^a-z()[\]]|[a-z\*]+)/gi, + insideEqu = { + 'equation-command': { + pattern: funcPattern, + alias: 'regex' + } + }; + + Prism.languages.latex = { + 'comment': /%.*?$/gm, + // the verbatim environment prints whitespace to the document + 'cdata': { + pattern: /(\\begin\{((?:verbatim|lstlisting)\*?)\})([\w\W]*?)(?=\\end\{\2\})/, + lookbehind: true + }, + /* + * equations can be between $ $ or \( \) or \[ \] + * (all are multiline) + */ + 'equation': [ + { + pattern: /(\$(\\?[\w\W])*?\$|\\\((\\?[\w\W])*?\\\)|\\\[(\\?[\w\W])*?\\\])/g, + inside: insideEqu, + alias: 'string' + }, + { + pattern: /(\\begin\{((?:equation|math|eqnarray|align|multline|gather)\*?)\})([\w\W]*?)(?=\\end\{\2\})/, + lookbehind: true, + inside: insideEqu, + alias: 'string' + } + ], + /* + * arguments which are keywords or references are highlighted + * as keywords + */ + 'keyword': { + pattern: /(\\(?:begin|end|ref|cite|label|usepackage|documentclass)(?:\[[^\]]+\])?\{)[^}]+(?=\}(?:\[[^\]]+\])?)/, + lookbehind: true + }, + 'url': { + pattern: /(\\url\{)[^}]+(?=\})/, + lookbehind: true + }, + /* + * section or chapter headlines are highlighted as bold so that + * they stand out more + */ + 'headline': { + pattern: /(\\(?:part|chapter|section|subsection|frametitle|subsubsection|paragraph|subparagraph|subsubparagraph|subsubsubparagraph)\*?(?:\[[^\]]+\])?\{)[^}]+(?=\}(?:\[[^\]]+\])?)/, + lookbehind: true, + alias: 'class-name' + }, + 'function': { + pattern: funcPattern, + alias: 'selector' + }, + 'punctuation': /[[\]{}&]/g, + }; +})(Prism); diff --git a/components/prism-latex.min.js b/components/prism-latex.min.js index 29f90249f1..2699cd297d 100644 --- a/components/prism-latex.min.js +++ b/components/prism-latex.min.js @@ -1 +1 @@ -Prism.languages.latex={comment:/%.*?(\r?\n|$)$/m,string:/(\$)(\\?.)*?\1/g,punctuation:/[{}]/g,selector:/\\[a-z;,:\.]*/i}; \ No newline at end of file +!function(a){var e=/\\([^a-z()[\]]|[a-z\*]+)/gi,n={"equation-command":{pattern:e,alias:"regex"}};a.languages.latex={comment:/%.*?$/gm,cdata:{pattern:/(\\begin\{((?:verbatim|lstlisting)\*?)\})([\w\W]*?)(?=\\end\{\2\})/,lookbehind:!0},equation:[{pattern:/(\$(\\?[\w\W])*?\$|\\\((\\?[\w\W])*?\\\)|\\\[(\\?[\w\W])*?\\\])/g,inside:n,alias:"string"},{pattern:/(\\begin\{((?:equation|math|eqnarray|align|multline|gather)\*?)\})([\w\W]*?)(?=\\end\{\2\})/,lookbehind:!0,inside:n,alias:"string"}],keyword:{pattern:/(\\(?:begin|end|ref|cite|label|usepackage|documentclass)(?:\[[^\]]+\])?\{)[^}]+(?=\}(?:\[[^\]]+\])?)/,lookbehind:!0},url:{pattern:/(\\url\{)[^}]+(?=\})/,lookbehind:!0},headline:{pattern:/(\\(?:part|chapter|section|subsection|frametitle|subsubsection|paragraph|subparagraph|subsubparagraph|subsubsubparagraph)\*?(?:\[[^\]]+\])?\{)[^}]+(?=\}(?:\[[^\]]+\])?)/,lookbehind:!0,alias:"class-name"},"function":{pattern:e,alias:"selector"},punctuation:/[[\]{}&]/g}}(Prism); \ No newline at end of file From c84bd33208d8adb41aa6afc55137e6f26b4fc159 Mon Sep 17 00:00:00 2001 From: Peter Chaplin Date: Thu, 11 Dec 2014 10:25:23 +0000 Subject: [PATCH 004/310] Add Tcl language --- components.js | 4 ++ components/prism-tcl.js | 116 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 components/prism-tcl.js diff --git a/components.js b/components.js index 7bae5697d4..70f7ddcb91 100644 --- a/components.js +++ b/components.js @@ -206,6 +206,10 @@ var components = { "handlebars": { "title": "Handlebars", "owner": "Golmote" + }, + "tcl": { + "title": "Tcl", + "owner": "PeterChaplin" } }, "plugins": { diff --git a/components/prism-tcl.js b/components/prism-tcl.js new file mode 100644 index 0000000000..a52379bf64 --- /dev/null +++ b/components/prism-tcl.js @@ -0,0 +1,116 @@ +Prism.languages.tcl = { + 'escaped': /\\./g, + 'comment': /#.*/g, + 'string': /"[^"]*"/g, + 'variable': [ + { + pattern: /(\$)(::)?([a-zA-Z0-9]+::)*[a-zA-Z0-9_]+/g, + lookbehind: true + }, + { + pattern: /(\$){[^}]+}/g, + lookbehind: true + }, + { + pattern: /(^\s*set\s+)(::)?([a-zA-Z0-9]+::)*[a-zA-Z0-9_]+/gm, + lookbehind: true + } + ], + 'function': { + lookbehind: true, + pattern: /(^\s*proc\s+)[^\s]+/gm + }, + 'builtin': [ + { + pattern: /(^\s*)(proc|return|class|error|eval|exit)\b/gm, + lookbehind: true + }, + { + pattern: /(^\s*)(for|foreach|if|switch|while|break|continue)\b/gm, + lookbehind: true + }, + /\b(elseif|else)\b/g + ], + 'scope': { + pattern: /^\s+(global|upvar|variable)\b/gm, + alias: 'constant' + }, + 'keyword': [ + { + pattern: /(^\s*|\[)(after|append|apply|array|auto_execok|auto_import)\b/gm, + lookbehind: true + }, + { + pattern: /(^\s*|\[)(auto_load|auto_mkindex|automkindex_old)\b/gm, + lookbehind: true + }, + { + pattern: /(^\s*|\[)(auto_qualify|auto_reset|bgerror|binary|catch|cd)\b/gm, + lookbehind: true + }, + { + pattern: /(^\s*|\[)(chan|clock|close|concat|dde|dict|encoding|eof)\b/gm, + lookbehind: true + }, + { + pattern: /(^\s*|\[)(exec|exit|expr|fblocked|fconfigure|fcopy|file)\b/gm, + lookbehind: true + }, + { + pattern: /(^\s*|\[)(fileevent|filename|flush|gets|glob|history)\b/gm, + lookbehind: true + }, + { + pattern: /(^\s*|\[)(http|incr|info|interp|join|lappend|lassign)\b/gm, + lookbehind: true + }, + { + pattern: /(^\s*|\[)(lindex|linsert|list|llength|load|lrange)\b/gm, + lookbehind: true + }, + { + pattern: /(^\s*|\[)(lrepeat|lreplace|lreverse|lsearch|lset|lsort)\b/gm, + lookbehind: true + }, + { + pattern: /(^\s*|\[)(mathfunc|mathop|memory|msgcat|namespace|open)\b/gm, + lookbehind: true + }, + { + pattern: /(^\s*|\[)(package|parray|pid|pkg_mkIndex|platform|puts)\b/gm, + lookbehind: true + }, + { + pattern: /(^\s*|\[)(pwd|re_syntax|read|refchan|regexp|registry)\b/gm, + lookbehind: true + }, + { + pattern: /(^\s*|\[)(regsub|rename|Safe_Base|scan|seek|set|socket)\b/gm, + lookbehind: true + }, + { + pattern: /(^\s*|\[)(source|split|string|subst|Tcl|tcl_endOfWord)\b/gm, + lookbehind: true + }, + { + pattern: /(^\s*|\[)(tcl_findLibrary|tclStartOfNextWord)\b/gm, + lookbehind: true + }, + { + pattern: /(^\s*|\[)(tclstartOfPreviousWord|tclwordBreakAfter)\b/gm, + lookbehind: true + }, + { + pattern: /(^\s*|\[)(tclwordBreakBefore|tcltest|tclvars|tell|time)\b/gm, + lookbehind: true + }, + { + pattern: /(^\s*|\[)(tm|trace|unknown|unload|unset|update|uplevel)\b/gm, + lookbehind: true + }, + { + pattern: /(^\s*|\[)(upvar|variable|vwait)\b/gm, + lookbehind: true + } + ] +}; From c38007c42c53edc9fb5fe77e8457cef1298e5f4b Mon Sep 17 00:00:00 2001 From: Petr Chalupny Date: Wed, 31 Dec 2014 12:18:24 +0100 Subject: [PATCH 005/310] Added Qore language support --- components/prism-qore.js | 20 ++++++++++++++++++++ components/prism-qore.min.js | 1 + 2 files changed, 21 insertions(+) create mode 100644 components/prism-qore.js create mode 100644 components/prism-qore.min.js diff --git a/components/prism-qore.js b/components/prism-qore.js new file mode 100644 index 0000000000..a2ce637e51 --- /dev/null +++ b/components/prism-qore.js @@ -0,0 +1,20 @@ +Prism.languages.qore = Prism.languages.extend('clike', { + 'comment': { + pattern: /(^|[^\\])(\/\*[\w\W]*?\*\/|((\/\/)|#).*?(\r?\n|$))/g, // /(^|[^\\])([\w\W]*?\*\/|(^|[^:])\/\/.*?(\r?\n|$))/g, + lookbehind: true + }, + 'variable': /(\$\w+)\b/ig, + 'keyword': /\b(abstract|any|assert|binary|bool|boolean|break|byte|case|catch|char|class|code|const|continue|data|default|do|double|else|enum|extends|final|finally|float|for|goto|hash|if|implements|import|inherits|instanceof|int|interface|long|my|native|new|nothing|null|object|our|own|private|reference|rethrow|return|short|softint|softfloat|softnumber|softbool|softstring|softdate|softlist|static|strictfp|string|sub|super|switch|synchronized|this|throw|throws|transient|try|void|volatile|while)\b/g, + 'number': /\b0b[01]+\b|\b0x[\da-f]*\.?[\da-fp\-]+\b|\b\d*\.?\d+[e]?[\d]*[df]\b|\W\d*\.?\d+\b/gi, + 'boolean': /\b(true|false)\b/ig, + 'operator': { + pattern: /([^\.]|^)([-+]{1,2}|!|=?<|=?>|={1,2}|(&){1,2}|\|?\||\?|\*|\/|%|\^|(<){2}|($gt;){2,3}|:|~|new|background|dlete|remove|cast|shift|pop|chomp|trim|elements|keys|exists|instanceof|unshift|push|splice|extract|map|foldl|foldr|select|\$)/g, + lookbehind: true + }, + 'function': { + pattern: /[a-z0-9_]+\(/ig, + inside: { + punctuation: /\(/ + } + }, +}); \ No newline at end of file diff --git a/components/prism-qore.min.js b/components/prism-qore.min.js new file mode 100644 index 0000000000..760c5add03 --- /dev/null +++ b/components/prism-qore.min.js @@ -0,0 +1 @@ +Prism.languages.qore=Prism.languages.extend("clike",{comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|((\/\/)|#).*?(\r?\n|$))/g,lookbehind:!0},variable:/(\$\w+)\b/gi,keyword:/\b(abstract|any|assert|binary|bool|boolean|break|byte|case|catch|char|class|code|const|continue|data|default|do|double|else|enum|extends|final|finally|float|for|goto|hash|if|implements|import|inherits|instanceof|int|interface|long|my|native|new|nothing|null|object|our|own|private|reference|rethrow|return|short|softint|softfloat|softnumber|softbool|softstring|softdate|softlist|static|strictfp|string|sub|super|switch|synchronized|this|throw|throws|transient|try|void|volatile|while)\b/g,number:/\b0b[01]+\b|\b0x[\da-f]*\.?[\da-fp\-]+\b|\b\d*\.?\d+[e]?[\d]*[df]\b|\W\d*\.?\d+\b/gi,"boolean":/\b(true|false)\b/gi,operator:{pattern:/([^\.]|^)([-+]{1,2}|!|=?<|=?>|={1,2}|(&){1,2}|\|?\||\?|\*|\/|%|\^|(<){2}|($gt;){2,3}|:|~|new|background|dlete|remove|cast|shift|pop|chomp|trim|elements|keys|exists|instanceof|unshift|push|splice|extract|map|foldl|foldr|select|\$)/g,lookbehind:!0},"function":{pattern:/[a-z0-9_]+\(/gi,inside:{punctuation:/\(/}}}); From 98c326b21abedcdb1bfa62aee10c64e03143e391 Mon Sep 17 00:00:00 2001 From: Petr Chalupny Date: Wed, 31 Dec 2014 12:23:01 +0100 Subject: [PATCH 006/310] Added Qore to component listing --- components.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components.js b/components.js index 8d48e5fe46..846ac2b798 100644 --- a/components.js +++ b/components.js @@ -268,6 +268,10 @@ var components = { "powershell": { "title": "PowerShell", "owner": "nauzilus" + }, + "qore": { + "title": "Qore", + "owner": "temnroegg" } }, "plugins": { From 230b67ae8088481ed0d24120ed3ed3e6b4fe6f8b Mon Sep 17 00:00:00 2001 From: Golmote Date: Sat, 21 Mar 2015 00:05:02 +0100 Subject: [PATCH 007/310] Add Brainfuck language --- components.js | 4 ++++ components/prism-brainfuck.js | 20 ++++++++++++++++ components/prism-brainfuck.min.js | 1 + examples/prism-brainfuck.html | 40 +++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 components/prism-brainfuck.js create mode 100644 components/prism-brainfuck.min.js create mode 100644 examples/prism-brainfuck.html diff --git a/components.js b/components.js index 83b7c39853..b1e05d91a5 100644 --- a/components.js +++ b/components.js @@ -319,6 +319,10 @@ var components = { "title": "Wiki markup", "require": "markup", "owner": "Golmote" + }, + "brainfuck": { + "title": "Brainfuck", + "owner": "Golmote" } }, "plugins": { diff --git a/components/prism-brainfuck.js b/components/prism-brainfuck.js new file mode 100644 index 0000000000..604d12292c --- /dev/null +++ b/components/prism-brainfuck.js @@ -0,0 +1,20 @@ +Prism.languages.brainfuck = { + 'pointer': { + pattern: /<|>/, + alias: 'keyword' + }, + 'increment': { + pattern: /\+/, + alias: 'inserted' + }, + 'decrement': { + pattern: /-/, + alias: 'deleted' + }, + 'branching': { + pattern: /\[|\]/, + alias: 'important' + }, + 'operator': /[.,]/, + 'comment': /\S+/ +}; \ No newline at end of file diff --git a/components/prism-brainfuck.min.js b/components/prism-brainfuck.min.js new file mode 100644 index 0000000000..ed9707eaa4 --- /dev/null +++ b/components/prism-brainfuck.min.js @@ -0,0 +1 @@ +Prism.languages.brainfuck={pointer:{pattern:/<|>/,alias:"keyword"},increment:{pattern:/\+/,alias:"inserted"},decrement:{pattern:/-/,alias:"deleted"},branching:{pattern:/\[|\]/,alias:"important"},operator:/[.,]/,comment:/\S+/}; \ No newline at end of file diff --git a/examples/prism-brainfuck.html b/examples/prism-brainfuck.html new file mode 100644 index 0000000000..e4cf9fe22d --- /dev/null +++ b/examples/prism-brainfuck.html @@ -0,0 +1,40 @@ +

Brainfuck

+

To use this language, use the class "language-brainfuck".

+ +

Full example

+
+++++ +++               Set Cell #0 to 8
+[
+    >++++               Add 4 to Cell #1; this will always set Cell #1 to 4
+    [                   as the cell will be cleared by the loop
+        >++             Add 2 to Cell #2
+        >+++            Add 3 to Cell #3
+        >+++            Add 3 to Cell #4
+        >+              Add 1 to Cell #5
+        <<<<-           Decrement the loop counter in Cell #1
+    ]                   Loop till Cell #1 is zero; number of iterations is 4
+    >+                  Add 1 to Cell #2
+    >+                  Add 1 to Cell #3
+    >-                  Subtract 1 from Cell #4
+    >>+                 Add 1 to Cell #6
+    [<]                 Move back to the first zero cell you find; this will
+                        be Cell #1 which was cleared by the previous loop
+    <-                  Decrement the loop Counter in Cell #0
+]                       Loop till Cell #0 is zero; number of iterations is 8
+
+The result of this is:
+Cell No :   0   1   2   3   4   5   6
+Contents:   0   0  72 104  88  32   8
+Pointer :   ^
+
+>>.                     Cell #2 has value 72 which is 'H'
+>---.                   Subtract 3 from Cell #3 to get 101 which is 'e'
++++++++..+++.           Likewise for 'llo' from Cell #3
+>>.                     Cell #5 is 32 for the space
+<-.                     Subtract 1 from Cell #4 for 87 to give a 'W'
+<.                      Cell #3 was set to 'o' from the end of 'Hello'
++++.------.--------.    Cell #3 for 'rl' and 'd'
+>>+.                    Add 1 to Cell #5 gives us an exclamation point
+>++.                    And finally a newline from Cell #6
+ +

One-line example

+
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
From c79922532b787f159861aaaf66bf1c4e4c4e82fe Mon Sep 17 00:00:00 2001 From: Golmote Date: Tue, 31 Mar 2015 07:47:32 +0200 Subject: [PATCH 008/310] Fixed implicitly declared variable --- plugins/line-numbers/prism-line-numbers.js | 2 +- plugins/line-numbers/prism-line-numbers.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/line-numbers/prism-line-numbers.js b/plugins/line-numbers/prism-line-numbers.js index e340049f73..329d568ac5 100644 --- a/plugins/line-numbers/prism-line-numbers.js +++ b/plugins/line-numbers/prism-line-numbers.js @@ -8,7 +8,7 @@ Prism.hooks.add('after-highlight', function (env) { var linesNum = (1 + env.code.split('\n').length); var lineNumbersWrapper; - lines = new Array(linesNum); + var lines = new Array(linesNum); lines = lines.join(''); lineNumbersWrapper = document.createElement('span'); diff --git a/plugins/line-numbers/prism-line-numbers.min.js b/plugins/line-numbers/prism-line-numbers.min.js index bade829a23..a0172fc885 100644 --- a/plugins/line-numbers/prism-line-numbers.min.js +++ b/plugins/line-numbers/prism-line-numbers.min.js @@ -1 +1 @@ -Prism.hooks.add("after-highlight",function(e){var n=e.element.parentNode;if(n&&/pre/i.test(n.nodeName)&&-1!==n.className.indexOf("line-numbers")){var t,a=1+e.code.split("\n").length;lines=new Array(a),lines=lines.join(""),t=document.createElement("span"),t.className="line-numbers-rows",t.innerHTML=lines,n.hasAttribute("data-start")&&(n.style.counterReset="linenumber "+(parseInt(n.getAttribute("data-start"),10)-1)),e.element.appendChild(t)}}); \ No newline at end of file +Prism.hooks.add("after-highlight",function(e){var t=e.element.parentNode;if(t&&/pre/i.test(t.nodeName)&&-1!==t.className.indexOf("line-numbers")){var n,a=1+e.code.split("\n").length,r=new Array(a);r=r.join(""),n=document.createElement("span"),n.className="line-numbers-rows",n.innerHTML=r,t.hasAttribute("data-start")&&(t.style.counterReset="linenumber "+(parseInt(t.getAttribute("data-start"),10)-1)),e.element.appendChild(n)}}); \ No newline at end of file From b31e2dd5242878f6e7c8f4237024150ab5d96704 Mon Sep 17 00:00:00 2001 From: Golmote Date: Wed, 1 Apr 2015 09:05:57 +0200 Subject: [PATCH 009/310] Add a "Select All" languages checkbox (fix #513) --- components.js | 3 ++- download.html | 3 ++- download.js | 62 ++++++++++++++++++++++++++++++++++++++++++--------- 3 files changed, 56 insertions(+), 12 deletions(-) diff --git a/components.js b/components.js index 7be18694e5..a4c0867284 100644 --- a/components.js +++ b/components.js @@ -35,7 +35,8 @@ var components = { "meta": { "path": "components/prism-{id}", "noCSS": true, - "examplesPath": "examples/prism-{id}" + "examplesPath": "examples/prism-{id}", + "addCheckAll": true }, "markup": { "title": "Markup", diff --git a/download.html b/download.html index f273c7eaa0..0dd9930f0d 100644 --- a/download.html +++ b/download.html @@ -65,7 +65,8 @@ column-span: all; } - section.options#category-languages label[data-id="javascript"] { + section.options#category-languages label[data-id="javascript"], + section.options label[data-id^="check-all-"] { border-bottom: 1px solid #aaa; padding-bottom: 1em; margin-bottom: 1em; diff --git a/download.js b/download.js index 742da9716b..e56e58710c 100644 --- a/download.js +++ b/download.js @@ -64,6 +64,37 @@ for (var category in components) { }, inside: '#components' }); + + if (all.meta.addCheckAll) { + $u.element.create('label', { + attributes: { + 'data-id': 'check-all-' + category + }, + contents: [ + { + tag: 'input', + properties: { + type: 'checkbox', + name: 'check-all-' + category, + value: '', + checked: false, + onclick: (function(category, all){ + return function () { + var checkAll = this; + $$('input[name="download-' + category + '"]').forEach(function(input) { + all[input.value].enabled = input.checked = checkAll.checked; + }); + + update(category); + }; + })(category, all) + } + }, + 'Select/unselect all' + ], + inside: all.meta.section + }); + } for (var id in all) { if(id === 'meta') { @@ -266,10 +297,11 @@ function update(updatedCategory, updatedId){ for (var category in components) { var all = components[category]; - + var allChecked = true; + for (var id in all) { var info = all[id]; - + if (info.enabled || id == updatedId) { var distro = info.files[minified? 'minified' : 'dev']; @@ -295,18 +327,28 @@ function update(updatedCategory, updatedId){ } }); } + if (id !== 'meta' && !info.enabled) { + allChecked = false; + } + } + + if (all.meta.addCheckAll) { + $('input[name="check-all-' + category + '"]').checked = allChecked; } } total.all = total.js + total.css; - updated.all = updated.js + updated.css; - - $u.element.prop($('label[data-id="' + updatedId + '"] .filesize'), { - textContent: prettySize(updated.all), - title: (updated.js? Math.round(100 * updated.js / updated.all) + '% JavaScript' : '') + - (updated.js && updated.css? ' + ' : '') + - (updated.css? Math.round(100 * updated.css / updated.all) + '% CSS' : '') - }); + + if (updatedId) { + updated.all = updated.js + updated.css; + + $u.element.prop($('label[data-id="' + updatedId + '"] .filesize'), { + textContent: prettySize(updated.all), + title: (updated.js ? Math.round(100 * updated.js / updated.all) + '% JavaScript' : '') + + (updated.js && updated.css ? ' + ' : '') + + (updated.css ? Math.round(100 * updated.css / updated.all) + '% CSS' : '') + }); + } $('#filesize').textContent = prettySize(total.all); From 93fb18a10a27ecba1c88657ee1c1ce35a954a676 Mon Sep 17 00:00:00 2001 From: Daniel Flint Date: Fri, 3 Apr 2015 00:04:46 +1100 Subject: [PATCH 010/310] Don't force scrollbars to be shown unnecessarily. --- plugins/show-language/prism-show-language.css | 2 +- plugins/show-language/prism-show-language.min.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/show-language/prism-show-language.css b/plugins/show-language/prism-show-language.css index 5561baeb7b..336f0f9b96 100644 --- a/plugins/show-language/prism-show-language.css +++ b/plugins/show-language/prism-show-language.css @@ -2,7 +2,7 @@ pre[class*='language-'] { position: relative; } pre[class*='language-'] > code[data-language] { - overflow: scroll; + overflow: auto; max-height: 28em; display: block; } diff --git a/plugins/show-language/prism-show-language.min.css b/plugins/show-language/prism-show-language.min.css index 76d4568213..0444f4dda3 100644 --- a/plugins/show-language/prism-show-language.min.css +++ b/plugins/show-language/prism-show-language.min.css @@ -1 +1 @@ -pre[class*=language-]{position:relative}pre[class*=language-]>code[data-language]{overflow:scroll;max-height:28em;display:block}pre[class*=language-]>code[data-language]::before{content:attr(data-language);color:#000;background-color:#CFCFCF;display:inline-block;position:absolute;top:0;right:0;font-size:.9em;border-radius:0 0 0 5px;padding:0 .5em;text-shadow:none} \ No newline at end of file +pre[class*=language-]{position:relative}pre[class*=language-]>code[data-language]{overflow:auto;max-height:28em;display:block}pre[class*=language-]>code[data-language]::before{content:attr(data-language);color:#000;background-color:#CFCFCF;display:inline-block;position:absolute;top:0;right:0;font-size:.9em;border-radius:0 0 0 5px;padding:0 .5em;text-shadow:none} \ No newline at end of file From 2781c8b9ca060361d944a82708ec5870116e5710 Mon Sep 17 00:00:00 2001 From: Golmote Date: Fri, 10 Apr 2015 21:36:06 +0200 Subject: [PATCH 011/310] Allow empty single-like comments. Fix #564 --- components/prism-clike.js | 2 +- components/prism-clike.min.js | 2 +- prism.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/prism-clike.js b/components/prism-clike.js index 1c8548bd77..5c0a03a7c6 100644 --- a/components/prism-clike.js +++ b/components/prism-clike.js @@ -5,7 +5,7 @@ Prism.languages.clike = { lookbehind: true }, { - pattern: /(^|[^\\:])\/\/.+/, + pattern: /(^|[^\\:])\/\/.*/, lookbehind: true } ], diff --git a/components/prism-clike.min.js b/components/prism-clike.min.js index 1c583cf382..83c97474a8 100644 --- a/components/prism-clike.min.js +++ b/components/prism-clike.min.js @@ -1 +1 @@ -Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.+/,lookbehind:!0}],string:/("|')(\\\n|\\?.)*?\1/,"class-name":{pattern:/((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,"boolean":/\b(true|false)\b/,"function":{pattern:/[a-z0-9_]+\(/i,inside:{punctuation:/\(/}},number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,operator:/[-+]{1,2}|!|<=?|>=?|={1,3}|&{1,2}|\|?\||\?|\*|\/|~|\^|%/,ignore:/&(lt|gt|amp);/i,punctuation:/[{}[\];(),.:]/}; \ No newline at end of file +Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:/("|')(\\\n|\\?.)*?\1/,"class-name":{pattern:/((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,"boolean":/\b(true|false)\b/,"function":{pattern:/[a-z0-9_]+\(/i,inside:{punctuation:/\(/}},number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,operator:/[-+]{1,2}|!|<=?|>=?|={1,3}|&{1,2}|\|?\||\?|\*|\/|~|\^|%/,ignore:/&(lt|gt|amp);/i,punctuation:/[{}[\];(),.:]/}; \ No newline at end of file diff --git a/prism.js b/prism.js index 2a5c0244bd..e74f7cd746 100644 --- a/prism.js +++ b/prism.js @@ -544,7 +544,7 @@ Prism.languages.clike = { lookbehind: true }, { - pattern: /(^|[^\\:])\/\/.+/, + pattern: /(^|[^\\:])\/\/.*/, lookbehind: true } ], From 8417aff19b942e9ef2f7d0cd56ab388dbd353d4a Mon Sep 17 00:00:00 2001 From: Andreas Larsen Date: Fri, 10 Apr 2015 23:40:29 +0200 Subject: [PATCH 012/310] Fixes same empty // comment error as in clike --- components/prism-less.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/prism-less.js b/components/prism-less.js index 3328db8f49..0ed468c543 100644 --- a/components/prism-less.js +++ b/components/prism-less.js @@ -10,7 +10,7 @@ Prism.languages.less = Prism.languages.extend('css', { 'comment': [ /\/\*[\w\W]*?\*\//, { - pattern: /(^|[^\\])\/\/.+/, + pattern: /(^|[^\\])\/\/.*/, lookbehind: true } ], @@ -57,4 +57,4 @@ Prism.languages.insertBefore('less', 'property', { lookbehind: true, alias: 'function' } -}); \ No newline at end of file +}); From 0c30a04308c4c3d9e74f2ab100f7ef515394c124 Mon Sep 17 00:00:00 2001 From: Andreas Larsen Date: Fri, 10 Apr 2015 23:41:20 +0200 Subject: [PATCH 013/310] Same as #566 - just the minified file --- components/prism-less.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/prism-less.min.js b/components/prism-less.min.js index e4c1be2240..5f826d6903 100644 --- a/components/prism-less.min.js +++ b/components/prism-less.min.js @@ -1 +1 @@ -Prism.languages.less=Prism.languages.extend("css",{comment:[/\/\*[\w\W]*?\*\//,{pattern:/(^|[^\\])\/\/.+/,lookbehind:!0}],atrule:{pattern:/@[\w-]+?(?:\([^{}]+\)|[^(){};])*?(?=\s*\{)/i,inside:{punctuation:/[:()]/}},selector:{pattern:/(?:@\{[\w-]+\}|[^{};\s@])(?:@\{[\w-]+\}|\([^{}]*\)|[^{};@])*?(?=\s*\{)/,inside:{variable:/@+[\w-]+/}},property:/(\b|\B)(?:@\{[\w-]+\}|[\w-])+(?:\+_?)?(?=\s*:)/i,punctuation:/[{}();:,]/,operator:/[+\-*\/]/}),Prism.languages.insertBefore("less","punctuation",{"function":Prism.languages.less.function}),Prism.languages.insertBefore("less","property",{variable:[{pattern:/@[\w-]+\s*:/,inside:{punctuation:/:/}},/@@?[\w-]+/],"mixin-usage":{pattern:/([{;]\s*)[.#](?!\d)[\w-]+.*?(?=[(;])/,lookbehind:!0,alias:"function"}}); \ No newline at end of file +Prism.languages.less=Prism.languages.extend("css",{comment:[/\/\*[\w\W]*?\*\//,{pattern:/(^|[^\\])\/\/.*/,lookbehind:!0}],atrule:{pattern:/@[\w-]+?(?:\([^{}]+\)|[^(){};])*?(?=\s*\{)/i,inside:{punctuation:/[:()]/}},selector:{pattern:/(?:@\{[\w-]+\}|[^{};\s@])(?:@\{[\w-]+\}|\([^{}]*\)|[^{};@])*?(?=\s*\{)/,inside:{variable:/@+[\w-]+/}},property:/(\b|\B)(?:@\{[\w-]+\}|[\w-])+(?:\+_?)?(?=\s*:)/i,punctuation:/[{}();:,]/,operator:/[+\-*\/]/}),Prism.languages.insertBefore("less","punctuation",{"function":Prism.languages.less.function}),Prism.languages.insertBefore("less","property",{variable:[{pattern:/@[\w-]+\s*:/,inside:{punctuation:/:/}},/@@?[\w-]+/],"mixin-usage":{pattern:/([{;]\s*)[.#](?!\d)[\w-]+.*?(?=[(;])/,lookbehind:!0,alias:"function"}}); From 2acd30dcd625113b14a3edc994ba7ce2d7bc25f1 Mon Sep 17 00:00:00 2001 From: Daniel Flint Date: Fri, 17 Apr 2015 18:23:37 +1000 Subject: [PATCH 014/310] Work nicely with line-numbers plugin Generated content on the `pre` means if the highlighted area needs to scroll, the language will scroll out of view with the code. But that's better than completely breaking another plugin. --- plugins/show-language/index.html | 7 ------- plugins/show-language/prism-show-language.css | 7 +------ plugins/show-language/prism-show-language.js | 6 +++++- plugins/show-language/prism-show-language.min.css | 2 +- plugins/show-language/prism-show-language.min.js | 2 +- 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/plugins/show-language/index.html b/plugins/show-language/index.html index aa790af970..299a73cde1 100644 --- a/plugins/show-language/index.html +++ b/plugins/show-language/index.html @@ -36,13 +36,6 @@

HTML (Markup)


 
 
-
-

Known Issues

- -
    -
  • Changes the appearence of the Funky theme, to be less 'funky' and more 'black'
  • -
-
diff --git a/plugins/show-language/prism-show-language.css b/plugins/show-language/prism-show-language.css index 336f0f9b96..4a3c2f29f6 100644 --- a/plugins/show-language/prism-show-language.css +++ b/plugins/show-language/prism-show-language.css @@ -1,12 +1,7 @@ pre[class*='language-'] { position: relative; } -pre[class*='language-'] > code[data-language] { - overflow: auto; - max-height: 28em; - display: block; -} -pre[class*='language-'] > code[data-language]::before { +pre[class*='language-'][data-language]::before { content: attr(data-language); color: black; background-color: #CFCFCF; diff --git a/plugins/show-language/prism-show-language.js b/plugins/show-language/prism-show-language.js index 7ca2f231a9..7b345d39be 100644 --- a/plugins/show-language/prism-show-language.js +++ b/plugins/show-language/prism-show-language.js @@ -9,8 +9,12 @@ var Languages = { 'cpp': 'C++' }; Prism.hooks.add('before-highlight', function(env) { + var pre = env.element.parentNode; + if (!pre || !/pre/i.test(pre.nodeName)) { + return; + } var language = Languages[env.language] || env.language; - env.element.setAttribute('data-language', language); + pre.setAttribute('data-language', language); }); })(); diff --git a/plugins/show-language/prism-show-language.min.css b/plugins/show-language/prism-show-language.min.css index 0444f4dda3..16a7f46830 100644 --- a/plugins/show-language/prism-show-language.min.css +++ b/plugins/show-language/prism-show-language.min.css @@ -1 +1 @@ -pre[class*=language-]{position:relative}pre[class*=language-]>code[data-language]{overflow:auto;max-height:28em;display:block}pre[class*=language-]>code[data-language]::before{content:attr(data-language);color:#000;background-color:#CFCFCF;display:inline-block;position:absolute;top:0;right:0;font-size:.9em;border-radius:0 0 0 5px;padding:0 .5em;text-shadow:none} \ No newline at end of file +pre[class*=language-]{position:relative}pre[class*=language-][data-language]::before{content:attr(data-language);color:#000;background-color:#CFCFCF;display:inline-block;position:absolute;top:0;right:0;font-size:.9em;border-radius:0 0 0 5px;padding:0 .5em;text-shadow:none} \ No newline at end of file diff --git a/plugins/show-language/prism-show-language.min.js b/plugins/show-language/prism-show-language.min.js index 4ac0d48ab3..3f9280d985 100644 --- a/plugins/show-language/prism-show-language.min.js +++ b/plugins/show-language/prism-show-language.min.js @@ -1 +1 @@ -!function(){if(self.Prism){var a={csharp:"C#",cpp:"C++"};Prism.hooks.add("before-highlight",function(e){var t=a[e.language]||e.language;e.element.setAttribute("data-language",t)})}}(); \ No newline at end of file +!function(){if(self.Prism){var e={csharp:"C#",cpp:"C++"};Prism.hooks.add("before-highlight",function(a){var t=a.element.parentNode;if(t&&/pre/i.test(t.nodeName)){var i=e[a.language]||a.language;t.setAttribute("data-language",i)}})}}(); \ No newline at end of file From 969cda6fd2562b23df74c082906bd4b53796beca Mon Sep 17 00:00:00 2001 From: Golmote Date: Sun, 26 Apr 2015 12:05:19 +0200 Subject: [PATCH 015/310] Fix typo in Python keywords: "elf" => "elif". Fix #573 --- components/prism-python.js | 2 +- components/prism-python.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/prism-python.js b/components/prism-python.js index ceda1631d3..f04765b56c 100644 --- a/components/prism-python.js +++ b/components/prism-python.js @@ -4,7 +4,7 @@ Prism.languages.python= { lookbehind: true }, 'string': /"""[\s\S]+?"""|'''[\s\S]+?'''|("|')(\\?.)*?\1/, - 'keyword' : /\b(as|assert|break|class|continue|def|del|elf|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/, + 'keyword' : /\b(as|assert|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/, 'boolean' : /\b(True|False)\b/, 'number' : /\b-?(0[box])?(?:[\da-f]+\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i, 'operator' : /[-+]|<=?|>=?|!|={1,2}|&{1,2}|\|?\||\?|\*|\/|~|\^|%|\b(or|and|not)\b/, diff --git a/components/prism-python.min.js b/components/prism-python.min.js index 6f615d3e0a..3bd60b4f42 100644 --- a/components/prism-python.min.js +++ b/components/prism-python.min.js @@ -1 +1 @@ -Prism.languages.python={comment:{pattern:/(^|[^\\])#.*?(\r?\n|$)/,lookbehind:!0},string:/"""[\s\S]+?"""|'''[\s\S]+?'''|("|')(\\?.)*?\1/,keyword:/\b(as|assert|break|class|continue|def|del|elf|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/,"boolean":/\b(True|False)\b/,number:/\b-?(0[box])?(?:[\da-f]+\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,operator:/[-+]|<=?|>=?|!|={1,2}|&{1,2}|\|?\||\?|\*|\/|~|\^|%|\b(or|and|not)\b/,punctuation:/[{}[\];(),.:]/}; \ No newline at end of file +Prism.languages.python={comment:{pattern:/(^|[^\\])#.*?(\r?\n|$)/,lookbehind:!0},string:/"""[\s\S]+?"""|'''[\s\S]+?'''|("|')(\\?.)*?\1/,keyword:/\b(as|assert|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/,"boolean":/\b(True|False)\b/,number:/\b-?(0[box])?(?:[\da-f]+\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,operator:/[-+]|<=?|>=?|!|={1,2}|&{1,2}|\|?\||\?|\*|\/|~|\^|%|\b(or|and|not)\b/,punctuation:/[{}[\];(),.:]/}; \ No newline at end of file From 33bebfe7bbac6c44ec53f7acb5f4547fe7746eb5 Mon Sep 17 00:00:00 2001 From: Golmote Date: Wed, 6 May 2015 07:38:23 +0200 Subject: [PATCH 016/310] Line-numbers : accept CSS class on both
 and
 . Fixes #568

---
 plugins/line-numbers/prism-line-numbers.js     | 18 ++++++++++++++++--
 plugins/line-numbers/prism-line-numbers.min.js |  2 +-
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/plugins/line-numbers/prism-line-numbers.js b/plugins/line-numbers/prism-line-numbers.js
index 329d568ac5..9443deb7dc 100644
--- a/plugins/line-numbers/prism-line-numbers.js
+++ b/plugins/line-numbers/prism-line-numbers.js
@@ -1,10 +1,24 @@
 Prism.hooks.add('after-highlight', function (env) {
-	// works only for  wrapped inside 
 (not inline)
+	// works only for  wrapped inside 
 (not inline)
 	var pre = env.element.parentNode;
-	if (!pre || !/pre/i.test(pre.nodeName) || pre.className.indexOf('line-numbers') === -1) {
+	var clsReg = /\s*\bline-numbers\b\s*/;
+	if (
+		!pre || !/pre/i.test(pre.nodeName) ||
+		// Abort only if nor the 
 nor the  have the class
+		(!clsReg.test(pre.className) && !clsReg.test(env.element.className))
+	) {
 		return;
 	}
 
+	if (clsReg.test(env.element.className)) {
+		// Remove the class "line-numbers" from the 
+		env.element.className = env.element.className.replace(clsReg, '');
+	}
+	if (!clsReg.test(pre.className)) {
+		// Add the class "line-numbers" to the 
+		pre.className += ' line-numbers';
+	}
+
 	var linesNum = (1 + env.code.split('\n').length);
 	var lineNumbersWrapper;
 
diff --git a/plugins/line-numbers/prism-line-numbers.min.js b/plugins/line-numbers/prism-line-numbers.min.js
index a0172fc885..26f0a22514 100644
--- a/plugins/line-numbers/prism-line-numbers.min.js
+++ b/plugins/line-numbers/prism-line-numbers.min.js
@@ -1 +1 @@
-Prism.hooks.add("after-highlight",function(e){var t=e.element.parentNode;if(t&&/pre/i.test(t.nodeName)&&-1!==t.className.indexOf("line-numbers")){var n,a=1+e.code.split("\n").length,r=new Array(a);r=r.join(""),n=document.createElement("span"),n.className="line-numbers-rows",n.innerHTML=r,t.hasAttribute("data-start")&&(t.style.counterReset="linenumber "+(parseInt(t.getAttribute("data-start"),10)-1)),e.element.appendChild(n)}});
\ No newline at end of file
+Prism.hooks.add("after-highlight",function(e){var t=e.element.parentNode,s=/\s*\bline-numbers\b\s*/;if(t&&/pre/i.test(t.nodeName)&&(s.test(t.className)||s.test(e.element.className))){s.test(e.element.className)&&(e.element.className=e.element.className.replace(s,"")),s.test(t.className)||(t.className+=" line-numbers");var a,n=1+e.code.split("\n").length,l=new Array(n);l=l.join(""),a=document.createElement("span"),a.className="line-numbers-rows",a.innerHTML=l,t.hasAttribute("data-start")&&(t.style.counterReset="linenumber "+(parseInt(t.getAttribute("data-start"),10)-1)),e.element.appendChild(a)}});
\ No newline at end of file

From 951e973eaf6f61f9bbba513ed075638aa1c76b65 Mon Sep 17 00:00:00 2001
From: beckwith 
Date: Fri, 8 May 2015 08:27:36 -0700
Subject: [PATCH 017/310] add dockerfile highlighting

---
 components.js                  |  4 ++++
 components/prism-docker.js     |  8 +++++++
 examples/prism-dockerfile.html | 39 ++++++++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+)
 create mode 100644 components/prism-docker.js
 create mode 100644 examples/prism-dockerfile.html

diff --git a/components.js b/components.js
index 7be18694e5..8997f0ac60 100644
--- a/components.js
+++ b/components.js
@@ -114,6 +114,10 @@ var components = {
 			"require": "clike",
 			"owner": "Golmote"
 		},
+		"dockerfile": {
+			"title": "Dockerfile",
+			"owner": "JustinBeckwith"
+		},
 		"eiffel": {
 			"title": "Eiffel",
 			"owner": "Conaclos"
diff --git a/components/prism-docker.js b/components/prism-docker.js
new file mode 100644
index 0000000000..835f037591
--- /dev/null
+++ b/components/prism-docker.js
@@ -0,0 +1,8 @@
+Prism.languages.docker = {
+	'keyword': {
+    pattern: /^\s*\b(ONBUILD|FROM|MAINTAINER|RUN|EXPOSE|ENV|ADD|COPY|VOLUME|USER|WORKDIR|CMD|ENTRYPOINT)\b\s/mi
+	},
+  'string': /("|')(\\\n|\\?.)*?\1/,
+	'comment': /#[^\n]+/,
+  'punctuation': /([:[\]{}\-,|>?]|---|\.\.\.)/
+};
diff --git a/examples/prism-dockerfile.html b/examples/prism-dockerfile.html
new file mode 100644
index 0000000000..295a3cff60
--- /dev/null
+++ b/examples/prism-dockerfile.html
@@ -0,0 +1,39 @@
+

Dockerfile

+

To use this language, use the class "language-docker".

+ +

Comments

+
# These are the comments for a dockerfile.
+# I want to make sure $(variables) don't break out,
+# and we shouldn't see keywords like ADD or ENTRYPOINT
+
+ +

Instructions

+
# Use the official go docker image built on debian.
+FROM golang:1.4.2
+
+# Grab the source code and add it to the workspace.
+ADD . /go/src/github.com/JustinBeckwith/revel-appengine
+
+# Install revel and the revel CLI.
+RUN go get github.com/revel/revel
+RUN go get github.com/revel/cmd/revel
+
+ + +

Full example

+
# Use the official go docker image built on debian.
+FROM golang:1.4.2
+
+# Grab the source code and add it to the workspace.
+ADD . /go/src/github.com/JustinBeckwith/revel-appengine
+
+# Install revel and the revel CLI.
+RUN go get github.com/revel/revel
+RUN go get github.com/revel/cmd/revel
+
+# Use the revel CLI to start up our application.
+ENTRYPOINT revel run github.com/JustinBeckwith/revel-appengine dev 8080
+
+# Open up the port where the app is running.
+EXPOSE 8080
+
From 99d87ca25e68ee6ae1c1052c8a17347a8895fe7f Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Wed, 13 May 2015 17:54:36 -0700 Subject: [PATCH 018/310] fix CR feedback, add better sample --- components.js | 4 +-- components/prism-docker.js | 9 +++--- examples/prism-docker.html | 52 ++++++++++++++++++++++++++++++++++ examples/prism-dockerfile.html | 39 ------------------------- 4 files changed, 59 insertions(+), 45 deletions(-) create mode 100644 examples/prism-docker.html delete mode 100644 examples/prism-dockerfile.html diff --git a/components.js b/components.js index 8997f0ac60..346cb8ebe5 100644 --- a/components.js +++ b/components.js @@ -114,8 +114,8 @@ var components = { "require": "clike", "owner": "Golmote" }, - "dockerfile": { - "title": "Dockerfile", + "docker": { + "title": "Docker", "owner": "JustinBeckwith" }, "eiffel": { diff --git a/components/prism-docker.js b/components/prism-docker.js index 835f037591..b8724b51c2 100644 --- a/components/prism-docker.js +++ b/components/prism-docker.js @@ -1,8 +1,9 @@ Prism.languages.docker = { 'keyword': { - pattern: /^\s*\b(ONBUILD|FROM|MAINTAINER|RUN|EXPOSE|ENV|ADD|COPY|VOLUME|USER|WORKDIR|CMD|ENTRYPOINT)\b\s/mi + pattern: /(^\s*)(?:ONBUILD|FROM|MAINTAINER|RUN|EXPOSE|ENV|ADD|COPY|VOLUME|USER|WORKDIR|CMD|ENTRYPOINT)(?=\s)/mi, + lookbehind: true }, - 'string': /("|')(\\\n|\\?.)*?\1/, - 'comment': /#[^\n]+/, - 'punctuation': /([:[\]{}\-,|>?]|---|\.\.\.)/ + 'string': /("|')(\\\n|\\?.)*?\1/, + 'comment': /#.*/, + 'punctuation': /([:[\]{}\-,|>?]|---|\.\.\.)/ }; diff --git a/examples/prism-docker.html b/examples/prism-docker.html new file mode 100644 index 0000000000..a37b2df2ed --- /dev/null +++ b/examples/prism-docker.html @@ -0,0 +1,52 @@ +

Docker

+

To use this language, use the class "language-docker".

+ +

Comments

+
# These are the comments for a dockerfile.
+# I want to make sure $(variables) don't break out,
+# and we shouldn't see keywords like ADD or ENTRYPOINT
+
+ +

Full example

+
# Nginx
+#
+# VERSION               0.0.1
+
+FROM      ubuntu
+MAINTAINER Victor Vieux 
+
+LABEL Description="This image is used to start the foobar executable" Vendor="ACME Products" Version="1.0"
+RUN apt-get update && apt-get install -y inotify-tools nginx apache2 openssh-server
+
+# Firefox over VNC
+#
+# VERSION               0.3
+
+FROM ubuntu
+
+# Install vnc, xvfb in order to create a 'fake' display and firefox
+RUN apt-get update && apt-get install -y x11vnc xvfb firefox
+RUN mkdir ~/.vnc
+# Setup a password
+RUN x11vnc -storepasswd 1234 ~/.vnc/passwd
+# Autostart firefox (might not be the best way, but it does the trick)
+RUN bash -c 'echo "firefox" >> /.bashrc'
+
+EXPOSE 5900
+CMD    ["x11vnc", "-forever", "-usepw", "-create"]
+
+# Multiple images example
+#
+# VERSION               0.1
+
+FROM ubuntu
+RUN echo foo > bar
+# Will output something like ===> 907ad6c2736f
+
+FROM ubuntu
+RUN echo moo > oink
+# Will output something like ===> 695d7793cbe4
+
+# You᾿ll now have two images, 907ad6c2736f with /bar, and 695d7793cbe4 with
+# /oink.
+
diff --git a/examples/prism-dockerfile.html b/examples/prism-dockerfile.html deleted file mode 100644 index 295a3cff60..0000000000 --- a/examples/prism-dockerfile.html +++ /dev/null @@ -1,39 +0,0 @@ -

Dockerfile

-

To use this language, use the class "language-docker".

- -

Comments

-
# These are the comments for a dockerfile.
-# I want to make sure $(variables) don't break out,
-# and we shouldn't see keywords like ADD or ENTRYPOINT
-
- -

Instructions

-
# Use the official go docker image built on debian.
-FROM golang:1.4.2
-
-# Grab the source code and add it to the workspace.
-ADD . /go/src/github.com/JustinBeckwith/revel-appengine
-
-# Install revel and the revel CLI.
-RUN go get github.com/revel/revel
-RUN go get github.com/revel/cmd/revel
-
- - -

Full example

-
# Use the official go docker image built on debian.
-FROM golang:1.4.2
-
-# Grab the source code and add it to the workspace.
-ADD . /go/src/github.com/JustinBeckwith/revel-appengine
-
-# Install revel and the revel CLI.
-RUN go get github.com/revel/revel
-RUN go get github.com/revel/cmd/revel
-
-# Use the revel CLI to start up our application.
-ENTRYPOINT revel run github.com/JustinBeckwith/revel-appengine dev 8080
-
-# Open up the port where the app is running.
-EXPOSE 8080
-
From d795397ef0880bfb79efa2481b7155981be8ef4e Mon Sep 17 00:00:00 2001 From: Golmote Date: Sat, 23 May 2015 10:25:16 +0200 Subject: [PATCH 019/310] C#: Verbatim strings can contain doubled quotes and new lines --- components/prism-csharp.js | 5 ++++- components/prism-csharp.min.js | 2 +- examples/prism-csharp.html | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/components/prism-csharp.js b/components/prism-csharp.js index b405a85eb2..50ee493ee1 100644 --- a/components/prism-csharp.js +++ b/components/prism-csharp.js @@ -1,6 +1,9 @@ Prism.languages.csharp = Prism.languages.extend('clike', { 'keyword': /\b(abstract|as|async|await|base|bool|break|byte|case|catch|char|checked|class|const|continue|decimal|default|delegate|do|double|else|enum|event|explicit|extern|false|finally|fixed|float|for|foreach|goto|if|implicit|in|int|interface|internal|is|lock|long|namespace|new|null|object|operator|out|override|params|private|protected|public|readonly|ref|return|sbyte|sealed|short|sizeof|stackalloc|static|string|struct|switch|this|throw|true|try|typeof|uint|ulong|unchecked|unsafe|ushort|using|virtual|void|volatile|while|add|alias|ascending|async|await|descending|dynamic|from|get|global|group|into|join|let|orderby|partial|remove|select|set|value|var|where|yield)\b/, - 'string': /@?("|')(\\?.)*?\1/, + 'string': [ + /@("|')(\1\1|\\\1|\\?(?!\1)[\s\S])*\1/, + /("|')(\\?.)*?\1/ + ], 'preprocessor': /^\s*#.*/m, 'number': /\b-?(0x[\da-f]+|\d*\.?\d+)\b/i }); diff --git a/components/prism-csharp.min.js b/components/prism-csharp.min.js index 526a84705c..abde3d03c6 100644 --- a/components/prism-csharp.min.js +++ b/components/prism-csharp.min.js @@ -1 +1 @@ -Prism.languages.csharp=Prism.languages.extend("clike",{keyword:/\b(abstract|as|async|await|base|bool|break|byte|case|catch|char|checked|class|const|continue|decimal|default|delegate|do|double|else|enum|event|explicit|extern|false|finally|fixed|float|for|foreach|goto|if|implicit|in|int|interface|internal|is|lock|long|namespace|new|null|object|operator|out|override|params|private|protected|public|readonly|ref|return|sbyte|sealed|short|sizeof|stackalloc|static|string|struct|switch|this|throw|true|try|typeof|uint|ulong|unchecked|unsafe|ushort|using|virtual|void|volatile|while|add|alias|ascending|async|await|descending|dynamic|from|get|global|group|into|join|let|orderby|partial|remove|select|set|value|var|where|yield)\b/,string:/@?("|')(\\?.)*?\1/,preprocessor:/^\s*#.*/m,number:/\b-?(0x[\da-f]+|\d*\.?\d+)\b/i}); \ No newline at end of file +Prism.languages.csharp=Prism.languages.extend("clike",{keyword:/\b(abstract|as|async|await|base|bool|break|byte|case|catch|char|checked|class|const|continue|decimal|default|delegate|do|double|else|enum|event|explicit|extern|false|finally|fixed|float|for|foreach|goto|if|implicit|in|int|interface|internal|is|lock|long|namespace|new|null|object|operator|out|override|params|private|protected|public|readonly|ref|return|sbyte|sealed|short|sizeof|stackalloc|static|string|struct|switch|this|throw|true|try|typeof|uint|ulong|unchecked|unsafe|ushort|using|virtual|void|volatile|while|add|alias|ascending|async|await|descending|dynamic|from|get|global|group|into|join|let|orderby|partial|remove|select|set|value|var|where|yield)\b/,string:[/@("|')(\1\1|\\\1|\\?(?!\1)[\s\S])*\1/,/("|')(\\?.)*?\1/],preprocessor:/^\s*#.*/m,number:/\b-?(0x[\da-f]+|\d*\.?\d+)\b/i}); \ No newline at end of file diff --git a/examples/prism-csharp.html b/examples/prism-csharp.html index 84d760f14d..9073aedab1 100644 --- a/examples/prism-csharp.html +++ b/examples/prism-csharp.html @@ -10,6 +10,10 @@

Strings

"foo \"bar\" baz"
 'foo \'bar\' baz'
 @"Verbatim strings"
+@"Luis: ""Patrick, where did you get that overnight bag?""
+    Patrick: ""Jean Paul Gaultier.""";
+@'Luis: ''Patrick, where did you get that overnight bag?''
+    Patrick: ''Jean Paul Gaultier.''';
 

Full example

From 534f34cd35526481e4a32ac4d1eaf447a5a64bf2 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sat, 23 May 2015 10:26:08 +0200 Subject: [PATCH 020/310] Run gulp task --- components/prism-less.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/prism-less.min.js b/components/prism-less.min.js index 5f826d6903..e470eab9b0 100644 --- a/components/prism-less.min.js +++ b/components/prism-less.min.js @@ -1 +1 @@ -Prism.languages.less=Prism.languages.extend("css",{comment:[/\/\*[\w\W]*?\*\//,{pattern:/(^|[^\\])\/\/.*/,lookbehind:!0}],atrule:{pattern:/@[\w-]+?(?:\([^{}]+\)|[^(){};])*?(?=\s*\{)/i,inside:{punctuation:/[:()]/}},selector:{pattern:/(?:@\{[\w-]+\}|[^{};\s@])(?:@\{[\w-]+\}|\([^{}]*\)|[^{};@])*?(?=\s*\{)/,inside:{variable:/@+[\w-]+/}},property:/(\b|\B)(?:@\{[\w-]+\}|[\w-])+(?:\+_?)?(?=\s*:)/i,punctuation:/[{}();:,]/,operator:/[+\-*\/]/}),Prism.languages.insertBefore("less","punctuation",{"function":Prism.languages.less.function}),Prism.languages.insertBefore("less","property",{variable:[{pattern:/@[\w-]+\s*:/,inside:{punctuation:/:/}},/@@?[\w-]+/],"mixin-usage":{pattern:/([{;]\s*)[.#](?!\d)[\w-]+.*?(?=[(;])/,lookbehind:!0,alias:"function"}}); +Prism.languages.less=Prism.languages.extend("css",{comment:[/\/\*[\w\W]*?\*\//,{pattern:/(^|[^\\])\/\/.*/,lookbehind:!0}],atrule:{pattern:/@[\w-]+?(?:\([^{}]+\)|[^(){};])*?(?=\s*\{)/i,inside:{punctuation:/[:()]/}},selector:{pattern:/(?:@\{[\w-]+\}|[^{};\s@])(?:@\{[\w-]+\}|\([^{}]*\)|[^{};@])*?(?=\s*\{)/,inside:{variable:/@+[\w-]+/}},property:/(\b|\B)(?:@\{[\w-]+\}|[\w-])+(?:\+_?)?(?=\s*:)/i,punctuation:/[{}();:,]/,operator:/[+\-*\/]/}),Prism.languages.insertBefore("less","punctuation",{"function":Prism.languages.less.function}),Prism.languages.insertBefore("less","property",{variable:[{pattern:/@[\w-]+\s*:/,inside:{punctuation:/:/}},/@@?[\w-]+/],"mixin-usage":{pattern:/([{;]\s*)[.#](?!\d)[\w-]+.*?(?=[(;])/,lookbehind:!0,alias:"function"}}); \ No newline at end of file From 81eff5476fe6b703b13643b52285b6151055a7f4 Mon Sep 17 00:00:00 2001 From: Weston Ganger Date: Sat, 23 May 2015 14:54:09 -0700 Subject: [PATCH 021/310] fixed string interpolation feature --- components/prism-ruby.js | 28 ++++++++++++++++++++++------ examples/prism-ruby.html | 8 +++++++- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/components/prism-ruby.js b/components/prism-ruby.js index 554d6873e4..e1a19d3475 100644 --- a/components/prism-ruby.js +++ b/components/prism-ruby.js @@ -5,17 +5,33 @@ * constant, builtin, variable, symbol, regex */ Prism.languages.ruby = Prism.languages.extend('clike', { - 'comment': /#[^\r\n]*(\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/, + 'comment': /#(?!\{[^\r\n]*?\})[^\r\n]*(\r?\n|$)/g, + '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/g, '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/ + 'constant': /\b[A-Z][a-zA-Z_0-9]*[?!]?\b/g }); Prism.languages.insertBefore('ruby', 'keyword', { 'regex': { - pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/, + pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/g, lookbehind: true }, - 'variable': /[@$]+\b[a-zA-Z_][a-zA-Z_0-9]*[?!]?\b/, - 'symbol': /:\b[a-zA-Z_][a-zA-Z_0-9]*[?!]?\b/ + 'variable': /[@$]+\b[a-zA-Z_][a-zA-Z_0-9]*[?!]?\b/g, + 'symbol': /:\b[a-zA-Z_][a-zA-Z_0-9]*[?!]?\b/g }); + +Prism.languages.ruby.string = { + pattern: /("|')(\\\n|\\?.)*?\1/, + inside: { + 'interpolation': { + pattern: /#\{[^}]+\}/, + inside: { + 'delimiter': { + pattern: /^#\{|\}$/, + alias: 'tag' + }, + rest: Prism.languages.extend('ruby') + } + } + } +}; diff --git a/examples/prism-ruby.html b/examples/prism-ruby.html index 8d724c98ce..4d6472e8b2 100644 --- a/examples/prism-ruby.html +++ b/examples/prism-ruby.html @@ -25,6 +25,9 @@

Variables

Symbols

mystring = :steveT;
+

String Interpolation

+
"foo #{'bar'+my_variable}"
+

Known failures

There are certain edge cases where Prism will fail. There are always such cases in every regex-based syntax highlighter. @@ -32,6 +35,9 @@

Known failures

If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug.

+

Comments that look like interpolation shows as ruby code

+
#{my_var}
+

Comment-like substrings

"foo # bar";
@@ -43,4 +49,4 @@

Multi-line comments are not supported

************************ This is a comment block ************************ -=end
\ No newline at end of file +=end
From 9020d78f89a0fbb92e0605d1fe165129df0e168c Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Mon, 25 May 2015 21:34:42 -0700 Subject: [PATCH 022/310] add label keyword to docker highlighter --- components/prism-docker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/prism-docker.js b/components/prism-docker.js index b8724b51c2..ddf909e2f6 100644 --- a/components/prism-docker.js +++ b/components/prism-docker.js @@ -1,6 +1,6 @@ Prism.languages.docker = { 'keyword': { - pattern: /(^\s*)(?:ONBUILD|FROM|MAINTAINER|RUN|EXPOSE|ENV|ADD|COPY|VOLUME|USER|WORKDIR|CMD|ENTRYPOINT)(?=\s)/mi, + pattern: /(^\s*)(?:ONBUILD|FROM|MAINTAINER|RUN|EXPOSE|ENV|ADD|COPY|VOLUME|USER|WORKDIR|CMD|LABEL|ENTRYPOINT)(?=\s)/mi, lookbehind: true }, 'string': /("|')(\\\n|\\?.)*?\1/, From e3f4d7af137edcc0843883ad1811b2eeafe8a199 Mon Sep 17 00:00:00 2001 From: Weston Ganger Date: Fri, 29 May 2015 20:31:17 -0700 Subject: [PATCH 023/310] added ruby string interpolation --- components/prism-ruby.js | 38 +++++++++++++++++++------------------- examples/prism-ruby.html | 3 +++ 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/components/prism-ruby.js b/components/prism-ruby.js index e1a19d3475..f34a6de4bb 100644 --- a/components/prism-ruby.js +++ b/components/prism-ruby.js @@ -5,33 +5,33 @@ * constant, builtin, variable, symbol, regex */ Prism.languages.ruby = Prism.languages.extend('clike', { - 'comment': /#(?!\{[^\r\n]*?\})[^\r\n]*(\r?\n|$)/g, - '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/g, + 'comment': /#(?!\{[^\r\n]*?\})[^\r\n]*(\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/, '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/g + 'constant': /\b[A-Z][a-zA-Z_0-9]*[?!]?\b/ }); Prism.languages.insertBefore('ruby', 'keyword', { 'regex': { - pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/g, + pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/, lookbehind: true }, - 'variable': /[@$]+\b[a-zA-Z_][a-zA-Z_0-9]*[?!]?\b/g, - 'symbol': /:\b[a-zA-Z_][a-zA-Z_0-9]*[?!]?\b/g + 'variable': /[@$]+\b[a-zA-Z_][a-zA-Z_0-9]*[?!]?\b/, + 'symbol': /:\b[a-zA-Z_][a-zA-Z_0-9]*[?!]?\b/ }); Prism.languages.ruby.string = { - pattern: /("|')(\\\n|\\?.)*?\1/, - inside: { - 'interpolation': { - pattern: /#\{[^}]+\}/, - inside: { - 'delimiter': { - pattern: /^#\{|\}$/, - alias: 'tag' - }, - rest: Prism.languages.extend('ruby') - } - } - } + pattern: /("|')(\\\n|\\?.)*?\1/, + inside: { + 'interpolation': { + pattern: /#\{[^}]+\}/, + inside: { + 'delimiter': { + pattern: /^#\{|\}$/, + alias: 'tag' + }, + rest: Prism.util.clone(Prism.languages.ruby) + } + } + } }; diff --git a/examples/prism-ruby.html b/examples/prism-ruby.html index 4d6472e8b2..1e7b748aa1 100644 --- a/examples/prism-ruby.html +++ b/examples/prism-ruby.html @@ -38,6 +38,9 @@

Known failures

Comments that look like interpolation shows as ruby code

#{my_var}
+

Double quoted strings inside of string interpolation

+
"foo #{my_var + "bar"}"
+

Comment-like substrings

"foo # bar";
From 67b89eaf0ff666573261b7856b262c4cf26f8bc9 Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Mon, 1 Jun 2015 18:45:17 +0200 Subject: [PATCH 024/310] Handlebars: support blocks with dashes --- components/prism-handlebars.js | 4 ++-- components/prism-handlebars.min.js | 2 +- examples/prism-handlebars.html | 10 +++++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/components/prism-handlebars.js b/components/prism-handlebars.js index 3154940500..00fe7714d6 100644 --- a/components/prism-handlebars.js +++ b/components/prism-handlebars.js @@ -1,7 +1,7 @@ (function(Prism) { var handlebars_pattern = /\{\{\{[\w\W]+?\}\}\}|\{\{[\w\W]+?\}\}/g; - + Prism.languages.handlebars = Prism.languages.extend('markup', { 'handlebars': { pattern: handlebars_pattern, @@ -14,7 +14,7 @@ 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/, 'boolean': /\b(true|false)\b/, 'block': { - pattern: /^(\s*~?\s*)[#\/]\w+/i, + pattern: /^(\s*~?\s*)[#\/]\S+/i, lookbehind: true, alias: 'keyword' }, diff --git a/components/prism-handlebars.min.js b/components/prism-handlebars.min.js index d303e50220..acafd0c263 100644 --- a/components/prism-handlebars.min.js +++ b/components/prism-handlebars.min.js @@ -1 +1 @@ -!function(e){var a=/\{\{\{[\w\W]+?\}\}\}|\{\{[\w\W]+?\}\}/g;e.languages.handlebars=e.languages.extend("markup",{handlebars:{pattern:a,inside:{delimiter:{pattern:/^\{\{\{?|\}\}\}?$/i,alias:"punctuation"},string:/(["'])(\\?.)+?\1/,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,"boolean":/\b(true|false)\b/,block:{pattern:/^(\s*~?\s*)[#\/]\w+/i,lookbehind:!0,alias:"keyword"},brackets:{pattern:/\[[^\]]+\]/,inside:{punctuation:/\[|\]/,variable:/[\w\W]+/}},punctuation:/[!"#%&'()*+,.\/;<=>@\[\\\]^`{|}~]/,variable:/[^!"#%&'()*+,.\/;<=>@\[\\\]^`{|}~]+/}}}),e.languages.insertBefore("handlebars","tag",{"handlebars-comment":{pattern:/\{\{![\w\W]*?\}\}/,alias:["handlebars","comment"]}}),e.hooks.add("before-highlight",function(e){"handlebars"===e.language&&(e.tokenStack=[],e.backupCode=e.code,e.code=e.code.replace(a,function(a){return e.tokenStack.push(a),"___HANDLEBARS"+e.tokenStack.length+"___"}))}),e.hooks.add("before-insert",function(e){"handlebars"===e.language&&(e.code=e.backupCode,delete e.backupCode)}),e.hooks.add("after-highlight",function(a){if("handlebars"===a.language){for(var n,t=0;n=a.tokenStack[t];t++)a.highlightedCode=a.highlightedCode.replace("___HANDLEBARS"+(t+1)+"___",e.highlight(n,a.grammar,"handlebars"));a.element.innerHTML=a.highlightedCode}})}(Prism); \ No newline at end of file +!function(e){var a=/\{\{\{[\w\W]+?\}\}\}|\{\{[\w\W]+?\}\}/g;e.languages.handlebars=e.languages.extend("markup",{handlebars:{pattern:a,inside:{delimiter:{pattern:/^\{\{\{?|\}\}\}?$/i,alias:"punctuation"},string:/(["'])(\\?.)+?\1/,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,"boolean":/\b(true|false)\b/,block:{pattern:/^(\s*~?\s*)[#\/]\S+/i,lookbehind:!0,alias:"keyword"},brackets:{pattern:/\[[^\]]+\]/,inside:{punctuation:/\[|\]/,variable:/[\w\W]+/}},punctuation:/[!"#%&'()*+,.\/;<=>@\[\\\]^`{|}~]/,variable:/[^!"#%&'()*+,.\/;<=>@\[\\\]^`{|}~]+/}}}),e.languages.insertBefore("handlebars","tag",{"handlebars-comment":{pattern:/\{\{![\w\W]*?\}\}/,alias:["handlebars","comment"]}}),e.hooks.add("before-highlight",function(e){"handlebars"===e.language&&(e.tokenStack=[],e.backupCode=e.code,e.code=e.code.replace(a,function(a){return e.tokenStack.push(a),"___HANDLEBARS"+e.tokenStack.length+"___"}))}),e.hooks.add("before-insert",function(e){"handlebars"===e.language&&(e.code=e.backupCode,delete e.backupCode)}),e.hooks.add("after-highlight",function(a){if("handlebars"===a.language){for(var n,t=0;n=a.tokenStack[t];t++)a.highlightedCode=a.highlightedCode.replace("___HANDLEBARS"+(t+1)+"___",e.highlight(n,a.grammar,"handlebars"));a.element.innerHTML=a.highlightedCode}})}(Prism); \ No newline at end of file diff --git a/examples/prism-handlebars.html b/examples/prism-handlebars.html index ec7d31d4f0..49c5096e34 100644 --- a/examples/prism-handlebars.html +++ b/examples/prism-handlebars.html @@ -26,8 +26,12 @@

Block helpers

{{/with}} <div class="{{#if test}}foo{{else}}bar{{/if}}"></div> {{#list array}} - {{@index}}. {{title}} -{{/list}}
+ {{@index}}. {{title}} +{{/list}} +{{#block-with-hyphens args=yep}} + This should probably work... +{{/block-with-hyphens}} +

Known failures

There are certain edge cases where Prism will fail. @@ -37,4 +41,4 @@

Known failures

Handlebars tag in the middle of an HTML tag

-
<div{{#if test}} class="test"{{/if}}></div>
\ No newline at end of file +
<div{{#if test}} class="test"{{/if}}></div>
From f45dc851351e2736ab4a775e6d79136350a94957 Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Mon, 1 Jun 2015 18:53:38 +0200 Subject: [PATCH 025/310] Install mocha --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 06152b4fa8..74b926099b 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "gulp-concat": "^2.3.4", "gulp-header": "^1.0.5", "gulp-rename": "^1.2.0", - "gulp-uglify": "^0.3.1" + "gulp-uglify": "^0.3.1", + "mocha": "^2.2.5" } } From d1f905209ae44960a956481f7133be504471d39f Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Mon, 1 Jun 2015 20:39:11 +0200 Subject: [PATCH 026/310] Implemented test runner --- package.json | 3 +- tests/helper/components.js | 11 ++++ tests/helper/prism-loader.js | 101 +++++++++++++++++++++++++++++ tests/helper/test-case.js | 71 ++++++++++++++++++++ tests/helper/test-discovery.js | 63 ++++++++++++++++++ tests/languages/javascript/test.js | 0 tests/run.js | 32 +++++++++ 7 files changed, 280 insertions(+), 1 deletion(-) create mode 100644 tests/helper/components.js create mode 100644 tests/helper/prism-loader.js create mode 100644 tests/helper/test-case.js create mode 100644 tests/helper/test-discovery.js create mode 100644 tests/languages/javascript/test.js create mode 100644 tests/run.js diff --git a/package.json b/package.json index 74b926099b..e254ad770a 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Lightweight, robust, elegant syntax highlighting. A spin-off project from Dabblet.", "main": "prism.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "mocha tests/run.js" }, "repository": { "type": "git", @@ -18,6 +18,7 @@ "license": "MIT", "readmeFilename": "README.md", "devDependencies": { + "chai": "^2.3.0", "gulp": "^3.8.6", "gulp-concat": "^2.3.4", "gulp-header": "^1.0.5", diff --git a/tests/helper/components.js b/tests/helper/components.js new file mode 100644 index 0000000000..274ad146f7 --- /dev/null +++ b/tests/helper/components.js @@ -0,0 +1,11 @@ +"use strict"; + +var fs = require("fs"); +var vm = require('vm'); + +var fileContent = fs.readFileSync(__dirname + "/../../components.js", "utf8"); +var context = {}; +vm.createContext(context); +vm.runInContext(fileContent, context); + +module.exports = context.components; diff --git a/tests/helper/prism-loader.js b/tests/helper/prism-loader.js new file mode 100644 index 0000000000..1f1426ac92 --- /dev/null +++ b/tests/helper/prism-loader.js @@ -0,0 +1,101 @@ +"use strict"; + +var fs = require("fs"); +var vm = require('vm'); +var components = require("./components"); +var languagesCatalog = components.languages; + + +module.exports = { + + /** + * Creates a new Prism instance with the given language loaded + * + * @param {string} language + * @returns {Prism} + */ + createInstance: function (language) { + var Prism = this.createEmptyPrism(); + return this.loadLanguage(language, Prism); + }, + + + /** + * Loads the given language (including recursively loading the dependencies) and + * appends the config to the given Prism object + * + * @private + * @param {string} language + * @param {Prism} Prism + * @returns {Prism} + */ + loadLanguage: function (language, Prism) { + if (!languagesCatalog[language]) + { + throw new Error("Language '" + language + "' not found."); + } + + // if the language has a dependency -> load it first + if (languagesCatalog[language].require) + { + Prism = this.loadLanguage(languagesCatalog[language].require, Prism); + } + + // load the language itself + var languageSource = this.loadFileSource(language); + var context = this.runFileWithContext(languageSource, {Prism: Prism}); + + return context.Prism; + }, + + + /** + * Creates a new empty prism instance + * + * @private + * @returns {Prism} + */ + createEmptyPrism: function () { + var coreSource = this.loadFileSource("core"); + var context = this.runFileWithContext(coreSource); + return context.Prism; + }, + + + /** + * Cached file sources, to prevent massive HDD work + * + * @private + * @type {Object.} + */ + fileSourceCache: {}, + + + /** + * Loads the given file source as string + * + * @private + * @param {string} name + * @returns {string} + */ + loadFileSource: function (name) { + return this.fileSourceCache[name] = this.fileSourceCache[name] || fs.readFileSync(__dirname + "/../../components/prism-" + name + ".js", "utf8"); + }, + + + /** + * Runs a VM for a given file source with the given context + * + * @private + * @param {string} fileSource + * @param {*}context + * + * @returns {*} + */ + runFileWithContext: function (fileSource, context) { + context = context || {}; + vm.createContext(context); + vm.runInContext(fileSource, context); + return context; + } +}; diff --git a/tests/helper/test-case.js b/tests/helper/test-case.js new file mode 100644 index 0000000000..6afce39ae3 --- /dev/null +++ b/tests/helper/test-case.js @@ -0,0 +1,71 @@ +"use strict"; + +var fs = require("fs"); +var expect = require("chai").expect; +var PrismLoader = require("./prism-loader"); + +module.exports = { + + /** + * Runs the given test case file and asserts the result + * + * @param {string} language + * @param {string} filePath + */ + runTestCase: function (language, filePath) { + var testCase = this.parseTestCaseFile(filePath); + + if (null === testCase) { + throw new Error("Test case file has invalid format, please read the docs."); + } + + var Prism = PrismLoader.createInstance(language); + var compiledTokenStream = Prism.tokenize(testCase.testSource, Prism.languages[language]); + var simplifiedTokenStream = this.transformCompiledTokenStream(compiledTokenStream); + + expect(simplifiedTokenStream).to.eql(testCase.expectedTokenStream); + }, + + + /** + * Simplifies the token stream to ease the matching with the expected token stream + * + * @param {string} tokenStream + * @returns {Array.} + */ + transformCompiledTokenStream: function (tokenStream) { + return tokenStream.filter( + function (token) { + // only support objects + return (typeof token === "object"); + } + ).map( + function (entry) + { + return [entry.type, entry.content]; + } + ); + }, + + + /** + * Parses the test case from the given test case file + * + * @private + * @param {string} filePath + * @returns {{testSource: string, expectedTokenStream: *}|null} + */ + parseTestCaseFile: function (filePath) { + var testCaseSource = fs.readFileSync(filePath, "utf8"); + var testCase = testCaseSource.split(/^----*\w*$/m); + + if (2 === testCase.length) { + return { + testSource: testCase[0].trim(), + expectedTokenStream: JSON.parse(testCase[1]) + }; + } + + return null; + } +}; diff --git a/tests/helper/test-discovery.js b/tests/helper/test-discovery.js new file mode 100644 index 0000000000..9f9ea2dca4 --- /dev/null +++ b/tests/helper/test-discovery.js @@ -0,0 +1,63 @@ +"use strict"; + +var fs = require("fs"); +var path = require('path'); + + +module.exports = { + + /** + * Loads the list of all available tests + * + * @param {string} rootDir + * @returns {Object.} + */ + loadAllTests: function (rootDir) { + var testSuite = {}; + var self = this; + + this.getAllDirectories(rootDir).forEach( + function (language) { + testSuite[language] = self.getAllFiles(path.join(rootDir, language)); + } + ); + + return testSuite; + }, + + + /** + * Returns a list of all (sub)directories (just the directory names, not full paths) + * in the given src directory + * + * @param {string} src + * @returns {Array.} + */ + getAllDirectories: function (src) { + return fs.readdirSync(src).filter( + function (file) { + return fs.statSync(path.join(src, file)).isDirectory(); + } + ); + }, + + + /** + * Returns a list of all full file paths to all files in the given src directory + * + * @private + * @param {string} src + * @returns {Array.} + */ + getAllFiles: function (src) { + return fs.readdirSync(src).filter( + function (fileName) { + return fs.statSync(path.join(src, fileName)).isFile(); + } + ).map( + function (fileName) { + return path.join(src, fileName); + } + ); + } +}; diff --git a/tests/languages/javascript/test.js b/tests/languages/javascript/test.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/run.js b/tests/run.js new file mode 100644 index 0000000000..50bd20f137 --- /dev/null +++ b/tests/run.js @@ -0,0 +1,32 @@ +"use strict"; + +var TestDiscovery = require("./helper/test-discovery"); +var TestCase = require("./helper/test-case"); +var path = require("path"); + +// load complete test suite +var testSuite = TestDiscovery.loadAllTests(__dirname + "/languages"); + +// define tests for all tests in all languages in the test suite +for (var language in testSuite) +{ + if (!testSuite.hasOwnProperty(language)) { + continue; + } + + (function (language, testFiles) { + describe("Testing language '" + language + "'", function() { + testFiles.forEach( + function (filePath) { + var fileName = path.basename(filePath); + + it("Should pass test case '" + fileName + "'", + function () { + TestCase.runTestCase(language, filePath); + } + ); + } + ); + }); + })(language, testSuite[language]); +} From a806d1cc55f1d22d5a964c241bca40a74923763c Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Mon, 1 Jun 2015 20:39:28 +0200 Subject: [PATCH 027/310] Added first simple test case --- tests/languages/javascript/test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/languages/javascript/test.js b/tests/languages/javascript/test.js index e69de29bb2..df16f2e405 100644 --- a/tests/languages/javascript/test.js +++ b/tests/languages/javascript/test.js @@ -0,0 +1,10 @@ +var a = 5; + +---------------------------------------------------- + +[ + ["keyword", "var"], + ["operator", "="], + ["number", "5"], + ["punctuation", ";"] +] From 8c64e4779203ef3f9cce8adb8d3afd896ca364e1 Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Mon, 1 Jun 2015 21:12:37 +0200 Subject: [PATCH 028/310] Fixed internal test names --- tests/run.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run.js b/tests/run.js index 50bd20f137..32dab49fb5 100644 --- a/tests/run.js +++ b/tests/run.js @@ -20,7 +20,7 @@ for (var language in testSuite) function (filePath) { var fileName = path.basename(filePath); - it("Should pass test case '" + fileName + "'", + it("– should pass test case '" + fileName + "'", function () { TestCase.runTestCase(language, filePath); } From 4693499f5b97df5e79a8951c4de21c11a062916d Mon Sep 17 00:00:00 2001 From: Kevin Kirsche Date: Thu, 11 Jun 2015 20:52:53 -0400 Subject: [PATCH 029/310] Remove moot `version` property from bower.json Per bower/bower.json-spec@a325da3 Also their maintainer says they probably won't ever use it: http://stackoverflow.com/questions/24844901/bowers-bower-json-file-version-property --- bower.json | 1 - 1 file changed, 1 deletion(-) diff --git a/bower.json b/bower.json index 822afac07c..16a07f097a 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,5 @@ { "name": "prism", - "version": "0.0.1", "main": [ "prism.js", "themes/prism.css" From 52fd55ee6ac8cfd01bdecaa63a47554810c8b8fa Mon Sep 17 00:00:00 2001 From: Golmote Date: Fri, 12 Jun 2015 20:20:41 +0200 Subject: [PATCH 030/310] Relax markup grammar to allow non-ASCII chars in tag names and attributes. Fix #585 --- components/prism-markup.js | 10 +++++----- components/prism-markup.min.js | 2 +- examples/prism-markup.html | 7 ++++++- prism.js | 10 +++++----- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/components/prism-markup.js b/components/prism-markup.js index f4ab4f3651..febdc98171 100644 --- a/components/prism-markup.js +++ b/components/prism-markup.js @@ -4,13 +4,13 @@ Prism.languages.markup = { 'doctype': //, 'cdata': //i, 'tag': { - pattern: /<\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+))?\s*)*\/?>/i, + pattern: /<\/?[^\s>\/]+\s*(?:\s+[^\s>\/=]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+))?\s*)*\/?>/i, inside: { 'tag': { - pattern: /^<\/?[\w:-]+/i, + pattern: /^<\/?[^\s>\/]+/i, inside: { 'punctuation': /^<\/?/, - 'namespace': /^[\w-]+?:/ + 'namespace': /^[^\s>\/:]+:/ } }, 'attr-value': { @@ -21,9 +21,9 @@ Prism.languages.markup = { }, 'punctuation': /\/?>/, 'attr-name': { - pattern: /[\w:-]+/, + pattern: /[^\s>\/]+/, inside: { - 'namespace': /^[\w-]+?:/ + 'namespace': /^[^\s>\/:]+:/ } } diff --git a/components/prism-markup.min.js b/components/prism-markup.min.js index fbf30552b9..dece1fb7eb 100644 --- a/components/prism-markup.min.js +++ b/components/prism-markup.min.js @@ -1 +1 @@ -Prism.languages.markup={comment://,prolog:/<\?.+?\?>/,doctype://,cdata://i,tag:{pattern:/<\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+))?\s*)*\/?>/i,inside:{tag:{pattern:/^<\/?[\w:-]+/i,inside:{punctuation:/^<\/?/,namespace:/^[\w-]+?:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,inside:{punctuation:/=|>|"/}},punctuation:/\/?>/,"attr-name":{pattern:/[\w:-]+/,inside:{namespace:/^[\w-]+?:/}}}},entity:/&#?[\da-z]{1,8};/i},Prism.hooks.add("wrap",function(t){"entity"===t.type&&(t.attributes.title=t.content.replace(/&/,"&"))}); \ No newline at end of file +Prism.languages.markup={comment://,prolog:/<\?.+?\?>/,doctype://,cdata://i,tag:{pattern:/<\/?[^\s>\/]+\s*(?:\s+[^\s>\/=]+(?:=(?:("|')(\\?[\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(t){"entity"===t.type&&(t.attributes.title=t.content.replace(/&/,"&"))}); \ No newline at end of file diff --git a/examples/prism-markup.html b/examples/prism-markup.html index d3a333c76d..7709c025fd 100644 --- a/examples/prism-markup.html +++ b/examples/prism-markup.html @@ -72,4 +72,9 @@

Invalid HTML

Multi-line attribute values

<p title="foo
 bar
-baz">
\ No newline at end of file +baz">
+ +

XML tags with non-ASCII characters

+
<Läufer>foo</Läufer>
+<tag läufer="läufer">bar</tag>
+<läufer:tag>baz</läufer:tag>
\ No newline at end of file diff --git a/prism.js b/prism.js index e74f7cd746..ace59c0437 100644 --- a/prism.js +++ b/prism.js @@ -441,13 +441,13 @@ Prism.languages.markup = { 'doctype': //, 'cdata': //i, 'tag': { - pattern: /<\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+))?\s*)*\/?>/i, + pattern: /<\/?[^\s>\/]+\s*(?:\s+[^\s>\/=]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+))?\s*)*\/?>/i, inside: { 'tag': { - pattern: /^<\/?[\w:-]+/i, + pattern: /^<\/?[^\s>\/]+/i, inside: { 'punctuation': /^<\/?/, - 'namespace': /^[\w-]+?:/ + 'namespace': /^[^\s>\/:]+:/ } }, 'attr-value': { @@ -458,9 +458,9 @@ Prism.languages.markup = { }, 'punctuation': /\/?>/, 'attr-name': { - pattern: /[\w:-]+/, + pattern: /[^\s>\/]+/, inside: { - 'namespace': /^[\w-]+?:/ + 'namespace': /^[^\s>\/:]+:/ } } From 1707e4e3a54a506e915c3b6ba7ca165fff9a2c1c Mon Sep 17 00:00:00 2001 From: Golmote Date: Fri, 12 Jun 2015 20:33:36 +0200 Subject: [PATCH 031/310] Add .DS_Store in .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 692a6cb8bc..ea5cfc7e8e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ hide-*.js node_modules -.idea/ \ No newline at end of file +.idea/ +.DS_Store \ No newline at end of file From 75452ba11b3b1c6074b99f54b7a7a592e2adb0f1 Mon Sep 17 00:00:00 2001 From: Golmote Date: Fri, 12 Jun 2015 21:35:06 +0200 Subject: [PATCH 032/310] Markup: optimized tag's regexp so that it stops crashing on large unclosed tags --- components/prism-markup.js | 2 +- components/prism-markup.min.js | 2 +- prism.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/prism-markup.js b/components/prism-markup.js index febdc98171..eeec921065 100644 --- a/components/prism-markup.js +++ b/components/prism-markup.js @@ -4,7 +4,7 @@ Prism.languages.markup = { 'doctype': //, 'cdata': //i, 'tag': { - pattern: /<\/?[^\s>\/]+\s*(?:\s+[^\s>\/=]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+))?\s*)*\/?>/i, + pattern: /<\/?[^\s>\/]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i, inside: { 'tag': { pattern: /^<\/?[^\s>\/]+/i, diff --git a/components/prism-markup.min.js b/components/prism-markup.min.js index dece1fb7eb..458e87ec48 100644 --- a/components/prism-markup.min.js +++ b/components/prism-markup.min.js @@ -1 +1 @@ -Prism.languages.markup={comment://,prolog:/<\?.+?\?>/,doctype://,cdata://i,tag:{pattern:/<\/?[^\s>\/]+\s*(?:\s+[^\s>\/=]+(?:=(?:("|')(\\?[\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(t){"entity"===t.type&&(t.attributes.title=t.content.replace(/&/,"&"))}); \ No newline at end of file +Prism.languages.markup={comment://,prolog:/<\?.+?\?>/,doctype://,cdata://i,tag:{pattern:/<\/?[^\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(t){"entity"===t.type&&(t.attributes.title=t.content.replace(/&/,"&"))}); \ No newline at end of file diff --git a/prism.js b/prism.js index ace59c0437..cdf4543ed8 100644 --- a/prism.js +++ b/prism.js @@ -441,7 +441,7 @@ Prism.languages.markup = { 'doctype': //, 'cdata': //i, 'tag': { - pattern: /<\/?[^\s>\/]+\s*(?:\s+[^\s>\/=]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+))?\s*)*\/?>/i, + pattern: /<\/?[^\s>\/]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i, inside: { 'tag': { pattern: /^<\/?[^\s>\/]+/i, From e2580134029cdab3045e761f02eb1124503d9288 Mon Sep 17 00:00:00 2001 From: a-rey Date: Fri, 12 Jun 2015 15:38:43 -0400 Subject: [PATCH 033/310] adding vhdl language --- components.js | 4 ++++ components/prism-vhdl.js | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 components/prism-vhdl.js diff --git a/components.js b/components.js index 7be18694e5..52988bf83c 100644 --- a/components.js +++ b/components.js @@ -322,6 +322,10 @@ var components = { "require": "javascript", "owner": "vkbansal" }, + "vhdl": { + "title": "VHDL", + "owner": "a-rey" + }, "wiki": { "title": "Wiki markup", "require": "markup", diff --git a/components/prism-vhdl.js b/components/prism-vhdl.js new file mode 100644 index 0000000000..41bff16806 --- /dev/null +++ b/components/prism-vhdl.js @@ -0,0 +1,24 @@ +Prism.languages.vhdl = { + 'comment': /(--[^\r\n]+)/, + // support for all logic vectors + 'vhdl-vectors': { + 'pattern': /(\b[oOxXbB]"[\dA-Fa-f_]+"|"[UuXx01ZzWwLlHh-]+")/, + 'alias': 'number' + }, + 'string': /(")(\\\n|\\?.)*?"/, + 'constant': /\b(use|library)\b/i, + // support for predefined attributes included + 'keyword': /\b(access|after|alias|all|architecture|array|assert|attribute|begin|block|body|buffer|bus|case|component|configuration|constant|disconnect|downto|else|elsif|end|entity|exit|file|for|function|generate|generic|group|guarded|if|impure|in|inertial|inout|is|label|library|linkage|literal|loop|map|new|next|null|of|on|open|others|out|package|port|postponed|procedure|process|pure|range|record|register|reject|report|return|select|severity|signal|shared|subtype|then|to|transport|type|unaffected|units|until|use|variable|wait|when|while|with|'base|'left|'right|'high|'low|'ascending|'image|'value|'pos|'val|'succ|'pred|'leftof|'rightof|'left|'left|'right|'right|'high|'high|'low|'low|'range|'range|'reverse_range|'reverse_range|'length|'length|'ascending|'ascending|'delayed|'stable|'stable|'quiet|'quiet|'transaction|'event|'active|'last_event|'last_active|'last_value|'driving|'driving_value|'simple_name|'instance_name|'path_name)\b/i, + 'boolean': /\b(true|false)\b/i, + 'function': { + // support for operator overloading included + pattern: /([a-z0-9_]+|"\S+")\(/i, + inside: { + punctuation: /\(/ + } + }, + // decimal, based, physical, and exponential numbers supported + 'number': /('[UuXx01ZzWwLlHh-]'|\b\d+([_.]+)?(#[\dA-Fa-f_.]+#)?([eE][-+]?\d+)?)/, + 'operator': /[-+]{1}|<=?|>=?|=|:=|&|\*|\/|\b(abs|not|mod|rem|sll|srl|sla|sra|rol|ror|and|or|nand|xnor|xor|nor)\b/i, + 'punctuation': /[{}[\];(),.:]/ +}; From fe608582d4257fca273bc6bd3cb0acce7ad7622f Mon Sep 17 00:00:00 2001 From: Golmote Date: Fri, 12 Jun 2015 21:43:31 +0200 Subject: [PATCH 034/310] Improve test drive page usability. Fix #591 --- test.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test.html b/test.html index 1ffc38a422..63d46e12f7 100644 --- a/test.html +++ b/test.html @@ -72,12 +72,12 @@

Test drive

+

Result:

+
+

Language:

- -

Result:

-
From b081804639aed4f2e63ccd7a4130ac3f762ba1bd Mon Sep 17 00:00:00 2001 From: Golmote Date: Sat, 13 Jun 2015 11:03:08 +0200 Subject: [PATCH 035/310] Basic Sass support (fix #199) --- components.js | 4 +++ components/prism-sass.js | 66 ++++++++++++++++++++++++++++++++++++ components/prism-sass.min.js | 1 + examples/prism-sass.html | 50 +++++++++++++++++++++++++++ 4 files changed, 121 insertions(+) create mode 100644 components/prism-sass.js create mode 100644 components/prism-sass.min.js create mode 100644 examples/prism-sass.html diff --git a/components.js b/components.js index 7be18694e5..7523fae381 100644 --- a/components.js +++ b/components.js @@ -276,6 +276,10 @@ var components = { "title": "SAS", "owner": "Golmote" }, + "sass": { + "title": "Sass (Sass)", + "owner": "Golmote" + }, "scss": { "title": "Sass (Scss)", "require": "css", diff --git a/components/prism-sass.js b/components/prism-sass.js new file mode 100644 index 0000000000..9115684fa3 --- /dev/null +++ b/components/prism-sass.js @@ -0,0 +1,66 @@ +(function(Prism) { + Prism.languages.sass = Prism.languages.extend('css', { + // Sass comments don't need to be closed, only indented + 'comment': /^([ \t]*)\/[\/*].*(?:(?:\r?\n|\r)\1[ \t]+.+)*/m + }); + + Prism.languages.insertBefore('sass', 'atrule', { + // We want to consume the whole line + 'atrule-line': { + // Includes support for = and + shortcuts + pattern: /^(?:[ \t]*)[@+=].+/m, + inside: { + 'atrule': /^(?:[ \t]*)(?:@[\w-]+|[+=])/m + } + } + }); + delete Prism.languages.sass.atrule; + + + var variable = /((\$[-_\w]+)|(#\{\$[-_\w]+\}))/i; + var operator = /[-+]{1,2}|==?|!=|\|?\||\?|\*|\/|%/; + + Prism.languages.insertBefore('sass', 'property', { + // We want to consume the whole line + 'variable-line': { + pattern: /(^|(?:\r?\n|\r))[ \t]*\$.+/, + lookbehind: true, + inside: { + 'punctuation': /:/, + 'variable': variable, + 'operator': operator + } + }, + // We want to consume the whole line + 'property-line': { + pattern: /(^|(?:\r?\n|\r))[ \t]*(?:[^:\s]+[ ]*:.*|:[^:\s]+.*)/i, + lookbehind: true, + inside: { + 'property': [ + /[^:\s]+(?=\s*:)/, + { + pattern: /(:)[^:\s]+/, + lookbehind: true + } + ], + 'punctuation': /:/, + 'variable': variable, + 'operator': operator, + 'important': Prism.languages.sass.important + } + } + }); + delete Prism.languages.sass.property; + delete Prism.languages.sass.important; + + // Now that whole lines for other patterns are consumed, + // what's left should be selectors + delete Prism.languages.sass.selector; + Prism.languages.insertBefore('sass', 'punctuation', { + 'selector': { + pattern: /([ \t]*).+(?:,(?:\r?\n|\r)\1[ \t]+.+)*/, + lookbehind: true + } + }); + +}(Prism)); \ No newline at end of file diff --git a/components/prism-sass.min.js b/components/prism-sass.min.js new file mode 100644 index 0000000000..8b4ea94203 --- /dev/null +++ b/components/prism-sass.min.js @@ -0,0 +1 @@ +!function(e){e.languages.sass=e.languages.extend("css",{comment:/^([ \t]*)\/[\/*].*(?:(?:\r?\n|\r)\1[ \t]+.+)*/m}),e.languages.insertBefore("sass","atrule",{"atrule-line":{pattern:/^(?:[ \t]*)[@+=].+/m,inside:{atrule:/^(?:[ \t]*)(?:@[\w-]+|[+=])/m}}}),delete e.languages.sass.atrule;var a=/((\$[-_\w]+)|(#\{\$[-_\w]+\}))/i,s=/[-+]{1,2}|==?|!=|\|?\||\?|\*|\/|%/;e.languages.insertBefore("sass","property",{"variable-line":{pattern:/(^|(?:\r?\n|\r))[ \t]*\$.+/,lookbehind:!0,inside:{punctuation:/:/,variable:a,operator:s}},"property-line":{pattern:/(^|(?:\r?\n|\r))[ \t]*(?:[^:\s]+[ ]*:.*|:[^:\s]+.*)/i,lookbehind:!0,inside:{property:[/[^:\s]+(?=\s*:)/,{pattern:/(:)[^:\s]+/,lookbehind:!0}],punctuation:/:/,variable:a,operator:s,important:e.languages.sass.important}}}),delete e.languages.sass.property,delete e.languages.sass.important,delete e.languages.sass.selector,e.languages.insertBefore("sass","punctuation",{selector:{pattern:/([ \t]*).+(?:,(?:\r?\n|\r)\1[ \t]+.+)*/,lookbehind:!0}})}(Prism); \ No newline at end of file diff --git a/examples/prism-sass.html b/examples/prism-sass.html new file mode 100644 index 0000000000..68a7763e5c --- /dev/null +++ b/examples/prism-sass.html @@ -0,0 +1,50 @@ +

Sass (Sass)

+

To use this language, use the class "language-sass".

+ +

Comments

+
/* This comment will appear in the CSS output.
+  This is nested beneath the comment,
+  so it's part of it
+
+// This comment will not appear in the CSS output.
+  This is nested beneath the comment as well,
+  so it also won't appear
+ +

At-rules and shortcuts

+
@mixin large-text
+  color: #ff0000
+
+@media (min-width: 600px)
+  h1
+    @include large-text
+
+=large-text
+  color: #ff0000
+
+h1
+  +large-text
+ +

Variables

+
$width: 5em
+#main
+  width: $width
+
+ +

Known failures

+

There are certain edge cases where Prism will fail. + There are always such cases in every regex-based syntax highlighter. + However, Prism dares to be open and honest about them. + If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug. +

+ +

Deprecated Sass syntax is not supported

+
.page
+  color = 5px + 9px
+
+!width = 13px
+.icon
+  width = !width
+ +

Selectors with pseudo classes are highlighted as property/value pairs

+
a:hover
+  text-decoration: underline
\ No newline at end of file From be5e037b171be70be362574ebfffe4f0499bb4c5 Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Sat, 13 Jun 2015 15:12:21 +0200 Subject: [PATCH 036/310] Added support for test case comments --- tests/helper/test-case.js | 59 ++++++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 10 deletions(-) diff --git a/tests/helper/test-case.js b/tests/helper/test-case.js index 6afce39ae3..9bec510323 100644 --- a/tests/helper/test-case.js +++ b/tests/helper/test-case.js @@ -1,9 +1,38 @@ "use strict"; var fs = require("fs"); -var expect = require("chai").expect; +var assert = require("chai").assert; var PrismLoader = require("./prism-loader"); +/** + * Handles parsing of a test case file. + * + * + * A test case file consists of at least two parts, separated by a line of dashes. + * This separation line must start at the beginning of the line and consist of at least three dashes. + * + * The test case file can either consist of two parts: + * + * {source code} + * ---- + * {expected token stream} + * + * + * or of three parts: + * + * {source code} + * ---- + * {expected token stream} + * ---- + * {text comment explaining the test case} + * + * If the file contains more than three parts, the remaining parts are just ignored. + * If the file however does not contain at least two parts (so no expected token stream), + * the test case will later be marked as failed. + * + * + * @type {{runTestCase: Function, transformCompiledTokenStream: Function, parseTestCaseFile: Function}} + */ module.exports = { /** @@ -23,7 +52,7 @@ module.exports = { var compiledTokenStream = Prism.tokenize(testCase.testSource, Prism.languages[language]); var simplifiedTokenStream = this.transformCompiledTokenStream(compiledTokenStream); - expect(simplifiedTokenStream).to.eql(testCase.expectedTokenStream); + assert.deepEqual(simplifiedTokenStream, testCase.expectedTokenStream, testCase.comment); }, @@ -53,19 +82,29 @@ module.exports = { * * @private * @param {string} filePath - * @returns {{testSource: string, expectedTokenStream: *}|null} + * @returns {{testSource: string, expectedTokenStream: Array.>, comment:string?}|null} */ parseTestCaseFile: function (filePath) { var testCaseSource = fs.readFileSync(filePath, "utf8"); - var testCase = testCaseSource.split(/^----*\w*$/m); + var testCaseParts = testCaseSource.split(/^----*\w*$/m); - if (2 === testCase.length) { - return { - testSource: testCase[0].trim(), - expectedTokenStream: JSON.parse(testCase[1]) - }; + // No expected token stream found + if (2 > testCaseParts.length) { + return null; } - return null; + var testCase = { + testSource: testCaseParts[0].trim(), + expectedTokenStream: JSON.parse(testCaseParts[1]), + comment: null + }; + + // if there are three parts, the third one is the comment + // explaining the test case + if (testCaseParts[2]) { + testCase.comment = testCaseParts[2].trim(); + } + + return testCase; } }; From 829f8a860dbd6426213c3e0c3cd2afb22d3591d1 Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Sat, 13 Jun 2015 15:24:53 +0200 Subject: [PATCH 037/310] New file extension for test case files: .test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## All test case files are now required to have the ".test" extension. This prevents issues with syntax highlighting in common IDEs and also prevents the test system to choke on non-testcase files in these directories (like `.DS_Store` or `Thumbs.db`). ## Hide the ".test" extension in the description of the test cases The message for a testcase `blabla.test` will now just read: > 1) Testing language 'css' – should pass test case 'blabla': --- tests/helper/test-discovery.js | 4 +++- tests/run.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/helper/test-discovery.js b/tests/helper/test-discovery.js index 9f9ea2dca4..7cbaef8193 100644 --- a/tests/helper/test-discovery.js +++ b/tests/helper/test-discovery.js @@ -52,7 +52,9 @@ module.exports = { getAllFiles: function (src) { return fs.readdirSync(src).filter( function (fileName) { - return fs.statSync(path.join(src, fileName)).isFile(); + // only find files that have the ".test" extension + return ".test" === path.extname(fileName) && + fs.statSync(path.join(src, fileName)).isFile(); } ).map( function (fileName) { diff --git a/tests/run.js b/tests/run.js index 32dab49fb5..0f0475fa6e 100644 --- a/tests/run.js +++ b/tests/run.js @@ -18,7 +18,7 @@ for (var language in testSuite) describe("Testing language '" + language + "'", function() { testFiles.forEach( function (filePath) { - var fileName = path.basename(filePath); + var fileName = path.basename(filePath, path.extname(filePath)); it("– should pass test case '" + fileName + "'", function () { From dec517f38299413bd66f82cb8f64636e46737433 Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Sat, 13 Jun 2015 15:25:53 +0200 Subject: [PATCH 038/310] Refreshed example test case for new file extension and comment support. --- tests/languages/javascript/{test.js => testcase1.test} | 4 ++++ 1 file changed, 4 insertions(+) rename tests/languages/javascript/{test.js => testcase1.test} (60%) diff --git a/tests/languages/javascript/test.js b/tests/languages/javascript/testcase1.test similarity index 60% rename from tests/languages/javascript/test.js rename to tests/languages/javascript/testcase1.test index df16f2e405..e6cd4a59aa 100644 --- a/tests/languages/javascript/test.js +++ b/tests/languages/javascript/testcase1.test @@ -8,3 +8,7 @@ var a = 5; ["number", "5"], ["punctuation", ";"] ] + +---------------------------------------------------- + +This is a comment explaining this test case. \ No newline at end of file From 09898e8e77a38f812e080c3f1ffbdd28182bd14f Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Sat, 13 Jun 2015 16:37:07 +0200 Subject: [PATCH 039/310] Support language inclusion tests By using composed language names "language+language2+language3" you can test language inclusion or do integration tests. --- tests/helper/prism-loader.js | 36 +++++++++++++++++++++++++----------- tests/helper/test-case.js | 20 ++++++++++++++++---- 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/tests/helper/prism-loader.js b/tests/helper/prism-loader.js index 1f1426ac92..df34951be0 100644 --- a/tests/helper/prism-loader.js +++ b/tests/helper/prism-loader.js @@ -11,12 +11,21 @@ module.exports = { /** * Creates a new Prism instance with the given language loaded * - * @param {string} language + * @param {string|string[]} languages * @returns {Prism} */ - createInstance: function (language) { - var Prism = this.createEmptyPrism(); - return this.loadLanguage(language, Prism); + createInstance: function (languages) { + var context = { + loadedLanguages: [], + Prism: this.createEmptyPrism() + }; + languages = Array.isArray(languages) ? languages : [languages]; + + for (var i = 0, l = languages.length; i < l; i++) { + context = this.loadLanguage(languages[i], context); + } + + return context.Prism; }, @@ -26,26 +35,31 @@ module.exports = { * * @private * @param {string} language - * @param {Prism} Prism - * @returns {Prism} + * @param {{loadedLanguages: string[], Prism: Prism}} context */ - loadLanguage: function (language, Prism) { + loadLanguage: function (language, context) { if (!languagesCatalog[language]) { throw new Error("Language '" + language + "' not found."); } + // the given language was already loaded + if (-1 < context.loadedLanguages.indexOf(language)) { + return context; + } + // if the language has a dependency -> load it first if (languagesCatalog[language].require) { - Prism = this.loadLanguage(languagesCatalog[language].require, Prism); + context = this.loadLanguage(languagesCatalog[language].require, context); } // load the language itself var languageSource = this.loadFileSource(language); - var context = this.runFileWithContext(languageSource, {Prism: Prism}); + context.Prism = this.runFileWithContext(languageSource, {Prism: context.Prism}).Prism; + context.loadedLanguages.push(language); - return context.Prism; + return context; }, @@ -88,7 +102,7 @@ module.exports = { * * @private * @param {string} fileSource - * @param {*}context + * @param {*} [context] * * @returns {*} */ diff --git a/tests/helper/test-case.js b/tests/helper/test-case.js index 9bec510323..095cba0eda 100644 --- a/tests/helper/test-case.js +++ b/tests/helper/test-case.js @@ -38,18 +38,30 @@ module.exports = { /** * Runs the given test case file and asserts the result * - * @param {string} language + * The passed language identifier can either be a language like "css" or a composed language + * identifier like "css+markup". Composed identifiers can be used for testing language inclusion. + * + * When testing language inclusion, the first given language is the main language which will be passed + * to Prism for highlighting ("css+markup" will result in a call to Prism to highlight with the "css" grammar). + * But it will be ensured, that the additional passed languages will be loaded too. + * + * The languages will be loaded in the order they were provided. + * + * @param {string} languageIdentifier * @param {string} filePath */ - runTestCase: function (language, filePath) { + runTestCase: function (languageIdentifier, filePath) { var testCase = this.parseTestCaseFile(filePath); + var languages = languageIdentifier.split("+"); if (null === testCase) { throw new Error("Test case file has invalid format, please read the docs."); } - var Prism = PrismLoader.createInstance(language); - var compiledTokenStream = Prism.tokenize(testCase.testSource, Prism.languages[language]); + var Prism = PrismLoader.createInstance(languages); + // the first language is the main language to highlight + var mainLanguageGrammar = Prism.languages[languages[0]]; + var compiledTokenStream = Prism.tokenize(testCase.testSource, mainLanguageGrammar); var simplifiedTokenStream = this.transformCompiledTokenStream(compiledTokenStream); assert.deepEqual(simplifiedTokenStream, testCase.expectedTokenStream, testCase.comment); From aec5fcc4a2f8d9e60fe9c9172c5b26a495c9893b Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Sat, 13 Jun 2015 16:41:31 +0200 Subject: [PATCH 040/310] Added return type definition --- tests/helper/prism-loader.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/helper/prism-loader.js b/tests/helper/prism-loader.js index df34951be0..87739fd2e9 100644 --- a/tests/helper/prism-loader.js +++ b/tests/helper/prism-loader.js @@ -36,6 +36,7 @@ module.exports = { * @private * @param {string} language * @param {{loadedLanguages: string[], Prism: Prism}} context + * @returns {{loadedLanguages: string[], Prism: Prism}} */ loadLanguage: function (language, context) { if (!languagesCatalog[language]) From 9fb1e8b74528901571d480641762cf4902bf6e4d Mon Sep 17 00:00:00 2001 From: a-rey Date: Sat, 13 Jun 2015 14:58:11 -0400 Subject: [PATCH 041/310] requested changes/optimizations --- components/prism-vhdl.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/prism-vhdl.js b/components/prism-vhdl.js index 41bff16806..71bd533381 100644 --- a/components/prism-vhdl.js +++ b/components/prism-vhdl.js @@ -1,14 +1,14 @@ Prism.languages.vhdl = { - 'comment': /(--[^\r\n]+)/, + 'comment': /--.+/, // support for all logic vectors 'vhdl-vectors': { - 'pattern': /(\b[oOxXbB]"[\dA-Fa-f_]+"|"[UuXx01ZzWwLlHh-]+")/, + 'pattern': /(\b[oxb]"[\da-f_]+"|"[01uxzwlh-]+")/i, 'alias': 'number' }, - 'string': /(")(\\\n|\\?.)*?"/, + 'string': /"(\\\n|\\?.)*?"/, 'constant': /\b(use|library)\b/i, // support for predefined attributes included - 'keyword': /\b(access|after|alias|all|architecture|array|assert|attribute|begin|block|body|buffer|bus|case|component|configuration|constant|disconnect|downto|else|elsif|end|entity|exit|file|for|function|generate|generic|group|guarded|if|impure|in|inertial|inout|is|label|library|linkage|literal|loop|map|new|next|null|of|on|open|others|out|package|port|postponed|procedure|process|pure|range|record|register|reject|report|return|select|severity|signal|shared|subtype|then|to|transport|type|unaffected|units|until|use|variable|wait|when|while|with|'base|'left|'right|'high|'low|'ascending|'image|'value|'pos|'val|'succ|'pred|'leftof|'rightof|'left|'left|'right|'right|'high|'high|'low|'low|'range|'range|'reverse_range|'reverse_range|'length|'length|'ascending|'ascending|'delayed|'stable|'stable|'quiet|'quiet|'transaction|'event|'active|'last_event|'last_active|'last_value|'driving|'driving_value|'simple_name|'instance_name|'path_name)\b/i, + 'keyword': /\b('active|'ascending|'base|'delayed|'driving|'driving_value|'event|'high|'image|'instance_name|'last_active|'last_event|'last_value|'left|'leftof|'length|'low|'path_name|'pos|'pred|'quiet|'range|'reverse_range|'right|'rightof|'simple_name|'stable|'succ|'transaction|'val|'value|access|after|alias|all|architecture|array|assert|attribute|begin|block|body|buffer|bus|case|component|configuration|constant|disconnect|downto|else|elsif|end|entity|exit|file|for|function|generate|generic|group|guarded|if|impure|in|inertial|inout|is|label|library|linkage|literal|loop|map|new|next|null|of|on|open|others|out|package|port|postponed|procedure|process|pure|range|record|register|reject|report|return|select|severity|shared|signal|subtype|then|to|transport|type|unaffected|units|until|use|variable|wait|when|while|with)\b/i, 'boolean': /\b(true|false)\b/i, 'function': { // support for operator overloading included @@ -18,7 +18,7 @@ Prism.languages.vhdl = { } }, // decimal, based, physical, and exponential numbers supported - 'number': /('[UuXx01ZzWwLlHh-]'|\b\d+([_.]+)?(#[\dA-Fa-f_.]+#)?([eE][-+]?\d+)?)/, - 'operator': /[-+]{1}|<=?|>=?|=|:=|&|\*|\/|\b(abs|not|mod|rem|sll|srl|sla|sra|rol|ror|and|or|nand|xnor|xor|nor)\b/i, + 'number': /'[01uxzwlh-]'|\b\d+[_.]*(#[\da-f_.]+#)?([e][-+]?\d+)?/i, + 'operator': /<=?|>=?|:=|[-+*/&=]|\b(abs|not|mod|rem|sll|srl|sla|sra|rol|ror|and|or|nand|xnor|xor|nor)\b/i, 'punctuation': /[{}[\];(),.:]/ }; From 5d99957accc8106c2a2f5d16d5e8fb340a6d776f Mon Sep 17 00:00:00 2001 From: Logan Franken Date: Sun, 14 Jun 2015 00:48:06 -0700 Subject: [PATCH 042/310] Added support for 'y' and 'u' ES6 JavaScript regex flags --- components/prism-javascript.js | 2 +- components/prism-javascript.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/prism-javascript.js b/components/prism-javascript.js index 754ff0e489..06ae9c9f36 100644 --- a/components/prism-javascript.js +++ b/components/prism-javascript.js @@ -6,7 +6,7 @@ Prism.languages.javascript = Prism.languages.extend('clike', { Prism.languages.insertBefore('javascript', 'keyword', { 'regex': { - pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/, + pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/, lookbehind: true } }); diff --git a/components/prism-javascript.min.js b/components/prism-javascript.min.js index a8669d76bd..9372774688 100644 --- a/components/prism-javascript.min.js +++ b/components/prism-javascript.min.js @@ -1 +1 @@ -Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|get|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|-?Infinity)\b/,"function":/(?!\d)[a-z0-9_$]+(?=\()/i}),Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0}}),Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/[\w\W]*?<\/script>/i,inside:{tag:{pattern:/|<\/script>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript},alias:"language-javascript"}}); \ No newline at end of file +Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|get|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|-?Infinity)\b/,"function":/(?!\d)[a-z0-9_$]+(?=\()/i}),Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0}}),Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/[\w\W]*?<\/script>/i,inside:{tag:{pattern:/|<\/script>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript},alias:"language-javascript"}}); \ No newline at end of file From ca68b876b5f77b9dd440ebce41061e8d1e312de2 Mon Sep 17 00:00:00 2001 From: Logan Franken Date: Sun, 14 Jun 2015 00:53:20 -0700 Subject: [PATCH 043/310] Added support for missing ES6 keywords in JavaScript --- components/prism-javascript.js | 2 +- components/prism-javascript.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/prism-javascript.js b/components/prism-javascript.js index 06ae9c9f36..863f3af82a 100644 --- a/components/prism-javascript.js +++ b/components/prism-javascript.js @@ -1,5 +1,5 @@ Prism.languages.javascript = Prism.languages.extend('clike', { - 'keyword': /\b(break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|get|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/, + 'keyword': /\b(as|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/, 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|-?Infinity)\b/, 'function': /(?!\d)[a-z0-9_$]+(?=\()/i }); diff --git a/components/prism-javascript.min.js b/components/prism-javascript.min.js index 9372774688..655d780795 100644 --- a/components/prism-javascript.min.js +++ b/components/prism-javascript.min.js @@ -1 +1 @@ -Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|get|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|-?Infinity)\b/,"function":/(?!\d)[a-z0-9_$]+(?=\()/i}),Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0}}),Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/[\w\W]*?<\/script>/i,inside:{tag:{pattern:/|<\/script>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript},alias:"language-javascript"}}); \ No newline at end of file +Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(as|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|-?Infinity)\b/,"function":/(?!\d)[a-z0-9_$]+(?=\()/i}),Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0}}),Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/[\w\W]*?<\/script>/i,inside:{tag:{pattern:/|<\/script>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript},alias:"language-javascript"}}); \ No newline at end of file From 1453aac5a1e598fa8d2501ff2df6b5d3412a8bf3 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sun, 14 Jun 2015 17:53:53 +0200 Subject: [PATCH 044/310] Run gulp task --- prism.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prism.js b/prism.js index cdf4543ed8..0a62921272 100644 --- a/prism.js +++ b/prism.js @@ -576,14 +576,14 @@ Prism.languages.clike = { ********************************************** */ Prism.languages.javascript = Prism.languages.extend('clike', { - 'keyword': /\b(break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|get|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/, + 'keyword': /\b(as|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/, 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|-?Infinity)\b/, 'function': /(?!\d)[a-z0-9_$]+(?=\()/i }); Prism.languages.insertBefore('javascript', 'keyword', { 'regex': { - pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/, + pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/, lookbehind: true } }); From 04f72b1495278dccea1d6d994fbc885d5f841692 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sun, 14 Jun 2015 18:26:16 +0200 Subject: [PATCH 045/310] ES6: Template strings + interpolation --- components/prism-javascript.js | 19 +++++++++++++++++++ components/prism-javascript.min.js | 2 +- examples/prism-javascript.html | 27 ++++++++++++++++++++++++++- prism.js | 19 +++++++++++++++++++ 4 files changed, 65 insertions(+), 2 deletions(-) diff --git a/components/prism-javascript.js b/components/prism-javascript.js index 863f3af82a..f4139f2a9b 100644 --- a/components/prism-javascript.js +++ b/components/prism-javascript.js @@ -11,6 +11,25 @@ Prism.languages.insertBefore('javascript', 'keyword', { } }); +Prism.languages.insertBefore('javascript', 'string', { + 'template-string': { + pattern: /`(?:\\`|\\?[^`])*`/, + inside: { + 'interpolation': { + pattern: /\$\{[^}]+\}/, + inside: { + 'interpolation-punctuation': { + pattern: /^\$\{|\}$/, + alias: 'punctuation' + }, + rest: Prism.languages.javascript + } + }, + 'string': /[\s\S]+/ + } + } +}); + if (Prism.languages.markup) { Prism.languages.insertBefore('markup', 'tag', { 'script': { diff --git a/components/prism-javascript.min.js b/components/prism-javascript.min.js index 655d780795..da70a1b4a7 100644 --- a/components/prism-javascript.min.js +++ b/components/prism-javascript.min.js @@ -1 +1 @@ -Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(as|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|-?Infinity)\b/,"function":/(?!\d)[a-z0-9_$]+(?=\()/i}),Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0}}),Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/[\w\W]*?<\/script>/i,inside:{tag:{pattern:/|<\/script>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript},alias:"language-javascript"}}); \ No newline at end of file +Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(as|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|-?Infinity)\b/,"function":/(?!\d)[a-z0-9_$]+(?=\()/i}),Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0}}),Prism.languages.insertBefore("javascript","string",{"template-string":{pattern:/`(?:\\`|\\?[^`])*`/,inside:{interpolation:{pattern:/\$\{[^}]+\}/,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}}}),Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/[\w\W]*?<\/script>/i,inside:{tag:{pattern:/|<\/script>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript},alias:"language-javascript"}}); \ No newline at end of file diff --git a/examples/prism-javascript.html b/examples/prism-javascript.html index 213969fc2c..5bd11e3857 100644 --- a/examples/prism-javascript.html +++ b/examples/prism-javascript.html @@ -50,6 +50,24 @@

A division operator on the same line as a regex

var foo = 1/2, bar = /a/g;
 var foo = /a/, bar = 3/4;
+

ES6 features

+
// Regex "y" and "u" flags
+/[a-zA-Z]+/gimyu
+
+// for..of loops
+for(let x of y) { }
+
+// Modules: import
+import { foo as bar } from "file.js"
+
+// Template strings
+`Only on ${y} one line`
+`This template string ${x} is on
+
+multiple lines.`
+`40 + 2 = ${ 40 + 2 }`
+`The squares of the first 3 natural integers are ${[for (x of [1,2,3]) x*x].join(', ')}`
+

Known failures

There are certain edge cases where Prism will fail. There are always such cases in every regex-based syntax highlighter. @@ -61,4 +79,11 @@

Comment-like substrings

"foo /* bar */ baz"; "foo // bar";

Two quotes of the same type (i.e. both single or both double) inside a regex

-
foo = /"foo"/;
\ No newline at end of file +
foo = /"foo"/;
+ +

String interpolation containing a closing brace

+
`${ {foo:'bar'}.foo }`
+`${ '}' }`
+ +

String interpolation containing an unescaped back-tick

+
`${ '`' }`
\ No newline at end of file diff --git a/prism.js b/prism.js index 0a62921272..8e27b9fe6f 100644 --- a/prism.js +++ b/prism.js @@ -588,6 +588,25 @@ Prism.languages.insertBefore('javascript', 'keyword', { } }); +Prism.languages.insertBefore('javascript', 'string', { + 'template-string': { + pattern: /`(?:\\`|\\?[^`])*`/, + inside: { + 'interpolation': { + pattern: /\$\{[^}]+\}/, + inside: { + 'interpolation-punctuation': { + pattern: /^\$\{|\}$/, + alias: 'punctuation' + }, + rest: Prism.languages.javascript + } + }, + 'string': /[\s\S]+/ + } + } +}); + if (Prism.languages.markup) { Prism.languages.insertBefore('markup', 'tag', { 'script': { From a8aa05886c38712484a808c9a7fedaa79ade558a Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Sun, 14 Jun 2015 18:18:37 +0200 Subject: [PATCH 046/310] Implemented support for octal and binary numbers in javascript They are supported from ES6+ --- components/prism-javascript.js | 2 +- components/prism-javascript.min.js | 2 +- prism.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/prism-javascript.js b/components/prism-javascript.js index f4139f2a9b..c614346ba2 100644 --- a/components/prism-javascript.js +++ b/components/prism-javascript.js @@ -1,6 +1,6 @@ Prism.languages.javascript = Prism.languages.extend('clike', { 'keyword': /\b(as|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/, - 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|-?Infinity)\b/, + 'number': /\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/, 'function': /(?!\d)[a-z0-9_$]+(?=\()/i }); diff --git a/components/prism-javascript.min.js b/components/prism-javascript.min.js index da70a1b4a7..095cfb1cd4 100644 --- a/components/prism-javascript.min.js +++ b/components/prism-javascript.min.js @@ -1 +1 @@ -Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(as|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|-?Infinity)\b/,"function":/(?!\d)[a-z0-9_$]+(?=\()/i}),Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0}}),Prism.languages.insertBefore("javascript","string",{"template-string":{pattern:/`(?:\\`|\\?[^`])*`/,inside:{interpolation:{pattern:/\$\{[^}]+\}/,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}}}),Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/[\w\W]*?<\/script>/i,inside:{tag:{pattern:/|<\/script>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript},alias:"language-javascript"}}); \ No newline at end of file +Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(as|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,"function":/(?!\d)[a-z0-9_$]+(?=\()/i}),Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0}}),Prism.languages.insertBefore("javascript","string",{"template-string":{pattern:/`(?:\\`|\\?[^`])*`/,inside:{interpolation:{pattern:/\$\{[^}]+\}/,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}}}),Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/[\w\W]*?<\/script>/i,inside:{tag:{pattern:/|<\/script>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript},alias:"language-javascript"}}); \ No newline at end of file diff --git a/prism.js b/prism.js index 8e27b9fe6f..b0dd854b7a 100644 --- a/prism.js +++ b/prism.js @@ -577,7 +577,7 @@ Prism.languages.clike = { Prism.languages.javascript = Prism.languages.extend('clike', { 'keyword': /\b(as|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/, - 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|-?Infinity)\b/, + 'number': /\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/, 'function': /(?!\d)[a-z0-9_$]+(?=\()/i }); From 43cc56f51046439854a1a95e8467be37ebefbac0 Mon Sep 17 00:00:00 2001 From: a-rey Date: Sun, 14 Jun 2015 16:32:47 -0400 Subject: [PATCH 047/310] getting rid of [] and () --- components/prism-vhdl.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/prism-vhdl.js b/components/prism-vhdl.js index 71bd533381..bed5ffece6 100644 --- a/components/prism-vhdl.js +++ b/components/prism-vhdl.js @@ -2,7 +2,7 @@ Prism.languages.vhdl = { 'comment': /--.+/, // support for all logic vectors 'vhdl-vectors': { - 'pattern': /(\b[oxb]"[\da-f_]+"|"[01uxzwlh-]+")/i, + 'pattern': /\b[oxb]"[\da-f_]+"|"[01uxzwlh-]+"/i, 'alias': 'number' }, 'string': /"(\\\n|\\?.)*?"/, @@ -18,7 +18,7 @@ Prism.languages.vhdl = { } }, // decimal, based, physical, and exponential numbers supported - 'number': /'[01uxzwlh-]'|\b\d+[_.]*(#[\da-f_.]+#)?([e][-+]?\d+)?/i, + 'number': /'[01uxzwlh-]'|\b\d+[_.]*(#[\da-f_.]+#)?(e[-+]?\d+)?/i, 'operator': /<=?|>=?|:=|[-+*/&=]|\b(abs|not|mod|rem|sll|srl|sla|sra|rol|ror|and|or|nand|xnor|xor|nor)\b/i, 'punctuation': /[{}[\];(),.:]/ }; From 3d3989151c8b10ddaacba2c033ee97a0b34b649a Mon Sep 17 00:00:00 2001 From: a-rey Date: Thu, 18 Jun 2015 11:13:15 -0400 Subject: [PATCH 048/310] adding example page and minified file --- components/prism-vhdl.min.js | 1 + examples/prism-vhdl.html | 95 ++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 components/prism-vhdl.min.js create mode 100644 examples/prism-vhdl.html diff --git a/components/prism-vhdl.min.js b/components/prism-vhdl.min.js new file mode 100644 index 0000000000..3680f052e9 --- /dev/null +++ b/components/prism-vhdl.min.js @@ -0,0 +1 @@ +Prism.languages.vhdl={comment:/--.+/,"vhdl-vectors":{pattern:/\b[oxb]"[\da-f_]+"|"[01uxzwlh-]+"/i,alias:"number"},string:/"(\\\n|\\?.)*?"/,constant:/\b(use|library)\b/i,keyword:/\b('active|'ascending|'base|'delayed|'driving|'driving_value|'event|'high|'image|'instance_name|'last_active|'last_event|'last_value|'left|'leftof|'length|'low|'path_name|'pos|'pred|'quiet|'range|'reverse_range|'right|'rightof|'simple_name|'stable|'succ|'transaction|'val|'value|access|after|alias|all|architecture|array|assert|attribute|begin|block|body|buffer|bus|case|component|configuration|constant|disconnect|downto|else|elsif|end|entity|exit|file|for|function|generate|generic|group|guarded|if|impure|in|inertial|inout|is|label|library|linkage|literal|loop|map|new|next|null|of|on|open|others|out|package|port|postponed|procedure|process|pure|range|record|register|reject|report|return|select|severity|shared|signal|subtype|then|to|transport|type|unaffected|units|until|use|variable|wait|when|while|with)\b/i,"boolean":/\b(true|false)\b/i,"function":{pattern:/([a-z0-9_]+|"\S+")\(/i,inside:{punctuation:/\(/}},number:/'[01uxzwlh-]'|\b\d+[_.]*(#[\da-f_.]+#)?(e[-+]?\d+)?/i,operator:/<=?|>=?|:=|[-+*/&=]|\b(abs|not|mod|rem|sll|srl|sla|sra|rol|ror|and|or|nand|xnor|xor|nor)\b/i,punctuation:/[{}[\];(),.:]/}; \ No newline at end of file diff --git a/examples/prism-vhdl.html b/examples/prism-vhdl.html new file mode 100644 index 0000000000..1dbf649f79 --- /dev/null +++ b/examples/prism-vhdl.html @@ -0,0 +1,95 @@ +

VHDL

+

To use this language, use the class "language-vhdl".

+ +

Comments

+
-- I am a comment
+I am not
+ +

Literals

+
constant FREEZE : integer := 32;
+constant TEMP : real := 32.0;
+A_INT <= 16#FF#;
+B_INT <= 2#1010_1010#;
+MONEY := 1_000_000.0;
+FACTOR := 2.2E-6;
+constant DEL1 :time := 10 ns;
+constant DEL2 :time := 2.27 us;
+type MY_LOGIC is ('X','0','1','Z');
+type T_STATE is (IDLE, READ, END_CYC);
+signal CLK : MY_LOGIC := '0';
+signal STATE : T_STATE := IDLE;
+constant FLAG :bit_vector(0 to 7) := "11111111";
+constant MSG : string := "Hello";
+BIT_8_BUS <= B"1111_1111";
+BIT_9_BUS <= O"353";
+BIT_16_BUS <= X"AA55";
+constant TWO_LINE_MSG : string := "Hello" & CR & "World";
+ +

Full example

+
-- example code from: http://www.csee.umbc.edu/portal/help/VHDL/samples/samples.html
+library IEEE;
+use IEEE.std_logic_1164.all;
+
+entity fadd is               -- full adder stage, interface
+  port(a    : in  std_logic;
+       b    : in  std_logic;
+       cin  : in  std_logic;
+       s    : out std_logic;
+       cout : out std_logic);
+end entity fadd;
+
+architecture circuits of fadd is  -- full adder stage, body
+begin  -- circuits of fadd
+  s <= a xor b xor cin after 1 ns;
+  cout <= (a and b) or (a and cin) or (b and cin) after 1 ns;
+end architecture circuits; -- of fadd
+
+library IEEE;
+use IEEE.std_logic_1164.all;
+entity add32 is             -- simple 32 bit ripple carry adder
+  port(a    : in  std_logic_vector(31 downto 0);
+       b    : in  std_logic_vector(31 downto 0);
+       cin  : in  std_logic;
+       sum  : out std_logic_vector(31 downto 0);
+       cout : out std_logic);
+end entity add32;
+
+architecture circuits of add32 is
+  signal c : std_logic_vector(0 to 30); -- internal carry signals
+begin  -- circuits of add32
+  a0: entity WORK.fadd port map(a(0), b(0), cin, sum(0), c(0));
+  stage: for I in 1 to 30 generate
+             as: entity WORK.fadd port map(a(I), b(I), c(I-1) , sum(I), c(I));
+         end generate stage;
+  a31: entity WORK.fadd port map(a(31), b(31), c(30) , sum(31), cout);
+end architecture circuits;  -- of add32
+
+use STD.textio.all;
+library IEEE;
+use IEEE.std_logic_1164.all;
+use IEEE.std_logic_textio.all;
+
+entity signal_trace is
+end signal_trace;
+
+architecture circuits of signal_trace is
+  signal a:    std_logic_vector(31 downto 0) := x"00000000";
+  signal b:    std_logic_vector(31 downto 0) := x"FFFFFFFF";
+  signal cin:  std_logic := '1';
+  signal cout: std_logic;
+  signal sum:  std_logic_vector(31 downto 0);
+begin  -- circuits of signal_trace
+  adder: entity WORK.add32 port map(a, b, cin, sum, cout); -- parallel circuit
+
+  prtsum: process (sum)
+            variable my_line : LINE;
+            alias swrite is write [line, string, side, width] ;
+          begin
+            swrite(my_line, "sum=");
+            write(my_line, sum);
+            swrite(my_line, ",  at=");
+            write(my_line, now);
+            writeline(output, my_line);
+          end process prtsum;
+
+end architecture circuits; -- of signal_trace
From fa2ca999cee9c180c4e5c42c355e331e89c8cf79 Mon Sep 17 00:00:00 2001 From: AJ Ortega Date: Thu, 18 Jun 2015 21:23:21 -0700 Subject: [PATCH 049/310] Add repository field to bower.json. --- bower.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bower.json b/bower.json index 16a07f097a..39d655cd80 100644 --- a/bower.json +++ b/bower.json @@ -8,6 +8,10 @@ "authors": "Lea Verou", "description": "Lightweight, robust, elegant syntax highlighting. A spin-off project from Dabblet.", "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/PrismJS/prism.git" + } "ignore": [ "**/.*", "img", From 2dd972c215ef0bf781b1959678c607ddb3d1d434 Mon Sep 17 00:00:00 2001 From: AJ Ortega Date: Thu, 18 Jun 2015 21:24:43 -0700 Subject: [PATCH 050/310] Update bower.json --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 39d655cd80..17c6956b1e 100644 --- a/bower.json +++ b/bower.json @@ -11,7 +11,7 @@ "repository": { "type": "git", "url": "https://github.com/PrismJS/prism.git" - } + }, "ignore": [ "**/.*", "img", From f1b2e87adef3256cf8b9f549e557bb83bee4d6af Mon Sep 17 00:00:00 2001 From: aviaryan Date: Fri, 19 Jun 2015 11:55:24 +0530 Subject: [PATCH 051/310] added function highlighting in python --- components/prism-python.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/prism-python.js b/components/prism-python.js index f04765b56c..33bebb9279 100644 --- a/components/prism-python.js +++ b/components/prism-python.js @@ -4,10 +4,13 @@ Prism.languages.python= { lookbehind: true }, 'string': /"""[\s\S]+?"""|'''[\s\S]+?'''|("|')(\\?.)*?\1/, + 'function' : { + pattern: /((^|\s)def[ \t]+)([a-zA-Z_][a-zA-Z0-9_]*(?=\())/g, + lookbehind: true + }, 'keyword' : /\b(as|assert|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/, 'boolean' : /\b(True|False)\b/, 'number' : /\b-?(0[box])?(?:[\da-f]+\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i, 'operator' : /[-+]|<=?|>=?|!|={1,2}|&{1,2}|\|?\||\?|\*|\/|~|\^|%|\b(or|and|not)\b/, 'punctuation' : /[{}[\];(),.:]/ -}; - +}; \ No newline at end of file From 7af9c9bf233224b8bc7208eaafaac33b82c8ea1e Mon Sep 17 00:00:00 2001 From: aviaryan Date: Fri, 19 Jun 2015 12:12:27 +0530 Subject: [PATCH 052/310] fixed bug with hexa numbers highlighting in python --- components/prism-python.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/prism-python.js b/components/prism-python.js index 33bebb9279..b2e031f0a2 100644 --- a/components/prism-python.js +++ b/components/prism-python.js @@ -10,7 +10,7 @@ Prism.languages.python= { }, 'keyword' : /\b(as|assert|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/, 'boolean' : /\b(True|False)\b/, - 'number' : /\b-?(0[box])?(?:[\da-f]+\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i, + 'number' : /\b-?(0[bo])?(?:(\d|0x[a-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i, 'operator' : /[-+]|<=?|>=?|!|={1,2}|&{1,2}|\|?\||\?|\*|\/|~|\^|%|\b(or|and|not)\b/, 'punctuation' : /[{}[\];(),.:]/ }; \ No newline at end of file From 2f2ac778fc45e092a2d4499b3d034d427810442e Mon Sep 17 00:00:00 2001 From: aviaryan Date: Fri, 19 Jun 2015 12:18:28 +0530 Subject: [PATCH 053/310] updated python min file --- components/prism-python.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/prism-python.min.js b/components/prism-python.min.js index 3bd60b4f42..888e8a3fab 100644 --- a/components/prism-python.min.js +++ b/components/prism-python.min.js @@ -1 +1 @@ -Prism.languages.python={comment:{pattern:/(^|[^\\])#.*?(\r?\n|$)/,lookbehind:!0},string:/"""[\s\S]+?"""|'''[\s\S]+?'''|("|')(\\?.)*?\1/,keyword:/\b(as|assert|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/,"boolean":/\b(True|False)\b/,number:/\b-?(0[box])?(?:[\da-f]+\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,operator:/[-+]|<=?|>=?|!|={1,2}|&{1,2}|\|?\||\?|\*|\/|~|\^|%|\b(or|and|not)\b/,punctuation:/[{}[\];(),.:]/}; \ No newline at end of file +Prism.languages.python={comment:{pattern:/(^|[^\\])#.*?(\r?\n|$)/,lookbehind:!0},string:/"""[\s\S]+?"""|'''[\s\S]+?'''|("|')(\\?.)*?\1/,"function":{pattern:/((^|\s)def[ \t]+)([a-zA-Z_][a-zA-Z0-9_]*(?=\())/g,lookbehind:!0},keyword:/\b(as|assert|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/,"boolean":/\b(True|False)\b/,number:/\b-?(0[bo])?(?:(\d|0x[a-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,operator:/[-+]|<=?|>=?|!|={1,2}|&{1,2}|\|?\||\?|\*|\/|~|\^|%|\b(or|and|not)\b/,punctuation:/[{}[\];(),.:]/}; \ No newline at end of file From 476cbf4262a10491a110e4d3544ca0e060725217 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sat, 20 Jun 2015 20:06:39 +0200 Subject: [PATCH 054/310] Improved regex performance of C-like strings and JS regexps --- components/prism-clike.js | 2 +- components/prism-clike.min.js | 2 +- components/prism-javascript.js | 2 +- components/prism-javascript.min.js | 2 +- prism.js | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/prism-clike.js b/components/prism-clike.js index 5c0a03a7c6..3d9f88e57e 100644 --- a/components/prism-clike.js +++ b/components/prism-clike.js @@ -9,7 +9,7 @@ Prism.languages.clike = { lookbehind: true } ], - 'string': /("|')(\\\n|\\?.)*?\1/, + 'string': /("|')(\\[\s\S]|(?!\1)[^\\])*\1/, 'class-name': { pattern: /((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i, lookbehind: true, diff --git a/components/prism-clike.min.js b/components/prism-clike.min.js index 83c97474a8..1ea8bb34ef 100644 --- a/components/prism-clike.min.js +++ b/components/prism-clike.min.js @@ -1 +1 @@ -Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:/("|')(\\\n|\\?.)*?\1/,"class-name":{pattern:/((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,"boolean":/\b(true|false)\b/,"function":{pattern:/[a-z0-9_]+\(/i,inside:{punctuation:/\(/}},number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,operator:/[-+]{1,2}|!|<=?|>=?|={1,3}|&{1,2}|\|?\||\?|\*|\/|~|\^|%/,ignore:/&(lt|gt|amp);/i,punctuation:/[{}[\];(),.:]/}; \ No newline at end of file +Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:/("|')(\\[\s\S]|(?!\1)[^\\])*\1/,"class-name":{pattern:/((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,"boolean":/\b(true|false)\b/,"function":{pattern:/[a-z0-9_]+\(/i,inside:{punctuation:/\(/}},number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,operator:/[-+]{1,2}|!|<=?|>=?|={1,3}|&{1,2}|\|?\||\?|\*|\/|~|\^|%/,ignore:/&(lt|gt|amp);/i,punctuation:/[{}[\];(),.:]/}; \ No newline at end of file diff --git a/components/prism-javascript.js b/components/prism-javascript.js index c614346ba2..b29f194e75 100644 --- a/components/prism-javascript.js +++ b/components/prism-javascript.js @@ -6,7 +6,7 @@ Prism.languages.javascript = Prism.languages.extend('clike', { Prism.languages.insertBefore('javascript', 'keyword', { 'regex': { - pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/, + pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/, lookbehind: true } }); diff --git a/components/prism-javascript.min.js b/components/prism-javascript.min.js index 095cfb1cd4..3fa033b019 100644 --- a/components/prism-javascript.min.js +++ b/components/prism-javascript.min.js @@ -1 +1 @@ -Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(as|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,"function":/(?!\d)[a-z0-9_$]+(?=\()/i}),Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0}}),Prism.languages.insertBefore("javascript","string",{"template-string":{pattern:/`(?:\\`|\\?[^`])*`/,inside:{interpolation:{pattern:/\$\{[^}]+\}/,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}}}),Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/[\w\W]*?<\/script>/i,inside:{tag:{pattern:/|<\/script>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript},alias:"language-javascript"}}); \ No newline at end of file +Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(as|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,"function":/(?!\d)[a-z0-9_$]+(?=\()/i}),Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0}}),Prism.languages.insertBefore("javascript","string",{"template-string":{pattern:/`(?:\\`|\\?[^`])*`/,inside:{interpolation:{pattern:/\$\{[^}]+\}/,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}}}),Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/[\w\W]*?<\/script>/i,inside:{tag:{pattern:/|<\/script>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript},alias:"language-javascript"}}); \ No newline at end of file diff --git a/prism.js b/prism.js index b0dd854b7a..332d792060 100644 --- a/prism.js +++ b/prism.js @@ -548,7 +548,7 @@ Prism.languages.clike = { lookbehind: true } ], - 'string': /("|')(\\\n|\\?.)*?\1/, + 'string': /("|')(\\[\s\S]|(?!\1)[^\\])*\1/, 'class-name': { pattern: /((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i, lookbehind: true, @@ -583,7 +583,7 @@ Prism.languages.javascript = Prism.languages.extend('clike', { Prism.languages.insertBefore('javascript', 'keyword', { 'regex': { - pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/, + pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/, lookbehind: true } }); From a7064dd4cc896955590a6a7010e44acaf3faead0 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sat, 20 Jun 2015 20:07:37 +0200 Subject: [PATCH 055/310] Moved up JS strings before template strings as they are far more common --- components/prism-javascript.js | 2 +- components/prism-javascript.min.js | 2 +- examples/prism-javascript.html | 3 +++ prism.js | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/components/prism-javascript.js b/components/prism-javascript.js index b29f194e75..f2b4054be1 100644 --- a/components/prism-javascript.js +++ b/components/prism-javascript.js @@ -11,7 +11,7 @@ Prism.languages.insertBefore('javascript', 'keyword', { } }); -Prism.languages.insertBefore('javascript', 'string', { +Prism.languages.insertBefore('javascript', 'class-name', { 'template-string': { pattern: /`(?:\\`|\\?[^`])*`/, inside: { diff --git a/components/prism-javascript.min.js b/components/prism-javascript.min.js index 3fa033b019..3bbd703b14 100644 --- a/components/prism-javascript.min.js +++ b/components/prism-javascript.min.js @@ -1 +1 @@ -Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(as|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,"function":/(?!\d)[a-z0-9_$]+(?=\()/i}),Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0}}),Prism.languages.insertBefore("javascript","string",{"template-string":{pattern:/`(?:\\`|\\?[^`])*`/,inside:{interpolation:{pattern:/\$\{[^}]+\}/,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}}}),Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/[\w\W]*?<\/script>/i,inside:{tag:{pattern:/|<\/script>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript},alias:"language-javascript"}}); \ No newline at end of file +Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(as|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,"function":/(?!\d)[a-z0-9_$]+(?=\()/i}),Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0}}),Prism.languages.insertBefore("javascript","class-name",{"template-string":{pattern:/`(?:\\`|\\?[^`])*`/,inside:{interpolation:{pattern:/\$\{[^}]+\}/,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}}}),Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/[\w\W]*?<\/script>/i,inside:{tag:{pattern:/|<\/script>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript},alias:"language-javascript"}}); \ No newline at end of file diff --git a/examples/prism-javascript.html b/examples/prism-javascript.html index 5bd11e3857..77a63d0f40 100644 --- a/examples/prism-javascript.html +++ b/examples/prism-javascript.html @@ -81,6 +81,9 @@

Comment-like substrings

Two quotes of the same type (i.e. both single or both double) inside a regex

foo = /"foo"/;
+

Two quotes of the same type (i.e. both single or both double) inside string interpolation

+
foo = `${"foo"}`;
+

String interpolation containing a closing brace

`${ {foo:'bar'}.foo }`
 `${ '}' }`
diff --git a/prism.js b/prism.js index 332d792060..7ef3b77011 100644 --- a/prism.js +++ b/prism.js @@ -588,7 +588,7 @@ Prism.languages.insertBefore('javascript', 'keyword', { } }); -Prism.languages.insertBefore('javascript', 'string', { +Prism.languages.insertBefore('javascript', 'class-name', { 'template-string': { pattern: /`(?:\\`|\\?[^`])*`/, inside: { From e22af8b487174b1961a32f3518451809fa997e34 Mon Sep 17 00:00:00 2001 From: Logan Franken Date: Sat, 20 Jun 2015 18:44:16 -0700 Subject: [PATCH 056/310] Removed '\r' from line highlight new line spacing logic --- plugins/line-highlight/prism-line-highlight.js | 2 +- plugins/line-highlight/prism-line-highlight.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/line-highlight/prism-line-highlight.js b/plugins/line-highlight/prism-line-highlight.js index b8dddebb29..577d142e98 100644 --- a/plugins/line-highlight/prism-line-highlight.js +++ b/plugins/line-highlight/prism-line-highlight.js @@ -29,7 +29,7 @@ function highlightLines(pre, lines, classes) { var line = document.createElement('div'); - line.textContent = Array(end - start + 2).join(' \r\n'); + line.textContent = Array(end - start + 2).join(' \n'); line.className = (classes || '') + ' line-highlight'; //if the line-numbers plugin is enabled, then there is no reason for this plugin to display the line numbers diff --git a/plugins/line-highlight/prism-line-highlight.min.js b/plugins/line-highlight/prism-line-highlight.min.js index 9432b403ac..83a0108a55 100644 --- a/plugins/line-highlight/prism-line-highlight.min.js +++ b/plugins/line-highlight/prism-line-highlight.min.js @@ -1 +1 @@ -!function(){function e(e,t){return Array.prototype.slice.call((t||document).querySelectorAll(e))}function t(e,t){return t=" "+t+" ",(" "+e.className+" ").replace(/[\n\t]/g," ").indexOf(t)>-1}function n(e,n,r){for(var i,a=n.replace(/\s+/g,"").split(","),l=+e.getAttribute("data-line-offset")||0,o=parseFloat(getComputedStyle(e).lineHeight),d=0;i=a[d++];){i=i.split("-");var c=+i[0],h=+i[1]||c,s=document.createElement("div");s.textContent=Array(h-c+2).join(" \r\n"),s.className=(r||"")+" line-highlight",t(e,"line-numbers")||(s.setAttribute("data-start",c),h>c&&s.setAttribute("data-end",h)),s.style.top=(c-l-1)*o+"px",t(e,"line-numbers")?e.appendChild(s):(e.querySelector("code")||e).appendChild(s)}}function r(){var t=location.hash.slice(1);e(".temporary.line-highlight").forEach(function(e){e.parentNode.removeChild(e)});var r=(t.match(/\.([\d,-]+)$/)||[,""])[1];if(r&&!document.getElementById(t)){var i=t.slice(0,t.lastIndexOf(".")),a=document.getElementById(i);a&&(a.hasAttribute("data-line")||a.setAttribute("data-line",""),n(a,r,"temporary "),document.querySelector(".temporary.line-highlight").scrollIntoView())}}if(window.Prism){var i=(crlf=/\r?\n|\r/g,0);Prism.hooks.add("after-highlight",function(t){var a=t.element.parentNode,l=a&&a.getAttribute("data-line");a&&l&&/pre/i.test(a.nodeName)&&(clearTimeout(i),e(".line-highlight",a).forEach(function(e){e.parentNode.removeChild(e)}),n(a,l),i=setTimeout(r,1))}),addEventListener("hashchange",r)}}(); \ No newline at end of file +!function(){function e(e,t){return Array.prototype.slice.call((t||document).querySelectorAll(e))}function t(e,t){return t=" "+t+" ",(" "+e.className+" ").replace(/[\n\t]/g," ").indexOf(t)>-1}function n(e,n,i){for(var r,a=n.replace(/\s+/g,"").split(","),l=+e.getAttribute("data-line-offset")||0,o=parseFloat(getComputedStyle(e).lineHeight),d=0;r=a[d++];){r=r.split("-");var c=+r[0],h=+r[1]||c,s=document.createElement("div");s.textContent=Array(h-c+2).join(" \n"),s.className=(i||"")+" line-highlight",t(e,"line-numbers")||(s.setAttribute("data-start",c),h>c&&s.setAttribute("data-end",h)),s.style.top=(c-l-1)*o+"px",t(e,"line-numbers")?e.appendChild(s):(e.querySelector("code")||e).appendChild(s)}}function i(){var t=location.hash.slice(1);e(".temporary.line-highlight").forEach(function(e){e.parentNode.removeChild(e)});var i=(t.match(/\.([\d,-]+)$/)||[,""])[1];if(i&&!document.getElementById(t)){var r=t.slice(0,t.lastIndexOf(".")),a=document.getElementById(r);a&&(a.hasAttribute("data-line")||a.setAttribute("data-line",""),n(a,i,"temporary "),document.querySelector(".temporary.line-highlight").scrollIntoView())}}if(window.Prism){var r=(crlf=/\r?\n|\r/g,0);Prism.hooks.add("after-highlight",function(t){var a=t.element.parentNode,l=a&&a.getAttribute("data-line");a&&l&&/pre/i.test(a.nodeName)&&(clearTimeout(r),e(".line-highlight",a).forEach(function(e){e.parentNode.removeChild(e)}),n(a,l),r=setTimeout(i,1))}),addEventListener("hashchange",i)}}(); \ No newline at end of file From 8030db914a1e7331d245db0b9b787b4364994440 Mon Sep 17 00:00:00 2001 From: Golmote Date: Thu, 25 Jun 2015 08:00:14 +0200 Subject: [PATCH 057/310] File Highlight: allow to specify the language (takes precedence over extension guess) + Set language on parent even if unknown. Fix #607 --- components/prism-core.js | 8 +++--- components/prism-core.min.js | 2 +- plugins/file-highlight/index.html | 4 +-- .../file-highlight/prism-file-highlight.js | 17 +++++++++++-- .../prism-file-highlight.min.js | 2 +- prism.js | 25 ++++++++++++++----- 6 files changed, 42 insertions(+), 16 deletions(-) diff --git a/components/prism-core.js b/components/prism-core.js index 750ebb19f0..b9a0ac61a8 100644 --- a/components/prism-core.js +++ b/components/prism-core.js @@ -161,10 +161,6 @@ var _ = self.Prism = { grammar = _.languages[language]; } - if (!grammar) { - return; - } - // Set language on the element, if not present element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language; @@ -175,6 +171,10 @@ var _ = self.Prism = { parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language; } + if (!grammar) { + return; + } + var code = element.textContent; if(!code) { diff --git a/components/prism-core.min.js b/components/prism-core.min.js index 703d1430ef..df4ccd4c43 100644 --- a/components/prism-core.min.js +++ b/components/prism-core.min.js @@ -1 +1 @@ -self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{};var Prism=function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=self.Prism={util:{encode:function(e){return e instanceof n?new n(e.type,t.util.encode(e.content),e.alias):"Array"===t.util.type(e)?e.map(t.util.encode):e.replace(/&/g,"&").replace(/e.length)break e;if(!(d instanceof a)){u.lastIndex=0;var m=u.exec(d);if(m){c&&(f=m[1].length);var y=m.index-1+f,m=m[0].slice(f),v=m.length,k=y+v,b=d.slice(0,y+1),w=d.slice(k+1),N=[p,1];b&&N.push(b);var O=new a(l,g?t.tokenize(m,g):m,h);N.push(O),w&&N.push(w),Array.prototype.splice.apply(r,N)}}}}}return r},hooks:{all:{},add:function(e,n){var a=t.hooks.all;a[e]=a[e]||[],a[e].push(n)},run:function(e,n){var a=t.hooks.all[e];if(a&&a.length)for(var r,i=0;r=a[i++];)r(n)}}},n=t.Token=function(e,t,n){this.type=e,this.content=t,this.alias=n};if(n.stringify=function(e,a,r){if("string"==typeof e)return e;if("Array"===t.util.type(e))return e.map(function(t){return n.stringify(t,a,e)}).join("");var i={type:e.type,content:n.stringify(e.content,a,r),tag:"span",classes:["token",e.type],attributes:{},language:a,parent:r};if("comment"==i.type&&(i.attributes.spellcheck="true"),e.alias){var l="Array"===t.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(i.classes,l)}t.hooks.run("wrap",i);var s="";for(var o in i.attributes)s+=o+'="'+(i.attributes[o]||"")+'"';return"<"+i.tag+' class="'+i.classes.join(" ")+'" '+s+">"+i.content+""},!self.document)return self.addEventListener?(self.addEventListener("message",function(e){var n=JSON.parse(e.data),a=n.language,r=n.code;self.postMessage(JSON.stringify(t.util.encode(t.tokenize(r,t.languages[a])))),self.close()},!1),self.Prism):self.Prism;var a=document.getElementsByTagName("script");return a=a[a.length-1],a&&(t.filename=a.src,document.addEventListener&&!a.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)),self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism); \ No newline at end of file +self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{};var Prism=function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=self.Prism={util:{encode:function(e){return e instanceof n?new n(e.type,t.util.encode(e.content),e.alias):"Array"===t.util.type(e)?e.map(t.util.encode):e.replace(/&/g,"&").replace(/e.length)break e;if(!(d instanceof a)){u.lastIndex=0;var m=u.exec(d);if(m){c&&(f=m[1].length);var y=m.index-1+f,m=m[0].slice(f),v=m.length,k=y+v,b=d.slice(0,y+1),w=d.slice(k+1),N=[p,1];b&&N.push(b);var O=new a(l,g?t.tokenize(m,g):m,h);N.push(O),w&&N.push(w),Array.prototype.splice.apply(r,N)}}}}}return r},hooks:{all:{},add:function(e,n){var a=t.hooks.all;a[e]=a[e]||[],a[e].push(n)},run:function(e,n){var a=t.hooks.all[e];if(a&&a.length)for(var r,i=0;r=a[i++];)r(n)}}},n=t.Token=function(e,t,n){this.type=e,this.content=t,this.alias=n};if(n.stringify=function(e,a,r){if("string"==typeof e)return e;if("Array"===t.util.type(e))return e.map(function(t){return n.stringify(t,a,e)}).join("");var i={type:e.type,content:n.stringify(e.content,a,r),tag:"span",classes:["token",e.type],attributes:{},language:a,parent:r};if("comment"==i.type&&(i.attributes.spellcheck="true"),e.alias){var l="Array"===t.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(i.classes,l)}t.hooks.run("wrap",i);var s="";for(var o in i.attributes)s+=o+'="'+(i.attributes[o]||"")+'"';return"<"+i.tag+' class="'+i.classes.join(" ")+'" '+s+">"+i.content+""},!self.document)return self.addEventListener?(self.addEventListener("message",function(e){var n=JSON.parse(e.data),a=n.language,r=n.code;self.postMessage(JSON.stringify(t.util.encode(t.tokenize(r,t.languages[a])))),self.close()},!1),self.Prism):self.Prism;var a=document.getElementsByTagName("script");return a=a[a.length-1],a&&(t.filename=a.src,document.addEventListener&&!a.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)),self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism); \ No newline at end of file diff --git a/plugins/file-highlight/index.html b/plugins/file-highlight/index.html index 0a3cb58be7..686a7f796d 100644 --- a/plugins/file-highlight/index.html +++ b/plugins/file-highlight/index.html @@ -37,7 +37,7 @@

How to use

Examples

- +

The plugin’s JS code:


 	
@@ -53,7 +53,7 @@ 

Examples

- + diff --git a/plugins/file-highlight/prism-file-highlight.js b/plugins/file-highlight/prism-file-highlight.js index c81dd01af1..5fea85abf0 100644 --- a/plugins/file-highlight/prism-file-highlight.js +++ b/plugins/file-highlight/prism-file-highlight.js @@ -18,8 +18,21 @@ Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function(pre) { var src = pre.getAttribute('data-src'); - var extension = (src.match(/\.(\w+)$/) || [,''])[1]; - var language = Extensions[extension] || extension; + + var language, parent = pre; + var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i; + while (parent && !lang.test(parent.className)) { + parent = parent.parentNode; + } + + if (parent) { + language = (pre.className.match(lang) || [,''])[1]; + } + + if (!language) { + var extension = (src.match(/\.(\w+)$/) || [, ''])[1]; + language = Extensions[extension] || extension; + } var code = document.createElement('code'); code.className = 'language-' + language; diff --git a/plugins/file-highlight/prism-file-highlight.min.js b/plugins/file-highlight/prism-file-highlight.min.js index a14cc1369e..42889f90b6 100644 --- a/plugins/file-highlight/prism-file-highlight.min.js +++ b/plugins/file-highlight/prism-file-highlight.min.js @@ -1 +1 @@ -!function(){self.Prism&&self.document&&document.querySelector&&(self.Prism.fileHighlight=function(){var e={js:"javascript",html:"markup",svg:"markup",xml:"markup",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell"};Array.prototype.slice.call(document.querySelectorAll("pre[data-src]")).forEach(function(t){var r=t.getAttribute("data-src"),s=(r.match(/\.(\w+)$/)||[,""])[1],n=e[s]||s,a=document.createElement("code");a.className="language-"+n,t.textContent="",a.textContent="Loading…",t.appendChild(a);var l=new XMLHttpRequest;l.open("GET",r,!0),l.onreadystatechange=function(){4==l.readyState&&(l.status<400&&l.responseText?(a.textContent=l.responseText,Prism.highlightElement(a)):a.textContent=l.status>=400?"✖ Error "+l.status+" while fetching file: "+l.statusText:"✖ Error: File does not exist or is empty")},l.send(null)})},self.Prism.fileHighlight())}(); \ No newline at end of file +!function(){self.Prism&&self.document&&document.querySelector&&(self.Prism.fileHighlight=function(){var e={js:"javascript",html:"markup",svg:"markup",xml:"markup",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell"};Array.prototype.slice.call(document.querySelectorAll("pre[data-src]")).forEach(function(t){for(var r,s=t.getAttribute("data-src"),a=t,n=/\blang(?:uage)?-(?!\*)(\w+)\b/i;a&&!n.test(a.className);)a=a.parentNode;if(a&&(r=(t.className.match(n)||[,""])[1]),!r){var l=(s.match(/\.(\w+)$/)||[,""])[1];r=e[l]||l}var o=document.createElement("code");o.className="language-"+r,t.textContent="",o.textContent="Loading…",t.appendChild(o);var i=new XMLHttpRequest;i.open("GET",s,!0),i.onreadystatechange=function(){4==i.readyState&&(i.status<400&&i.responseText?(o.textContent=i.responseText,Prism.highlightElement(o)):o.textContent=i.status>=400?"✖ Error "+i.status+" while fetching file: "+i.statusText:"✖ Error: File does not exist or is empty")},i.send(null)})},self.Prism.fileHighlight())}(); \ No newline at end of file diff --git a/prism.js b/prism.js index 7ef3b77011..fb0aeca690 100644 --- a/prism.js +++ b/prism.js @@ -166,10 +166,6 @@ var _ = self.Prism = { grammar = _.languages[language]; } - if (!grammar) { - return; - } - // Set language on the element, if not present element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language; @@ -180,6 +176,10 @@ var _ = self.Prism = { parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language; } + if (!grammar) { + return; + } + var code = element.textContent; if(!code) { @@ -648,8 +648,21 @@ if (Prism.languages.markup) { Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function(pre) { var src = pre.getAttribute('data-src'); - var extension = (src.match(/\.(\w+)$/) || [,''])[1]; - var language = Extensions[extension] || extension; + + var language, parent = pre; + var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i; + while (parent && !lang.test(parent.className)) { + parent = parent.parentNode; + } + + if (parent) { + language = (pre.className.match(lang) || [,''])[1]; + } + + if (!language) { + var extension = (src.match(/\.(\w+)$/) || [, ''])[1]; + language = Extensions[extension] || extension; + } var code = document.createElement('code'); code.className = 'language-' + language; From 5b1e07bc04b0ac0b56a0f4baa6026eefb9aa5c4f Mon Sep 17 00:00:00 2001 From: Weston Ganger Date: Thu, 25 Jun 2015 12:58:40 -0700 Subject: [PATCH 058/310] fixed double quoted strings in interpolation ruby --- components/prism-ruby.js | 2 +- examples/prism-ruby.html | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/components/prism-ruby.js b/components/prism-ruby.js index f34a6de4bb..030eefe9f7 100644 --- a/components/prism-ruby.js +++ b/components/prism-ruby.js @@ -21,7 +21,7 @@ Prism.languages.insertBefore('ruby', 'keyword', { }); Prism.languages.ruby.string = { - pattern: /("|')(\\\n|\\?.)*?\1/, + pattern: /("|')(#\{[^}]+\}|\\\n|\\?.)*?\1/, inside: { 'interpolation': { pattern: /#\{[^}]+\}/, diff --git a/examples/prism-ruby.html b/examples/prism-ruby.html index 1e7b748aa1..4d6472e8b2 100644 --- a/examples/prism-ruby.html +++ b/examples/prism-ruby.html @@ -38,9 +38,6 @@

Known failures

Comments that look like interpolation shows as ruby code

#{my_var}
-

Double quoted strings inside of string interpolation

-
"foo #{my_var + "bar"}"
-

Comment-like substrings

"foo # bar";
From 7410377118a82fdfdbd36f82ae9fc63851e26ad6 Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Sat, 27 Jun 2015 21:52:20 +1000 Subject: [PATCH 059/310] Added Keyman language (http://help.keyman.com/developer) --- components.js | 4 ++++ components/prism-keyman.js | 14 ++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 components/prism-keyman.js diff --git a/components.js b/components.js index a7005728af..997960cd6d 100644 --- a/components.js +++ b/components.js @@ -185,6 +185,10 @@ var components = { "title": "Julia", "owner": "cdagnino" }, + "keyman": { + "title": "Keyman", + "owner": "mcdurdin" + }, "latex": { "title": "LaTeX", "owner": "japborst" diff --git a/components/prism-keyman.js b/components/prism-keyman.js new file mode 100644 index 0000000000..1a0c9751f3 --- /dev/null +++ b/components/prism-keyman.js @@ -0,0 +1,14 @@ +Prism.languages.keyman = { + 'comment': /\b[cC]\s.*?(\r?\n|$)/, + 'function': /\[\s*((CTRL|SHIFT|ALT|LCTRL|RCTRL|LALT|RALT)\s+)*(([T|K|U]_[a-z0-9_]+)|(".+")|('.+'))\s*\]/i, // virtual key + 'string': /("|')((?!\1).)*\1/, + 'keyword': /\b(any|beep|call|context|deadkey|dk|if|index|notany|nul|outs|return|reset|save|set|store|use)\b/i, // rule keywords + 'atrule': /\b(ansi|begin|unicode|group|(using keys))\b/i, // structural keywords + 'bold': [ // header statements + /\&(baselayout|bitmap|capsononly|capsalwaysoff|shiftfreescaps|copyright|ethnologuecode|hotkey|includecodes|keyboardversion|kmw_embedcss|kmw_embdjs|kmw_helpfile|kmw_helptext|kmw_rtl|language|layer|layoutfile|message|mnemoniclayout|name|oldcharposmatching|platform|targets|version|visualkeyboard|windowslanguages)\b/i, + /\b(bitmap|bitmaps|(caps on only)|(caps always off)|(shift frees caps)|copyright|hotkey|language|layout|message|name|version)\b/i + ], + 'number': /\b(([uU]\+[\dA-Fa-f]+)|([dD]\d+)|([xX][\dA-Fa-f]+)|([0-7]+))\b/, // U+####, x###, d### characters and numbers + 'operator': /[+>\\,\(\)]/, + 'tag': /\$(keyman|kmfl|silkey|keymanweb|keymanonly):/i // prefixes +}; \ No newline at end of file From e07819b86e71b4f100002950adae322c189ef76b Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Sat, 27 Jun 2015 22:42:19 +1000 Subject: [PATCH 060/310] Keyman examples --- examples/prism-keyman.html | 101 +++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 examples/prism-keyman.html diff --git a/examples/prism-keyman.html b/examples/prism-keyman.html new file mode 100644 index 0000000000..d85f58cb38 --- /dev/null +++ b/examples/prism-keyman.html @@ -0,0 +1,101 @@ +

Keyman

+

To use this language, use the class "language-keyman".

+ +

Comments

+
c This is a comment
+ +

Strings, numbers and characters

+
"'this' is a string"
+'and so is "this"'
+U+0041 d65 x41   c these are all the letter A
+
+ +

Example Code

+
c =====================Begin Identity Section===================================================
+c 
+c Mnemonic input method for Amharic script on US-QWERTY
+c keyboards for Keyman version 7.1, compliant with Unicode 4.1 and later.
+c 
+
+store(&VERSION) '9.0'
+store(&Name) "Amharic"
+c store(&MnemonicLayout) "1"
+store(&CapsAlwaysOff) "1"
+store(&Copyright) "Creative Commons Attribution 3.0"
+store(&Message) "This is an Amharic language mnemonic input method for Ethiopic script that requires Unicode 4.1 support."
+store(&WINDOWSLANGUAGES) 'x045E x045E'
+store(&LANGUAGE) 'x045E'
+store(&EthnologueCode) "amh"
+store(&VISUALKEYBOARD) 'gff-amh-7.kvk'
+store(&KMW_EMBEDCSS) 'gff-amh-7.css'
+HOTKEY "^%A"
+c 
+c =====================End Identity Section=====================================================
+
+c =====================Begin Data Section=======================================================
+
+c ---------------------Maps for Numbers---------------------------------------------------------
+store(ArabOnes) '23456789'
+store(ones)     '፪፫፬፭፮፯፰፱'
+store(tens)     '፳፴፵፶፷፸፹፺'
+store(arabNumbers) '123456789'
+store(ethNumbers) '፩፪፫፬፭፮፯፰፱፲፳፴፵፶፷፸፹፺፻፼'
+store(arabNumbersWithZero) '0123456789'
+store(ColonOrComma) ':,'
+store(ethWordspaceOrComma) '፡፣'
+c ---------------------End Numbers--------------------------------------------------------------
+
+c =====================End Data Section=========================================================
+
+c =====================Begin Functional Section=================================================
+c 
+store(&LAYOUTFILE) 'gff-amh-7_layout.js'
+store(&BITMAP) 'amharic.bmp'
+store(&TARGETS) 'any windows'
+begin Unicode > use(main)
+group(main) using keys    
+
+c ---------------------Input of Numbers---------------------------------------------------------
+
+c Special Rule for Arabic Numerals
+c 
+c The following attempts to auto-correct the use of Ethiopic wordspace and
+c Ethiopic comma within an Arabic numeral context.  Ethiopic wordspace gets
+c used erroneously in time formats and Ethiopic commas as an order of thousands
+c delimiter. The correction context is not known until numerals appear on _both_
+c sides of the punctuation.
+c 
+  any(arabNumbersWithZero) any(ethWordspaceOrComma) + any(arabNumbers) > index(arabNumbersWithZero,1) index(ColonOrComma,2) index(arabNumbers,3)
+
+c Ethiopic Numerals
+
+  "'" + '1' > '፩'
+  "'" + any(ArabOnes) > index(ones,2)
+
+c special cases for multiples of one
+  '፩'  + '0' > '፲'
+  '፲'  + '0' > '፻'
+  '፻'  + '0' > '፲፻'
+  '፲፻' + '0' > '፼'
+  '፼'  + '0' > '፲፼'    
+  '፲፼' + '0' > '፻፼' 
+  '፻፼'  + '0' > '፲፻፼'
+  '፲፻፼' + '0' > '፼፼'
+  '፼፼' + '0' > context beep  c do not go any higher, we could beep here
+
+c upto the order of 100 million
+  any(ones)     + '0' > index(tens,1)
+  any(tens)     + '0' > index(ones,1) '፻'  c Hundreds
+  any(ones)  '፻ '+ '0' > index(tens,1) '፻'  c Thousands
+  any(tens)  '፻' + '0' > index(ones,1) '፼'  c Ten Thousands
+  any(ones)  '፼' + '0' > index(tens,1) '፼'  c Hundred Thousands
+  any(tens)  '፼' + '0' > index(ones,1) '፻፼' c Millions
+  any(ones) '፻፼' + '0' > index(tens,1) '፻፼' c Ten Millions
+  any(tens) '፻፼' + '0' > index(ones,1) '፼፼' c Hundred Millions
+
+c enhance this later, look for something that can copy a match over
+  any(ethNumbers) + any(arabNumbers) > index(ethNumbers,1)  index(ethNumbers,2)
+c ---------------------End Input of Numbers-----------------------------------------------------
+                                            
+c =====================End Functional Section===================================================
+
From 1c8a841957164e91217c437aebbf3af954645d9b Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Sat, 27 Jun 2015 22:46:21 +1000 Subject: [PATCH 061/310] Add match and nomatch structural keywords --- components/prism-keyman.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/prism-keyman.js b/components/prism-keyman.js index 1a0c9751f3..98793d5d61 100644 --- a/components/prism-keyman.js +++ b/components/prism-keyman.js @@ -3,7 +3,7 @@ Prism.languages.keyman = { 'function': /\[\s*((CTRL|SHIFT|ALT|LCTRL|RCTRL|LALT|RALT)\s+)*(([T|K|U]_[a-z0-9_]+)|(".+")|('.+'))\s*\]/i, // virtual key 'string': /("|')((?!\1).)*\1/, 'keyword': /\b(any|beep|call|context|deadkey|dk|if|index|notany|nul|outs|return|reset|save|set|store|use)\b/i, // rule keywords - 'atrule': /\b(ansi|begin|unicode|group|(using keys))\b/i, // structural keywords + 'atrule': /\b(ansi|begin|unicode|group|(using keys)|match|nomatch)\b/i, // structural keywords 'bold': [ // header statements /\&(baselayout|bitmap|capsononly|capsalwaysoff|shiftfreescaps|copyright|ethnologuecode|hotkey|includecodes|keyboardversion|kmw_embedcss|kmw_embdjs|kmw_helpfile|kmw_helptext|kmw_rtl|language|layer|layoutfile|message|mnemoniclayout|name|oldcharposmatching|platform|targets|version|visualkeyboard|windowslanguages)\b/i, /\b(bitmap|bitmaps|(caps on only)|(caps always off)|(shift frees caps)|copyright|hotkey|language|layout|message|name|version)\b/i From ab4a4cad3dbb4423bcfb1abb154bf0370b69296e Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Sun, 28 Jun 2015 06:24:07 +1000 Subject: [PATCH 062/310] Clean up Keyman regexes, add further examples --- components/prism-keyman.js | 14 +++++++------- examples/prism-keyman.html | 9 +++++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/components/prism-keyman.js b/components/prism-keyman.js index 98793d5d61..aec70fa654 100644 --- a/components/prism-keyman.js +++ b/components/prism-keyman.js @@ -1,14 +1,14 @@ Prism.languages.keyman = { - 'comment': /\b[cC]\s.*?(\r?\n|$)/, - 'function': /\[\s*((CTRL|SHIFT|ALT|LCTRL|RCTRL|LALT|RALT)\s+)*(([T|K|U]_[a-z0-9_]+)|(".+")|('.+'))\s*\]/i, // virtual key + 'comment': /\bc\s.*/i, + 'function': /\[\s*((CTRL|SHIFT|ALT|LCTRL|RCTRL|LALT|RALT|CAPS|NCAPS)\s+)*([TKU]_[a-z0-9_?]+|".+?"|'.+?')\s*\]/i, // virtual key 'string': /("|')((?!\1).)*\1/, 'keyword': /\b(any|beep|call|context|deadkey|dk|if|index|notany|nul|outs|return|reset|save|set|store|use)\b/i, // rule keywords - 'atrule': /\b(ansi|begin|unicode|group|(using keys)|match|nomatch)\b/i, // structural keywords + 'atrule': /\b(ansi|begin|unicode|group|using keys|match|nomatch)\b/i, // structural keywords 'bold': [ // header statements - /\&(baselayout|bitmap|capsononly|capsalwaysoff|shiftfreescaps|copyright|ethnologuecode|hotkey|includecodes|keyboardversion|kmw_embedcss|kmw_embdjs|kmw_helpfile|kmw_helptext|kmw_rtl|language|layer|layoutfile|message|mnemoniclayout|name|oldcharposmatching|platform|targets|version|visualkeyboard|windowslanguages)\b/i, - /\b(bitmap|bitmaps|(caps on only)|(caps always off)|(shift frees caps)|copyright|hotkey|language|layout|message|name|version)\b/i + /&(baselayout|bitmap|capsononly|capsalwaysoff|shiftfreescaps|copyright|ethnologuecode|hotkey|includecodes|keyboardversion|kmw_embedcss|kmw_embdjs|kmw_helpfile|kmw_helptext|kmw_rtl|language|layer|layoutfile|message|mnemoniclayout|name|oldcharposmatching|platform|targets|version|visualkeyboard|windowslanguages)\b/i, + /\b(bitmap|bitmaps|caps on only|caps always off|shift frees caps|copyright|hotkey|language|layout|message|name|version)\b/i ], - 'number': /\b(([uU]\+[\dA-Fa-f]+)|([dD]\d+)|([xX][\dA-Fa-f]+)|([0-7]+))\b/, // U+####, x###, d### characters and numbers - 'operator': /[+>\\,\(\)]/, + 'number': /\b(U\+[\dA-F]+|d\d+|x[\da-f]+|[0-7]+)\b/i, // U+####, x###, d### characters and numbers + 'operator': /[+>\\,()]/, 'tag': /\$(keyman|kmfl|silkey|keymanweb|keymanonly):/i // prefixes }; \ No newline at end of file diff --git a/examples/prism-keyman.html b/examples/prism-keyman.html index d85f58cb38..05898fd1cd 100644 --- a/examples/prism-keyman.html +++ b/examples/prism-keyman.html @@ -10,7 +10,16 @@

Strings, numbers and characters

U+0041 d65 x41 c these are all the letter A +

Prefixes and Virtual Keys

+ +

+c Match RAlt+E on desktops, Ctrl+Alt+E on web because L/R Alt not consistently supported in browsers.
+$KeymanOnly: + [RALT K_E] > "€"
+$KeymanWeb: + [CTRL ALT K_E] > "€"
+
+

Example Code

+
c =====================Begin Identity Section===================================================
 c 
 c Mnemonic input method for Amharic script on US-QWERTY

From a03b32992876c81e12c1a9b85de5be63eff386b0 Mon Sep 17 00:00:00 2001
From: Marc Durdin 
Date: Sun, 28 Jun 2015 06:29:30 +1000
Subject: [PATCH 063/310] bare numbers are not always octal so allow any digit

---
 components/prism-keyman.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/components/prism-keyman.js b/components/prism-keyman.js
index aec70fa654..16752b5295 100644
--- a/components/prism-keyman.js
+++ b/components/prism-keyman.js
@@ -8,7 +8,7 @@ Prism.languages.keyman = {
 		/&(baselayout|bitmap|capsononly|capsalwaysoff|shiftfreescaps|copyright|ethnologuecode|hotkey|includecodes|keyboardversion|kmw_embedcss|kmw_embdjs|kmw_helpfile|kmw_helptext|kmw_rtl|language|layer|layoutfile|message|mnemoniclayout|name|oldcharposmatching|platform|targets|version|visualkeyboard|windowslanguages)\b/i,
 		/\b(bitmap|bitmaps|caps on only|caps always off|shift frees caps|copyright|hotkey|language|layout|message|name|version)\b/i
 	],
-	'number': /\b(U\+[\dA-F]+|d\d+|x[\da-f]+|[0-7]+)\b/i, // U+####, x###, d### characters and numbers
+	'number': /\b(U\+[\dA-F]+|d\d+|x[\da-f]+|\d+)\b/i, // U+####, x###, d### characters and numbers
 	'operator': /[+>\\,()]/,
 	'tag': /\$(keyman|kmfl|silkey|keymanweb|keymanonly):/i   // prefixes
 };
\ No newline at end of file

From c7eb5cb1ccda13d9f708c185254f76b1256504b1 Mon Sep 17 00:00:00 2001
From: Marc Durdin 
Date: Sun, 28 Jun 2015 08:22:28 +1000
Subject: [PATCH 064/310] rename $silkey to $weaver

---
 components/prism-keyman.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/components/prism-keyman.js b/components/prism-keyman.js
index 16752b5295..1082d9d927 100644
--- a/components/prism-keyman.js
+++ b/components/prism-keyman.js
@@ -10,5 +10,5 @@ Prism.languages.keyman = {
 	],
 	'number': /\b(U\+[\dA-F]+|d\d+|x[\da-f]+|\d+)\b/i, // U+####, x###, d### characters and numbers
 	'operator': /[+>\\,()]/,
-	'tag': /\$(keyman|kmfl|silkey|keymanweb|keymanonly):/i   // prefixes
+	'tag': /\$(keyman|kmfl|weaver|keymanweb|keymanonly):/i   // prefixes
 };
\ No newline at end of file

From 12219d2f59de3bf4b8951efd87ad12951ad715ab Mon Sep 17 00:00:00 2001
From: Golmote 
Date: Sun, 28 Jun 2015 02:17:08 +0200
Subject: [PATCH 065/310] Add support for Makefile

---
 components.js                    |   4 +
 components/prism-makefile.js     |  31 ++++
 components/prism-makefile.min.js |   1 +
 examples/prism-makefile.html     | 266 +++++++++++++++++++++++++++++++
 4 files changed, 302 insertions(+)
 create mode 100644 components/prism-makefile.js
 create mode 100644 components/prism-makefile.min.js
 create mode 100644 examples/prism-makefile.html

diff --git a/components.js b/components.js
index a7005728af..47932aa9d9 100644
--- a/components.js
+++ b/components.js
@@ -198,6 +198,10 @@ var components = {
 			"title": "LOLCODE",
 			"owner": "Golmote"
 		},
+		"makefile": {
+			"title": "Makefile",
+			"owner": "Golmote"
+		},
 		"markdown": {
 			"title": "Markdown",
 			"require": "markup",
diff --git a/components/prism-makefile.js b/components/prism-makefile.js
new file mode 100644
index 0000000000..a678fabac8
--- /dev/null
+++ b/components/prism-makefile.js
@@ -0,0 +1,31 @@
+Prism.languages.makefile = {
+	'comment': {
+		pattern: /(^|[^\\])#(?:\\[\s\S]|.)*/,
+		lookbehind: true
+	},
+	'string': /(["'])(?:\\[\s\S]|(?!\1)[^\\\r\n])*\1/,
+
+	// Built-in target names
+	'builtin': /\.[A-Z][^:#=\s]+(?=\s*:(?!=))/,
+
+	// Targets
+	'symbol': {
+		pattern: /^[^:=\r\n]+(?=\s*:(?!=))/m,
+		inside: {
+			'variable': /\$+(?:[^(){}:#=\s]+|(?=[({]))/
+		}
+	},
+	'variable': /\$+(?:[^(){}:#=\s]+|\([@*%<^+?][DF]\)|(?=[({]))/,
+
+	'keyword': [
+		// Directives
+		/\b(?:define|else|endef|endif|export|ifn?def|ifn?eq|-?include|override|private|sinclude|undefine|unexport|vpath)\b/,
+		// Functions
+		{
+			pattern: /(\()(?:addsuffix|abspath|and|basename|call|dir|error|eval|file|filter(?:-out)?|findstring|firstword|flavor|foreach|guile|if|info|join|lastword|load|notdir|or|origin|patsubst|realpath|shell|sort|strip|subst|suffix|value|warning|wildcard|word(?:s|list)?)(?=[ \t])/,
+			lookbehind: true
+		}
+	],
+	'operator': /(?:::|[?:+!])?=|[|@]/,
+	'punctuation': /[:;(){}]/
+};
\ No newline at end of file
diff --git a/components/prism-makefile.min.js b/components/prism-makefile.min.js
new file mode 100644
index 0000000000..85d6f42ca2
--- /dev/null
+++ b/components/prism-makefile.min.js
@@ -0,0 +1 @@
+Prism.languages.makefile={comment:{pattern:/(^|[^\\])#(?:\\[\s\S]|.)*/,lookbehind:!0},string:/(["'])(?:\\[\s\S]|(?!\1)[^\\\r\n])*\1/,builtin:/\.[A-Z][^:#=\s]+(?=\s*:(?!=))/,symbol:{pattern:/^[^:=\r\n]+(?=\s*:(?!=))/m,inside:{variable:/\$+(?:[^(){}:#=\s]+|(?=[({]))/}},variable:/\$+(?:[^(){}:#=\s]+|\([@*%<^+?][DF]\)|(?=[({]))/,keyword:[/\b(?:define|else|endef|endif|export|ifn?def|ifn?eq|-?include|override|private|sinclude|undefine|unexport|vpath)\b/,{pattern:/(\()(?:addsuffix|abspath|and|basename|call|dir|error|eval|file|filter(?:-out)?|findstring|firstword|flavor|foreach|guile|if|info|join|lastword|load|notdir|or|origin|patsubst|realpath|shell|sort|strip|subst|suffix|value|warning|wildcard|word(?:s|list)?)(?=[ \t])/,lookbehind:!0}],operator:/(?:::|[?:+!])?=|[|@]/,punctuation:/[:;(){}]/};
\ No newline at end of file
diff --git a/examples/prism-makefile.html b/examples/prism-makefile.html
new file mode 100644
index 0000000000..738c9a9759
--- /dev/null
+++ b/examples/prism-makefile.html
@@ -0,0 +1,266 @@
+

Makefile

+

To use this language, use the class "language-makefile".

+ +

Comments

+
# This is a comment
+include foo # This is another comment
+ +

Targets

+
kbd.o command.o files.o : command.h
+display.o insert.o search.o files.o : buffer.h
+
+.PHONY: clean
+clean:
+        rm *.o temp
+ +

Variables

+
objects = main.o kbd.o command.o display.o \
+          insert.o search.o files.o utils.o
+
+edit : $(objects)
+        cc -o edit $(objects)
+
+$(objects) : defs.h
+
+%oo: $$< $$^ $$+ $$*
+
+foo : bar/lose
+        cd $(@D) && gobble $(@F) > ../$@
+ +

Strings

+
STR = 'A string!'
+
+HELLO = 'hello \
+world'
+
+HELLO2 = "hello \
+world"
+ +

Directives

+
include foo *.mk $(bar)
+
+vpath %.c foo
+
+override define two-lines =
+foo
+$(bar)
+endef
+
+ifeq ($(CC),gcc)
+  libs=$(libs_for_gcc)
+else
+  libs=$(normal_libs)
+endif
+ +

Functions

+
whoami    := $(shell whoami)
+host-type := $(shell arch)
+
+y = $(subst 1,2,$(x))
+
+dirs := a b c d
+files := $(foreach dir,$(dirs),$(wildcard $(dir)/*))
+
+reverse = $(2) $(1)
+foo = $(call reverse,a,b)
+
+$(foreach prog,$(PROGRAMS),$(eval $(call PROGRAM_template,$(prog))))
+ +

Complete example

+
#!/usr/bin/make -f
+# Generated automatically from Makefile.in by configure.
+# Un*x Makefile for GNU tar program.
+# Copyright (C) 1991 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute
+# it and/or modify it under the terms of the GNU
+# General Public License …
+…
+…
+
+SHELL = /bin/sh
+
+#### Start of system configuration section. ####
+
+srcdir = .
+
+# If you use gcc, you should either run the
+# fixincludes script that comes with it or else use
+# gcc with the -traditional option.  Otherwise ioctl
+# calls will be compiled incorrectly on some systems.
+CC = gcc -O
+YACC = bison -y
+INSTALL = /usr/local/bin/install -c
+INSTALLDATA = /usr/local/bin/install -c -m 644
+
+# Things you might add to DEFS:
+# -DSTDC_HEADERS        If you have ANSI C headers and
+#                       libraries.
+# -DPOSIX               If you have POSIX.1 headers and
+#                       libraries.
+# -DBSD42               If you have sys/dir.h (unless
+#                       you use -DPOSIX), sys/file.h,
+#                       and st_blocks in `struct stat'.
+# -DUSG                 If you have System V/ANSI C
+#                       string and memory functions
+#                       and headers, sys/sysmacros.h,
+#                       fcntl.h, getcwd, no valloc,
+#                       and ndir.h (unless
+#                       you use -DDIRENT).
+# -DNO_MEMORY_H         If USG or STDC_HEADERS but do not
+#                       include memory.h.
+# -DDIRENT              If USG and you have dirent.h
+#                       instead of ndir.h.
+# -DSIGTYPE=int         If your signal handlers
+#                       return int, not void.
+# -DNO_MTIO             If you lack sys/mtio.h
+#                       (magtape ioctls).
+# -DNO_REMOTE           If you do not have a remote shell
+#                       or rexec.
+# -DUSE_REXEC           To use rexec for remote tape
+#                       operations instead of
+#                       forking rsh or remsh.
+# -DVPRINTF_MISSING     If you lack vprintf function
+#                       (but have _doprnt).
+# -DDOPRNT_MISSING      If you lack _doprnt function.
+#                       Also need to define
+#                       -DVPRINTF_MISSING.
+# -DFTIME_MISSING       If you lack ftime system call.
+# -DSTRSTR_MISSING      If you lack strstr function.
+# -DVALLOC_MISSING      If you lack valloc function.
+# -DMKDIR_MISSING       If you lack mkdir and
+#                       rmdir system calls.
+# -DRENAME_MISSING      If you lack rename system call.
+# -DFTRUNCATE_MISSING   If you lack ftruncate
+#                       system call.
+# -DV7                  On Version 7 Unix (not
+#                       tested in a long time).
+# -DEMUL_OPEN3          If you lack a 3-argument version
+#                       of open, and want to emulate it
+#                       with system calls you do have.
+# -DNO_OPEN3            If you lack the 3-argument open
+#                       and want to disable the tar -k
+#                       option instead of emulating open.
+# -DXENIX               If you have sys/inode.h
+#                       and need it 94 to be included.
+
+DEFS =  -DSIGTYPE=int -DDIRENT -DSTRSTR_MISSING \
+        -DVPRINTF_MISSING -DBSD42
+# Set this to rtapelib.o unless you defined NO_REMOTE,
+# in which case make it empty.
+RTAPELIB = rtapelib.o
+LIBS =
+DEF_AR_FILE = /dev/rmt8
+DEFBLOCKING = 20
+
+CDEBUG = -g
+CFLAGS = $(CDEBUG) -I. -I$(srcdir) $(DEFS) \
+        -DDEF_AR_FILE=\"$(DEF_AR_FILE)\" \
+        -DDEFBLOCKING=$(DEFBLOCKING)
+LDFLAGS = -g
+
+prefix = /usr/local
+# Prefix for each installed program,
+# normally empty or `g'.
+binprefix =
+
+# The directory to install tar in.
+bindir = $(prefix)/bin
+
+# The directory to install the info files in.
+infodir = $(prefix)/info
+
+#### End of system configuration section. ####
+
+SRCS_C  = tar.c create.c extract.c buffer.c   \
+          getoldopt.c update.c gnu.c mangle.c \
+          version.c list.c names.c diffarch.c \
+          port.c wildmat.c getopt.c getopt1.c \
+          regex.c
+SRCS_Y  = getdate.y
+SRCS    = $(SRCS_C) $(SRCS_Y)
+OBJS    = $(SRCS_C:.c=.o) $(SRCS_Y:.y=.o) $(RTAPELIB)
+
+AUX =   README COPYING ChangeLog Makefile.in  \
+        makefile.pc configure configure.in \
+        tar.texinfo tar.info* texinfo.tex \
+        tar.h port.h open3.h getopt.h regex.h \
+        rmt.h rmt.c rtapelib.c alloca.c \
+        msd_dir.h msd_dir.c tcexparg.c \
+        level-0 level-1 backup-specs testpad.c
+
+.PHONY: all
+all:    tar rmt tar.info
+
+tar:    $(OBJS)
+        $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
+
+rmt:    rmt.c
+        $(CC) $(CFLAGS) $(LDFLAGS) -o $@ rmt.c
+
+tar.info: tar.texinfo
+        makeinfo tar.texinfo
+
+.PHONY: install
+install: all
+        $(INSTALL) tar $(bindir)/$(binprefix)tar
+        -test ! -f rmt || $(INSTALL) rmt /etc/rmt
+        $(INSTALLDATA) $(srcdir)/tar.info* $(infodir)
+
+$(OBJS): tar.h port.h testpad.h
+regex.o buffer.o tar.o: regex.h
+# getdate.y has 8 shift/reduce conflicts.
+
+testpad.h: testpad
+        ./testpad
+
+testpad: testpad.o
+        $(CC) -o $@ testpad.o
+
+TAGS:   $(SRCS)
+        etags $(SRCS)
+
+.PHONY: clean
+clean:
+        rm -f *.o tar rmt testpad testpad.h core
+
+.PHONY: distclean
+distclean: clean
+        rm -f TAGS Makefile config.status
+
+.PHONY: realclean
+realclean: distclean
+        rm -f tar.info*
+
+.PHONY: shar
+shar: $(SRCS) $(AUX)
+        shar $(SRCS) $(AUX) | compress \
+          > tar-`sed -e '/version_string/!d' \
+                     -e 's/[^0-9.]*\([0-9.]*\).*/\1/' \
+                     -e q
+                     version.c`.shar.Z
+
+.PHONY: dist
+dist: $(SRCS) $(AUX)
+        echo tar-`sed \
+             -e '/version_string/!d' \
+             -e 's/[^0-9.]*\([0-9.]*\).*/\1/' \
+             -e q
+             version.c` > .fname
+        -rm -rf `cat .fname`
+        mkdir `cat .fname`
+        ln $(SRCS) $(AUX) `cat .fname`
+        tar chZf `cat .fname`.tar.Z `cat .fname`
+        -rm -rf `cat .fname` .fname
+
+tar.zoo: $(SRCS) $(AUX)
+        -rm -rf tmp.dir
+        -mkdir tmp.dir
+        -rm tar.zoo
+        for X in $(SRCS) $(AUX) ; do \
+            echo $$X ; \
+            sed 's/$$/^M/' $$X \
+            > tmp.dir/$$X ; done
+        cd tmp.dir ; zoo aM ../tar.zoo *
+        -rm -rf tmp.dir
+
\ No newline at end of file From 670d5afe758c94addbfe4ed8df16e2bf4b517f66 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sun, 28 Jun 2015 02:33:28 +0200 Subject: [PATCH 066/310] Regression fix: do not allow multi-line strings in C-like (unless properly escaped) --- components/prism-clike.js | 2 +- components/prism-clike.min.js | 2 +- prism.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/prism-clike.js b/components/prism-clike.js index 3d9f88e57e..7a5ba2e5dd 100644 --- a/components/prism-clike.js +++ b/components/prism-clike.js @@ -9,7 +9,7 @@ Prism.languages.clike = { lookbehind: true } ], - 'string': /("|')(\\[\s\S]|(?!\1)[^\\])*\1/, + 'string': /("|')(\\[\s\S]|(?!\1)[^\\\r\n])*\1/, 'class-name': { pattern: /((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i, lookbehind: true, diff --git a/components/prism-clike.min.js b/components/prism-clike.min.js index 1ea8bb34ef..32ad31cfa1 100644 --- a/components/prism-clike.min.js +++ b/components/prism-clike.min.js @@ -1 +1 @@ -Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:/("|')(\\[\s\S]|(?!\1)[^\\])*\1/,"class-name":{pattern:/((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,"boolean":/\b(true|false)\b/,"function":{pattern:/[a-z0-9_]+\(/i,inside:{punctuation:/\(/}},number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,operator:/[-+]{1,2}|!|<=?|>=?|={1,3}|&{1,2}|\|?\||\?|\*|\/|~|\^|%/,ignore:/&(lt|gt|amp);/i,punctuation:/[{}[\];(),.:]/}; \ No newline at end of file +Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:/("|')(\\[\s\S]|(?!\1)[^\\\r\n])*\1/,"class-name":{pattern:/((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,"boolean":/\b(true|false)\b/,"function":{pattern:/[a-z0-9_]+\(/i,inside:{punctuation:/\(/}},number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,operator:/[-+]{1,2}|!|<=?|>=?|={1,3}|&{1,2}|\|?\||\?|\*|\/|~|\^|%/,ignore:/&(lt|gt|amp);/i,punctuation:/[{}[\];(),.:]/}; \ No newline at end of file diff --git a/prism.js b/prism.js index fb0aeca690..60c7db9004 100644 --- a/prism.js +++ b/prism.js @@ -548,7 +548,7 @@ Prism.languages.clike = { lookbehind: true } ], - 'string': /("|')(\\[\s\S]|(?!\1)[^\\])*\1/, + 'string': /("|')(\\[\s\S]|(?!\1)[^\\\r\n])*\1/, 'class-name': { pattern: /((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i, lookbehind: true, From f28a3e0ad676fb708aad917ac68b040118864db7 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sun, 28 Jun 2015 05:00:41 +0200 Subject: [PATCH 067/310] Run gulp task --- components/prism-keyman.min.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 components/prism-keyman.min.js diff --git a/components/prism-keyman.min.js b/components/prism-keyman.min.js new file mode 100644 index 0000000000..3978bd266d --- /dev/null +++ b/components/prism-keyman.min.js @@ -0,0 +1 @@ +Prism.languages.keyman={comment:/\bc\s.*/i,"function":/\[\s*((CTRL|SHIFT|ALT|LCTRL|RCTRL|LALT|RALT|CAPS|NCAPS)\s+)*([TKU]_[a-z0-9_?]+|".+?"|'.+?')\s*\]/i,string:/("|')((?!\1).)*\1/,keyword:/\b(any|beep|call|context|deadkey|dk|if|index|notany|nul|outs|return|reset|save|set|store|use)\b/i,atrule:/\b(ansi|begin|unicode|group|using keys|match|nomatch)\b/i,bold:[/&(baselayout|bitmap|capsononly|capsalwaysoff|shiftfreescaps|copyright|ethnologuecode|hotkey|includecodes|keyboardversion|kmw_embedcss|kmw_embdjs|kmw_helpfile|kmw_helptext|kmw_rtl|language|layer|layoutfile|message|mnemoniclayout|name|oldcharposmatching|platform|targets|version|visualkeyboard|windowslanguages)\b/i,/\b(bitmap|bitmaps|caps on only|caps always off|shift frees caps|copyright|hotkey|language|layout|message|name|version)\b/i],number:/\b(U\+[\dA-F]+|d\d+|x[\da-f]+|\d+)\b/i,operator:/[+>\\,()]/,tag:/\$(keyman|kmfl|weaver|keymanweb|keymanonly):/i}; \ No newline at end of file From 08054b153b9d7bb1ac109c6bad56ea2e95ea6e38 Mon Sep 17 00:00:00 2001 From: Golmote Date: Tue, 30 Jun 2015 21:29:30 +0200 Subject: [PATCH 068/310] Add support for elixir --- components.js | 4 + components/prism-elixir.js | 82 ++++++ components/prism-elixir.min.js | 1 + examples/prism-elixir.html | 474 +++++++++++++++++++++++++++++++++ 4 files changed, 561 insertions(+) create mode 100644 components/prism-elixir.js create mode 100644 components/prism-elixir.min.js create mode 100644 examples/prism-elixir.html diff --git a/components.js b/components.js index 919b3c13ae..71400f0d84 100644 --- a/components.js +++ b/components.js @@ -122,6 +122,10 @@ var components = { "title": "Eiffel", "owner": "Conaclos" }, + "elixir": { + "title": "elixir", + "owner": "Golmote" + }, "erlang": { "title": "Erlang", "owner": "Golmote" diff --git a/components/prism-elixir.js b/components/prism-elixir.js new file mode 100644 index 0000000000..a8c52b8740 --- /dev/null +++ b/components/prism-elixir.js @@ -0,0 +1,82 @@ +Prism.languages.elixir = { + 'heredoc': { + pattern: /(?:~[csw])?("""|''')[\s\S]*?\1/i, + alias: 'string' + }, + // Negative look-ahead is needed for string interpolation + 'comment': /#(?!\{).*/, + // ~r"""foo""", ~r'''foo''', ~r/foo/, ~r|foo|, ~r"foo", ~r'foo', ~r(foo), ~r[foo], ~r{foo}, ~r + 'regex': /~[rR](?:("""|'''|[\/|"'])(?:\\.|(?!\1)[^\\])+\1|\((?:\\\)|[^)])+\)|\[(?:\\\]|[^\]])+\]|\{(?:\\\}|[^}])+\}|<(?:\\>|[^>])+>)[uismxfr]*/, + 'string': [ + { + // ~s"""foo""", ~s'''foo''', ~s/foo/, ~s|foo|, ~s"foo", ~s'foo', ~s(foo), ~s[foo], ~s{foo}, ~s + pattern: /~[cCsSwW](?:([\/|"'])(?:\\.|(?!\1)[^\\])+\1|\((?:\\\)|[^)])+\)|\[(?:\\\]|[^\]])+\]|\{(?:\\\}|[^}])+\}|<(?:\\>|[^>])+>)[csa]?/, + inside: { + // See interpolation below + } + }, + { + // Multi-line strings are allowed + pattern: /("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/, + inside: { + // See interpolation below + } + } + ], + 'atom': { + // Look-behind prevents bad highlighting of the :: operator + pattern: /(^|[^:]):\w+/, + lookbehind: true, + alias: 'symbol' + }, + // Look-ahead prevents bad highlighting of the :: operator + 'attr-name': /\w+:(?!:)/, + 'capture': { + // Look-behind prevents bad highlighting of the && operator + pattern: /(^|[^&])&(?:[^&\s\d()][^()]*|(?=\())/, + lookbehind: true, + alias: 'function' + }, + 'argument': { + // Look-behind prevents bad highlighting of the && operator + pattern: /(^|[^&])&\d+/, + lookbehind: true, + alias: 'variable' + }, + 'attribute': { + pattern: /@[\S]+/, + alias: 'variable' + }, + 'number': /\b(?:0[box][a-f\d_]+|\d[\d_]*)(?:\.[\d_]+)?(?:e[+-]?[\d_]+)?\b/i, + 'keyword': /\b(?:after|alias|and|case|catch|cond|def|defcallback|defexception|defimpl|defmodule|defp|defprotocol|defstruct|do|else|end|fn|for|if|import|not|or|require|rescue|try|unless|use|when)\b/, + 'boolean': /\b(?:true|false|nil)\b/, + 'operator': [ + /\bin\b|\|>|\\\\|::|\.\.\.?|\+\+|--|&&|\|\||<>|[!=]==?|[<>]=|->|=>|<-|=~|\B!|[+\-*\/=|^&]/, + { + // We don't want to match << + pattern: /([^<])<(?!<)/, + lookbehind: true + }, + { + // We don't want to match >> + pattern: /([^>])>(?!>)/, + lookbehind: true + } + ], + 'punctuation': /<<|>>|[.,%\[\]{}()]/ +}; + +Prism.languages.elixir.string.forEach(function(o) { + o.inside = { + 'interpolation': { + pattern: /#\{[^}]+\}/, + inside: { + 'delimiter': { + pattern: /^#\{|\}$/, + alias: 'punctuation' + }, + rest: Prism.util.clone(Prism.languages.elixir) + } + } + }; +}); \ No newline at end of file diff --git a/components/prism-elixir.min.js b/components/prism-elixir.min.js new file mode 100644 index 0000000000..d412babad6 --- /dev/null +++ b/components/prism-elixir.min.js @@ -0,0 +1 @@ +Prism.languages.elixir={heredoc:{pattern:/(?:~[csw])?("""|''')[\s\S]*?\1/i,alias:"string"},comment:/#(?!\{).*/,regex:/~[rR](?:("""|'''|[\/|"'])(?:\\.|(?!\1)[^\\])+\1|\((?:\\\)|[^)])+\)|\[(?:\\\]|[^\]])+\]|\{(?:\\\}|[^}])+\}|<(?:\\>|[^>])+>)[uismxfr]*/,string:[{pattern:/~[cCsSwW](?:([\/|"'])(?:\\.|(?!\1)[^\\])+\1|\((?:\\\)|[^)])+\)|\[(?:\\\]|[^\]])+\]|\{(?:\\\}|[^}])+\}|<(?:\\>|[^>])+>)[csa]?/,inside:{}},{pattern:/("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/,inside:{}}],atom:{pattern:/(^|[^:]):\w+/,lookbehind:!0,alias:"symbol"},"attr-name":/\w+:(?!:)/,capture:{pattern:/(^|[^&])&(?:[^&\s\d()][^()]*|(?=\())/,lookbehind:!0,alias:"function"},argument:{pattern:/(^|[^&])&\d+/,lookbehind:!0,alias:"variable"},attribute:{pattern:/@[\S]+/,alias:"variable"},number:/\b(?:0[box][a-f\d_]+|\d[\d_]*)(?:\.[\d_]+)?(?:e[+-]?[\d_]+)?\b/i,keyword:/\b(?:after|alias|and|case|catch|cond|def|defcallback|defexception|defimpl|defmodule|defp|defprotocol|defstruct|do|else|end|fn|for|if|import|not|or|require|rescue|try|unless|use|when)\b/,"boolean":/\b(?:true|false|nil)\b/,operator:[/\bin\b|\|>|\\\\|::|\.\.\.?|\+\+|--|&&|\|\||<>|[!=]==?|[<>]=|->|=>|<-|=~|\B!|[+\-*\/=|^&]/,{pattern:/([^<])<(?!<)/,lookbehind:!0},{pattern:/([^>])>(?!>)/,lookbehind:!0}],punctuation:/<<|>>|[.,%\[\]{}()]/},Prism.languages.elixir.string.forEach(function(e){e.inside={interpolation:{pattern:/#\{[^}]+\}/,inside:{delimiter:{pattern:/^#\{|\}$/,alias:"punctuation"},rest:Prism.util.clone(Prism.languages.elixir)}}}}); \ No newline at end of file diff --git a/examples/prism-elixir.html b/examples/prism-elixir.html new file mode 100644 index 0000000000..09b3631429 --- /dev/null +++ b/examples/prism-elixir.html @@ -0,0 +1,474 @@ +

elixir

+

To use this language, use the class "language-elixir".

+ +

Comments

+
# This is a comment
+ +

Atoms

+
:foo
+:bar
+ +

Numbers

+
42
+0b1010
+0o777
+0x1F
+3.14159
+5.2e10
+100_000
+ +

Strings and heredoc

+
'A string with \'quotes\'!'
+"A string with \"quotes\"!"
+"Multi-line
+strings are supported"
+""" "Heredoc" strings are
+also supported. # This is not a comment
+"""
+ +

Sigils

+
~s"""This is a sigil
+using heredoc delimiters"""
+~r/a [reg]exp/
+~r(another|regexp)
+~w[some words]s
+~c<a char list>
+ +

Interpolation

+
"This is an #{:atom}"
+~s/#{40+2} is the answer/
+ +

Function capturing

+
fun = &Math.zero?/1
+(&is_function/1).(fun)
+fun = &(&1 + 1)
+fun.(1)
+fun = &List.flatten(&1, &2)
+fun.([1, [[2], 3]], [4, 5])
+ +

Module attributes

+
defmodule MyServer do
+  @vsn 2
+end
+
+defmodule Math do
+  @moduledoc """
+  Provides math-related functions.
+
+  ## Examples
+
+      iex> Math.sum(1, 2)
+      3
+
+  """
+
+  @doc """
+  Calculates the sum of two numbers.
+  """
+  def sum(a, b), do: a + b
+end
+ +

Full example

+
# Example from http://learnxinyminutes.com/docs/elixir/
+
+# Single line comments start with a number symbol.
+
+# There's no multi-line comment,
+# but you can stack multiple comments.
+
+# To use the elixir shell use the `iex` command.
+# Compile your modules with the `elixirc` command.
+
+# Both should be in your path if you installed elixir correctly.
+
+## ---------------------------
+## -- Basic types
+## ---------------------------
+
+# There are numbers
+3    # integer
+0x1F # integer
+3.0  # float
+
+# Atoms, that are literals, a constant with name. They start with `:`.
+:hello # atom
+
+# Tuples that are stored contiguously in memory.
+{1,2,3} # tuple
+
+# We can access a tuple element with the `elem` function:
+elem({1, 2, 3}, 0) #=> 1
+
+# Lists that are implemented as linked lists.
+[1,2,3] # list
+
+# We can access the head and tail of a list as follows:
+[head | tail] = [1,2,3]
+head #=> 1
+tail #=> [2,3]
+
+# In elixir, just like in Erlang, the `=` denotes pattern matching and
+# not an assignment.
+#
+# This means that the left-hand side (pattern) is matched against a
+# right-hand side.
+#
+# This is how the above example of accessing the head and tail of a list works.
+
+# A pattern match will error when the sides don't match, in this example
+# the tuples have different sizes.
+# {a, b, c} = {1, 2} #=> ** (MatchError) no match of right hand side value: {1,2}
+
+# There are also binaries
+<<1,2,3>> # binary
+
+# Strings and char lists
+"hello" # string
+'hello' # char list
+
+# Multi-line strings
+"""
+I'm a multi-line
+string.
+"""
+#=> "I'm a multi-line\nstring.\n"
+
+# Strings are all encoded in UTF-8:
+"héllò" #=> "héllò"
+
+# Strings are really just binaries, and char lists are just lists.
+<<?a, ?b, ?c>> #=> "abc"
+[?a, ?b, ?c]   #=> 'abc'
+
+# `?a` in elixir returns the ASCII integer for the letter `a`
+?a #=> 97
+
+# To concatenate lists use `++`, for binaries use `<>`
+[1,2,3] ++ [4,5]     #=> [1,2,3,4,5]
+'hello ' ++ 'world'  #=> 'hello world'
+
+<<1,2,3>> <> <<4,5>> #=> <<1,2,3,4,5>>
+"hello " <> "world"  #=> "hello world"
+
+# Ranges are represented as `start..end` (both inclusive)
+1..10 #=> 1..10
+lower..upper = 1..10 # Can use pattern matching on ranges as well
+[lower, upper] #=> [1, 10]
+
+## ---------------------------
+## -- Operators
+## ---------------------------
+
+# Some math
+1 + 1  #=> 2
+10 - 5 #=> 5
+5 * 2  #=> 10
+10 / 2 #=> 5.0
+
+# In elixir the operator `/` always returns a float.
+
+# To do integer division use `div`
+div(10, 2) #=> 5
+
+# To get the division remainder use `rem`
+rem(10, 3) #=> 1
+
+# There are also boolean operators: `or`, `and` and `not`.
+# These operators expect a boolean as their first argument.
+true and true #=> true
+false or true #=> true
+# 1 and true    #=> ** (ArgumentError) argument error
+
+# Elixir also provides `||`, `&&` and `!` which accept arguments of any type.
+# All values except `false` and `nil` will evaluate to true.
+1 || true  #=> 1
+false && 1 #=> false
+nil && 20  #=> nil
+!true #=> false
+
+# For comparisons we have: `==`, `!=`, `===`, `!==`, `<=`, `>=`, `<` and `>`
+1 == 1 #=> true
+1 != 1 #=> false
+1 < 2  #=> true
+
+# `===` and `!==` are more strict when comparing integers and floats:
+1 == 1.0  #=> true
+1 === 1.0 #=> false
+
+# We can also compare two different data types:
+1 < :hello #=> true
+
+# The overall sorting order is defined below:
+# number < atom < reference < functions < port < pid < tuple < list < bit string
+
+# To quote Joe Armstrong on this: "The actual order is not important,
+# but that a total ordering is well defined is important."
+
+## ---------------------------
+## -- Control Flow
+## ---------------------------
+
+# `if` expression
+if false do
+  "This will never be seen"
+else
+  "This will"
+end
+
+# There's also `unless`
+unless true do
+  "This will never be seen"
+else
+  "This will"
+end
+
+# Remember pattern matching? Many control-flow structures in elixir rely on it.
+
+# `case` allows us to compare a value against many patterns:
+case {:one, :two} do
+  {:four, :five} ->
+    "This won't match"
+  {:one, x} ->
+    "This will match and bind `x` to `:two`"
+  _ ->
+    "This will match any value"
+end
+
+# It's common to bind the value to `_` if we don't need it.
+# For example, if only the head of a list matters to us:
+[head | _] = [1,2,3]
+head #=> 1
+
+# For better readability we can do the following:
+[head | _tail] = [:a, :b, :c]
+head #=> :a
+
+# `cond` lets us check for many conditions at the same time.
+# Use `cond` instead of nesting many `if` expressions.
+cond do
+  1 + 1 == 3 ->
+    "I will never be seen"
+  2 * 5 == 12 ->
+    "Me neither"
+  1 + 2 == 3 ->
+    "But I will"
+end
+
+# It is common to set the last condition equal to `true`, which will always match.
+cond do
+  1 + 1 == 3 ->
+    "I will never be seen"
+  2 * 5 == 12 ->
+    "Me neither"
+  true ->
+    "But I will (this is essentially an else)"
+end
+
+# `try/catch` is used to catch values that are thrown, it also supports an
+# `after` clause that is invoked whether or not a value is caught.
+try do
+  throw(:hello)
+catch
+  message -> "Got #{message}."
+after
+  IO.puts("I'm the after clause.")
+end
+#=> I'm the after clause
+# "Got :hello"
+
+## ---------------------------
+## -- Modules and Functions
+## ---------------------------
+
+# Anonymous functions (notice the dot)
+square = fn(x) -> x * x end
+square.(5) #=> 25
+
+# They also accept many clauses and guards.
+# Guards let you fine tune pattern matching,
+# they are indicated by the `when` keyword:
+f = fn
+  x, y when x > 0 -> x + y
+  x, y -> x * y
+end
+
+f.(1, 3)  #=> 4
+f.(-1, 3) #=> -3
+
+# Elixir also provides many built-in functions.
+# These are available in the current scope.
+is_number(10)    #=> true
+is_list("hello") #=> false
+elem({1,2,3}, 0) #=> 1
+
+# You can group several functions into a module. Inside a module use `def`
+# to define your functions.
+defmodule Math do
+  def sum(a, b) do
+    a + b
+  end
+
+  def square(x) do
+    x * x
+  end
+end
+
+Math.sum(1, 2)  #=> 3
+Math.square(3) #=> 9
+
+# To compile our simple Math module save it as `math.ex` and use `elixirc`
+# in your terminal: elixirc math.ex
+
+# Inside a module we can define functions with `def` and private functions with `defp`.
+# A function defined with `def` is available to be invoked from other modules,
+# a private function can only be invoked locally.
+defmodule PrivateMath do
+  def sum(a, b) do
+    do_sum(a, b)
+  end
+
+  defp do_sum(a, b) do
+    a + b
+  end
+end
+
+PrivateMath.sum(1, 2)    #=> 3
+# PrivateMath.do_sum(1, 2) #=> ** (UndefinedFunctionError)
+
+# Function declarations also support guards and multiple clauses:
+defmodule Geometry do
+  def area({:rectangle, w, h}) do
+    w * h
+  end
+
+  def area({:circle, r}) when is_number(r) do
+    3.14 * r * r
+  end
+end
+
+Geometry.area({:rectangle, 2, 3}) #=> 6
+Geometry.area({:circle, 3})       #=> 28.25999999999999801048
+# Geometry.area({:circle, "not_a_number"})
+#=> ** (FunctionClauseError) no function clause matching in Geometry.area/1
+
+# Due to immutability, recursion is a big part of elixir
+defmodule Recursion do
+  def sum_list([head | tail], acc) do
+    sum_list(tail, acc + head)
+  end
+
+  def sum_list([], acc) do
+    acc
+  end
+end
+
+Recursion.sum_list([1,2,3], 0) #=> 6
+
+# Elixir modules support attributes, there are built-in attributes and you
+# may also add custom ones.
+defmodule MyMod do
+  @moduledoc """
+  This is a built-in attribute on a example module.
+  """
+
+  @my_data 100 # This is a custom attribute.
+  IO.inspect(@my_data) #=> 100
+end
+
+## ---------------------------
+## -- Structs and Exceptions
+## ---------------------------
+
+# Structs are extensions on top of maps that bring default values,
+# compile-time guarantees and polymorphism into Elixir.
+defmodule Person do
+  defstruct name: nil, age: 0, height: 0
+end
+
+joe_info = %Person{ name: "Joe", age: 30, height: 180 }
+#=> %Person{age: 30, height: 180, name: "Joe"}
+
+# Access the value of name
+joe_info.name #=> "Joe"
+
+# Update the value of age
+older_joe_info = %{ joe_info | age: 31 }
+#=> %Person{age: 31, height: 180, name: "Joe"}
+
+# The `try` block with the `rescue` keyword is used to handle exceptions
+try do
+  raise "some error"
+rescue
+  RuntimeError -> "rescued a runtime error"
+  _error -> "this will rescue any error"
+end
+
+# All exceptions have a message
+try do
+  raise "some error"
+rescue
+  x in [RuntimeError] ->
+    x.message
+end
+
+## ---------------------------
+## -- Concurrency
+## ---------------------------
+
+# Elixir relies on the actor model for concurrency. All we need to write
+# concurrent programs in elixir are three primitives: spawning processes,
+# sending messages and receiving messages.
+
+# To start a new process we use the `spawn` function, which takes a function
+# as argument.
+f = fn -> 2 * 2 end #=> #Function<erl_eval.20.80484245>
+spawn(f) #=> #PID<0.40.0>
+
+# `spawn` returns a pid (process identifier), you can use this pid to send
+# messages to the process. To do message passing we use the `send` operator.
+# For all of this to be useful we need to be able to receive messages. This is
+# achieved with the `receive` mechanism:
+defmodule Geometry do
+  def area_loop do
+    receive do
+      {:rectangle, w, h} ->
+        IO.puts("Area = #{w * h}")
+        area_loop()
+      {:circle, r} ->
+        IO.puts("Area = #{3.14 * r * r}")
+        area_loop()
+    end
+  end
+end
+
+# Compile the module and create a process that evaluates `area_loop` in the shell
+pid = spawn(fn -> Geometry.area_loop() end) #=> #PID<0.40.0>
+
+# Send a message to `pid` that will match a pattern in the receive statement
+send pid, {:rectangle, 2, 3}
+#=> Area = 6
+#   {:rectangle,2,3}
+
+send pid, {:circle, 2}
+#=> Area = 12.56000000000000049738
+#   {:circle,2}
+
+# The shell is also a process, you can use `self` to get the current pid
+self() #=> #PID<0.27.0>
+ +

Known failures

+

There are certain edge cases where Prism will fail. + There are always such cases in every regex-based syntax highlighter. + However, Prism dares to be open and honest about them. + If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug. +

+ +

Comments starting with an opening curly brace

+
#{ This is not highlighted properly.
+ +

Comment-like substrings

+
"foo # var"
+ +

String interpolation in single-quoted strings

+
'#{:atom} <- this should not be highligted'
+ From a58bf9ae73edfc18d4260dca1f08f885b2259487 Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Thu, 7 May 2015 21:01:26 -0700 Subject: [PATCH 069/310] javascript: Add async/await --- components/prism-javascript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/prism-javascript.js b/components/prism-javascript.js index f2b4054be1..d4f1025dbf 100644 --- a/components/prism-javascript.js +++ b/components/prism-javascript.js @@ -1,5 +1,5 @@ Prism.languages.javascript = Prism.languages.extend('clike', { - 'keyword': /\b(as|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/, + 'keyword': /\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/, 'number': /\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/, 'function': /(?!\d)[a-z0-9_$]+(?=\()/i }); From 8be7815bfec07835d72f8a5cf5ea28ca6031655a Mon Sep 17 00:00:00 2001 From: Golmote Date: Wed, 1 Jul 2015 18:50:02 +0200 Subject: [PATCH 070/310] Run gulp task --- components/prism-javascript.min.js | 2 +- prism.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/prism-javascript.min.js b/components/prism-javascript.min.js index 3bbd703b14..a3a4a002ab 100644 --- a/components/prism-javascript.min.js +++ b/components/prism-javascript.min.js @@ -1 +1 @@ -Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(as|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,"function":/(?!\d)[a-z0-9_$]+(?=\()/i}),Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0}}),Prism.languages.insertBefore("javascript","class-name",{"template-string":{pattern:/`(?:\\`|\\?[^`])*`/,inside:{interpolation:{pattern:/\$\{[^}]+\}/,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}}}),Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/[\w\W]*?<\/script>/i,inside:{tag:{pattern:/|<\/script>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript},alias:"language-javascript"}}); \ No newline at end of file +Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,"function":/(?!\d)[a-z0-9_$]+(?=\()/i}),Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0}}),Prism.languages.insertBefore("javascript","class-name",{"template-string":{pattern:/`(?:\\`|\\?[^`])*`/,inside:{interpolation:{pattern:/\$\{[^}]+\}/,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}}}),Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/[\w\W]*?<\/script>/i,inside:{tag:{pattern:/|<\/script>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript},alias:"language-javascript"}}); \ No newline at end of file diff --git a/prism.js b/prism.js index 60c7db9004..81a2f0b286 100644 --- a/prism.js +++ b/prism.js @@ -576,7 +576,7 @@ Prism.languages.clike = { ********************************************** */ Prism.languages.javascript = Prism.languages.extend('clike', { - 'keyword': /\b(as|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/, + 'keyword': /\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/, 'number': /\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/, 'function': /(?!\d)[a-z0-9_$]+(?=\()/i }); From 950afe9d69fae09fbe23486a0363a99d386bd16e Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Thu, 2 Jul 2015 09:19:05 +1000 Subject: [PATCH 071/310] fix typo in kmw_embedjs --- components/prism-keyman.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/prism-keyman.js b/components/prism-keyman.js index 1082d9d927..aaafa10f61 100644 --- a/components/prism-keyman.js +++ b/components/prism-keyman.js @@ -5,7 +5,7 @@ Prism.languages.keyman = { 'keyword': /\b(any|beep|call|context|deadkey|dk|if|index|notany|nul|outs|return|reset|save|set|store|use)\b/i, // rule keywords 'atrule': /\b(ansi|begin|unicode|group|using keys|match|nomatch)\b/i, // structural keywords 'bold': [ // header statements - /&(baselayout|bitmap|capsononly|capsalwaysoff|shiftfreescaps|copyright|ethnologuecode|hotkey|includecodes|keyboardversion|kmw_embedcss|kmw_embdjs|kmw_helpfile|kmw_helptext|kmw_rtl|language|layer|layoutfile|message|mnemoniclayout|name|oldcharposmatching|platform|targets|version|visualkeyboard|windowslanguages)\b/i, + /&(baselayout|bitmap|capsononly|capsalwaysoff|shiftfreescaps|copyright|ethnologuecode|hotkey|includecodes|keyboardversion|kmw_embedcss|kmw_embedjs|kmw_helpfile|kmw_helptext|kmw_rtl|language|layer|layoutfile|message|mnemoniclayout|name|oldcharposmatching|platform|targets|version|visualkeyboard|windowslanguages)\b/i, /\b(bitmap|bitmaps|caps on only|caps always off|shift frees caps|copyright|hotkey|language|layout|message|name|version)\b/i ], 'number': /\b(U\+[\dA-F]+|d\d+|x[\da-f]+|\d+)\b/i, // U+####, x###, d### characters and numbers From ebfc23c878cb8f13c4a0af1d2035e6cd293524f9 Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Thu, 2 Jul 2015 09:42:35 +1000 Subject: [PATCH 072/310] Added baselayout, layer and platform statements (they exist as keywords as well as system stores) --- components/prism-keyman.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/prism-keyman.js b/components/prism-keyman.js index aaafa10f61..9c3e0bf5b6 100644 --- a/components/prism-keyman.js +++ b/components/prism-keyman.js @@ -2,9 +2,9 @@ Prism.languages.keyman = { 'comment': /\bc\s.*/i, 'function': /\[\s*((CTRL|SHIFT|ALT|LCTRL|RCTRL|LALT|RALT|CAPS|NCAPS)\s+)*([TKU]_[a-z0-9_?]+|".+?"|'.+?')\s*\]/i, // virtual key 'string': /("|')((?!\1).)*\1/, - 'keyword': /\b(any|beep|call|context|deadkey|dk|if|index|notany|nul|outs|return|reset|save|set|store|use)\b/i, // rule keywords + 'keyword': /\b(any|baselayout|beep|call|context|deadkey|dk|if|index|layer|notany|nul|outs|platform|return|reset|save|set|store|use)\b/i, // rule keywords 'atrule': /\b(ansi|begin|unicode|group|using keys|match|nomatch)\b/i, // structural keywords - 'bold': [ // header statements + 'bold': [ // header statements, system stores and variable system stores /&(baselayout|bitmap|capsononly|capsalwaysoff|shiftfreescaps|copyright|ethnologuecode|hotkey|includecodes|keyboardversion|kmw_embedcss|kmw_embedjs|kmw_helpfile|kmw_helptext|kmw_rtl|language|layer|layoutfile|message|mnemoniclayout|name|oldcharposmatching|platform|targets|version|visualkeyboard|windowslanguages)\b/i, /\b(bitmap|bitmaps|caps on only|caps always off|shift frees caps|copyright|hotkey|language|layout|message|name|version)\b/i ], From 1682ca5e9024e006230c758a4c538fd1c7c5f95a Mon Sep 17 00:00:00 2001 From: Golmote Date: Thu, 2 Jul 2015 06:26:56 +0200 Subject: [PATCH 073/310] Run gulp task --- components/prism-keyman.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/prism-keyman.min.js b/components/prism-keyman.min.js index 3978bd266d..1c6d17995a 100644 --- a/components/prism-keyman.min.js +++ b/components/prism-keyman.min.js @@ -1 +1 @@ -Prism.languages.keyman={comment:/\bc\s.*/i,"function":/\[\s*((CTRL|SHIFT|ALT|LCTRL|RCTRL|LALT|RALT|CAPS|NCAPS)\s+)*([TKU]_[a-z0-9_?]+|".+?"|'.+?')\s*\]/i,string:/("|')((?!\1).)*\1/,keyword:/\b(any|beep|call|context|deadkey|dk|if|index|notany|nul|outs|return|reset|save|set|store|use)\b/i,atrule:/\b(ansi|begin|unicode|group|using keys|match|nomatch)\b/i,bold:[/&(baselayout|bitmap|capsononly|capsalwaysoff|shiftfreescaps|copyright|ethnologuecode|hotkey|includecodes|keyboardversion|kmw_embedcss|kmw_embdjs|kmw_helpfile|kmw_helptext|kmw_rtl|language|layer|layoutfile|message|mnemoniclayout|name|oldcharposmatching|platform|targets|version|visualkeyboard|windowslanguages)\b/i,/\b(bitmap|bitmaps|caps on only|caps always off|shift frees caps|copyright|hotkey|language|layout|message|name|version)\b/i],number:/\b(U\+[\dA-F]+|d\d+|x[\da-f]+|\d+)\b/i,operator:/[+>\\,()]/,tag:/\$(keyman|kmfl|weaver|keymanweb|keymanonly):/i}; \ No newline at end of file +Prism.languages.keyman={comment:/\bc\s.*/i,"function":/\[\s*((CTRL|SHIFT|ALT|LCTRL|RCTRL|LALT|RALT|CAPS|NCAPS)\s+)*([TKU]_[a-z0-9_?]+|".+?"|'.+?')\s*\]/i,string:/("|')((?!\1).)*\1/,keyword:/\b(any|baselayout|beep|call|context|deadkey|dk|if|index|layer|notany|nul|outs|platform|return|reset|save|set|store|use)\b/i,atrule:/\b(ansi|begin|unicode|group|using keys|match|nomatch)\b/i,bold:[/&(baselayout|bitmap|capsononly|capsalwaysoff|shiftfreescaps|copyright|ethnologuecode|hotkey|includecodes|keyboardversion|kmw_embedcss|kmw_embedjs|kmw_helpfile|kmw_helptext|kmw_rtl|language|layer|layoutfile|message|mnemoniclayout|name|oldcharposmatching|platform|targets|version|visualkeyboard|windowslanguages)\b/i,/\b(bitmap|bitmaps|caps on only|caps always off|shift frees caps|copyright|hotkey|language|layout|message|name|version)\b/i],number:/\b(U\+[\dA-F]+|d\d+|x[\da-f]+|\d+)\b/i,operator:/[+>\\,()]/,tag:/\$(keyman|kmfl|weaver|keymanweb|keymanonly):/i}; \ No newline at end of file From 88f44a79d069af2b2d3efcdb899d7ef7d025d035 Mon Sep 17 00:00:00 2001 From: Golmote Date: Mon, 6 Jul 2015 19:58:40 +0200 Subject: [PATCH 074/310] Swift: update keyword list (fix #625) --- components/prism-swift.js | 2 +- components/prism-swift.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/prism-swift.js b/components/prism-swift.js index dc2f790ce5..953b7177cd 100644 --- a/components/prism-swift.js +++ b/components/prism-swift.js @@ -1,6 +1,6 @@ // issues: nested multiline comments, highlighting inside string interpolations Prism.languages.swift = Prism.languages.extend('clike', { - 'keyword': /\b(as|associativity|break|case|class|continue|convenience|default|deinit|didSet|do|dynamicType|else|enum|extension|fallthrough|final|for|func|get|if|import|in|infix|init|inout|internal|is|lazy|left|let|mutating|new|none|nonmutating|operator|optional|override|postfix|precedence|prefix|private|protocol|public|required|return|right|safe|self|Self|set|static|struct|subscript|super|switch|Type|typealias|unowned|unowned|unsafe|var|weak|where|while|willSet|__COLUMN__|__FILE__|__FUNCTION__|__LINE__)\b/, + 'keyword': /\b(as|associativity|break|case|catch|class|continue|convenience|default|defer|deinit|didSet|do|dynamic|dynamicType|else|enum|extension|fallthrough|final|for|func|get|guard|if|import|in|infix|init|inout|internal|is|lazy|left|let|mutating|new|none|nonmutating|operator|optional|override|postfix|precedence|prefix|private|Protocol|public|repeat|required|rethrows|return|right|safe|self|Self|set|static|struct|subscript|super|switch|throws?|try|Type|typealias|unowned|unsafe|var|weak|where|while|willSet|__COLUMN__|__FILE__|__FUNCTION__|__LINE__)\b/, 'number': /\b([\d_]+(\.[\de_]+)?|0x[a-f0-9_]+(\.[a-f0-9p_]+)?|0b[01_]+|0o[0-7_]+)\b/i, 'constant': /\b(nil|[A-Z_]{2,}|k[A-Z][A-Za-z_]+)\b/, 'atrule': /@\b(IBOutlet|IBDesignable|IBAction|IBInspectable|class_protocol|exported|noreturn|NSCopying|NSManaged|objc|UIApplicationMain|auto_closure)\b/, diff --git a/components/prism-swift.min.js b/components/prism-swift.min.js index 4e17687017..863366b193 100644 --- a/components/prism-swift.min.js +++ b/components/prism-swift.min.js @@ -1 +1 @@ -Prism.languages.swift=Prism.languages.extend("clike",{keyword:/\b(as|associativity|break|case|class|continue|convenience|default|deinit|didSet|do|dynamicType|else|enum|extension|fallthrough|final|for|func|get|if|import|in|infix|init|inout|internal|is|lazy|left|let|mutating|new|none|nonmutating|operator|optional|override|postfix|precedence|prefix|private|protocol|public|required|return|right|safe|self|Self|set|static|struct|subscript|super|switch|Type|typealias|unowned|unowned|unsafe|var|weak|where|while|willSet|__COLUMN__|__FILE__|__FUNCTION__|__LINE__)\b/,number:/\b([\d_]+(\.[\de_]+)?|0x[a-f0-9_]+(\.[a-f0-9p_]+)?|0b[01_]+|0o[0-7_]+)\b/i,constant:/\b(nil|[A-Z_]{2,}|k[A-Z][A-Za-z_]+)\b/,atrule:/@\b(IBOutlet|IBDesignable|IBAction|IBInspectable|class_protocol|exported|noreturn|NSCopying|NSManaged|objc|UIApplicationMain|auto_closure)\b/,builtin:/\b([A-Z]\S+|abs|advance|alignof|alignofValue|assert|contains|count|countElements|debugPrint|debugPrintln|distance|dropFirst|dropLast|dump|enumerate|equal|filter|find|first|getVaList|indices|isEmpty|join|last|lazy|lexicographicalCompare|map|max|maxElement|min|minElement|numericCast|overlaps|partition|prefix|print|println|reduce|reflect|reverse|sizeof|sizeofValue|sort|sorted|split|startsWith|stride|strideof|strideofValue|suffix|swap|toDebugString|toString|transcode|underestimateCount|unsafeBitCast|withExtendedLifetime|withUnsafeMutablePointer|withUnsafeMutablePointers|withUnsafePointer|withUnsafePointers|withVaList)\b/}); \ No newline at end of file +Prism.languages.swift=Prism.languages.extend("clike",{keyword:/\b(as|associativity|break|case|catch|class|continue|convenience|default|defer|deinit|didSet|do|dynamic|dynamicType|else|enum|extension|fallthrough|final|for|func|get|guard|if|import|in|infix|init|inout|internal|is|lazy|left|let|mutating|new|none|nonmutating|operator|optional|override|postfix|precedence|prefix|private|Protocol|public|repeat|required|rethrows|return|right|safe|self|Self|set|static|struct|subscript|super|switch|throws?|try|Type|typealias|unowned|unsafe|var|weak|where|while|willSet|__COLUMN__|__FILE__|__FUNCTION__|__LINE__)\b/,number:/\b([\d_]+(\.[\de_]+)?|0x[a-f0-9_]+(\.[a-f0-9p_]+)?|0b[01_]+|0o[0-7_]+)\b/i,constant:/\b(nil|[A-Z_]{2,}|k[A-Z][A-Za-z_]+)\b/,atrule:/@\b(IBOutlet|IBDesignable|IBAction|IBInspectable|class_protocol|exported|noreturn|NSCopying|NSManaged|objc|UIApplicationMain|auto_closure)\b/,builtin:/\b([A-Z]\S+|abs|advance|alignof|alignofValue|assert|contains|count|countElements|debugPrint|debugPrintln|distance|dropFirst|dropLast|dump|enumerate|equal|filter|find|first|getVaList|indices|isEmpty|join|last|lazy|lexicographicalCompare|map|max|maxElement|min|minElement|numericCast|overlaps|partition|prefix|print|println|reduce|reflect|reverse|sizeof|sizeofValue|sort|sorted|split|startsWith|stride|strideof|strideofValue|suffix|swap|toDebugString|toString|transcode|underestimateCount|unsafeBitCast|withExtendedLifetime|withUnsafeMutablePointer|withUnsafeMutablePointers|withUnsafePointer|withUnsafePointers|withVaList)\b/}); \ No newline at end of file From 5b29a673c468920ac68c3af6e769f72c2b895434 Mon Sep 17 00:00:00 2001 From: Vivek Ghaisas Date: Mon, 6 Jul 2015 21:25:08 +0300 Subject: [PATCH 075/310] Add Ubuntu Mono font to font stack None of the other fonts are currently available on Ubuntu and the addition of Ubuntu Mono to the font stack makes the code look much nicer on Ubuntu systems. Also added a missing newline to the end of prism-coy.css --- themes/prism-coy.css | 4 ++-- themes/prism-dark.css | 2 +- themes/prism-funky.css | 2 +- themes/prism-okaidia.css | 2 +- themes/prism-tomorrow.css | 2 +- themes/prism-twilight.css | 2 +- themes/prism.css | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/themes/prism-coy.css b/themes/prism-coy.css index 8db555e126..7a325d63a8 100644 --- a/themes/prism-coy.css +++ b/themes/prism-coy.css @@ -7,7 +7,7 @@ code[class*="language-"], pre[class*="language-"] { color: black; - font-family: Consolas, Monaco, 'Andale Mono', monospace; + font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; direction: ltr; text-align: left; white-space: pre; @@ -228,4 +228,4 @@ pre[data-line] code { } pre .line-highlight { margin-top: 0; -} \ No newline at end of file +} diff --git a/themes/prism-dark.css b/themes/prism-dark.css index a8047fce6e..1c4daa2227 100644 --- a/themes/prism-dark.css +++ b/themes/prism-dark.css @@ -8,7 +8,7 @@ code[class*="language-"], pre[class*="language-"] { color: white; text-shadow: 0 -.1em .2em black; - font-family: Consolas, Monaco, 'Andale Mono', monospace; + font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; direction: ltr; text-align: left; white-space: pre; diff --git a/themes/prism-funky.css b/themes/prism-funky.css index f2614d1573..30135635ee 100644 --- a/themes/prism-funky.css +++ b/themes/prism-funky.css @@ -6,7 +6,7 @@ code[class*="language-"], pre[class*="language-"] { - font-family: Consolas, Monaco, 'Andale Mono', monospace; + font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; direction: ltr; text-align: left; white-space: pre; diff --git a/themes/prism-okaidia.css b/themes/prism-okaidia.css index 3ff2e3c772..0fac6828db 100644 --- a/themes/prism-okaidia.css +++ b/themes/prism-okaidia.css @@ -8,7 +8,7 @@ code[class*="language-"], pre[class*="language-"] { color: #f8f8f2; text-shadow: 0 1px rgba(0, 0, 0, 0.3); - font-family: Consolas, Monaco, 'Andale Mono', monospace; + font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; direction: ltr; text-align: left; white-space: pre; diff --git a/themes/prism-tomorrow.css b/themes/prism-tomorrow.css index c998fb22cb..44f0f7edd0 100644 --- a/themes/prism-tomorrow.css +++ b/themes/prism-tomorrow.css @@ -7,7 +7,7 @@ code[class*="language-"], pre[class*="language-"] { color: #ccc; - font-family: Consolas, Monaco, 'Andale Mono', monospace; + font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; direction: ltr; text-align: left; white-space: pre; diff --git a/themes/prism-twilight.css b/themes/prism-twilight.css index 89dbe848b4..ab0813410e 100644 --- a/themes/prism-twilight.css +++ b/themes/prism-twilight.css @@ -7,7 +7,7 @@ code[class*="language-"], pre[class*="language-"] { color: white; direction: ltr; - font-family: Consolas, Monaco, 'Andale Mono', monospace; + font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; text-align: left; text-shadow: 0 -.1em .2em black; white-space: pre; diff --git a/themes/prism.css b/themes/prism.css index a04c82c89c..3a57f8e817 100644 --- a/themes/prism.css +++ b/themes/prism.css @@ -8,7 +8,7 @@ code[class*="language-"], pre[class*="language-"] { color: black; text-shadow: 0 1px white; - font-family: Consolas, Monaco, 'Andale Mono', monospace; + font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; direction: ltr; text-align: left; white-space: pre; From 9391e09ceef2a641b9e4289a2cefcb672f897ea9 Mon Sep 17 00:00:00 2001 From: Logan Franken Date: Tue, 7 Jul 2015 23:22:09 -0700 Subject: [PATCH 076/310] Added regex rule to capture media query media types and logical operators in SCSS language --- components/prism-scss.js | 2 +- components/prism-scss.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/prism-scss.js b/components/prism-scss.js index 69ea3c79f3..36b956c4ed 100644 --- a/components/prism-scss.js +++ b/components/prism-scss.js @@ -5,7 +5,7 @@ Prism.languages.scss = Prism.languages.extend('css', { }, // aturle is just the @***, not the entire rule (to highlight var & stuffs) // + add ability to highlight number & unit for media queries - 'atrule': /@[\w-]+(?=\s+(\(|\{|;))/i, + 'atrule': /@[\w-]+.*?(?=\s+(\(|\{|;))/i, // url, compassified 'url': /([-a-z]+-)*url(?=\()/i, // CSS selector regex is not appropriate for Sass diff --git a/components/prism-scss.min.js b/components/prism-scss.min.js index 7d0d82b47f..ef62fb7fe4 100644 --- a/components/prism-scss.min.js +++ b/components/prism-scss.min.js @@ -1 +1 @@ -Prism.languages.scss=Prism.languages.extend("css",{comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|\/\/.*?(\r?\n|$))/,lookbehind:!0},atrule:/@[\w-]+(?=\s+(\(|\{|;))/i,url:/([-a-z]+-)*url(?=\()/i,selector:/([^@;\{\}\(\)]?([^@;\{\}\(\)]|&|#\{\$[-_\w]+\})+)(?=\s*\{(\}|\s|[^\}]+(:|\{)[^\}]+))/m}),Prism.languages.insertBefore("scss","atrule",{keyword:/@(if|else if|else|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)|(?=@for\s+\$[-_\w]+\s)+from/i}),Prism.languages.insertBefore("scss","property",{variable:/((\$[-_\w]+)|(#\{\$[-_\w]+\}))/i}),Prism.languages.insertBefore("scss","function",{placeholder:/%[-_\w]+/i,statement:/\B!(default|optional)\b/i,"boolean":/\b(true|false)\b/,"null":/\b(null)\b/,operator:/\s+([-+]{1,2}|={1,2}|!=|\|?\||\?|\*|\/|%)\s+/}); \ No newline at end of file +Prism.languages.scss=Prism.languages.extend("css",{comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|\/\/.*?(\r?\n|$))/,lookbehind:!0},atrule:/@[\w-]+.*?(?=\s+(\(|\{|;))/i,url:/([-a-z]+-)*url(?=\()/i,selector:/([^@;\{\}\(\)]?([^@;\{\}\(\)]|&|#\{\$[-_\w]+\})+)(?=\s*\{(\}|\s|[^\}]+(:|\{)[^\}]+))/m}),Prism.languages.insertBefore("scss","atrule",{keyword:/@(if|else if|else|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)|(?=@for\s+\$[-_\w]+\s)+from/i}),Prism.languages.insertBefore("scss","property",{variable:/((\$[-_\w]+)|(#\{\$[-_\w]+\}))/i}),Prism.languages.insertBefore("scss","function",{placeholder:/%[-_\w]+/i,statement:/\B!(default|optional)\b/i,"boolean":/\b(true|false)\b/,"null":/\b(null)\b/,operator:/\s+([-+]{1,2}|={1,2}|!=|\|?\||\?|\*|\/|%)\s+/}); \ No newline at end of file From bf8e032623d0954969374e51d02d3640faa6f1b1 Mon Sep 17 00:00:00 2001 From: Golmote Date: Wed, 8 Jul 2015 09:10:59 +0200 Subject: [PATCH 077/310] Fix SCSS media queries --- components/prism-scss.js | 8 +++++++- components/prism-scss.min.js | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/components/prism-scss.js b/components/prism-scss.js index 36b956c4ed..907b6632bc 100644 --- a/components/prism-scss.js +++ b/components/prism-scss.js @@ -5,7 +5,13 @@ Prism.languages.scss = Prism.languages.extend('css', { }, // aturle is just the @***, not the entire rule (to highlight var & stuffs) // + add ability to highlight number & unit for media queries - 'atrule': /@[\w-]+.*?(?=\s+(\(|\{|;))/i, + 'atrule': { + pattern: /@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+(\{|;))/i, + inside: { + 'property': Prism.languages.css.property, + 'punctuation': /[():]/ + } + }, // url, compassified 'url': /([-a-z]+-)*url(?=\()/i, // CSS selector regex is not appropriate for Sass diff --git a/components/prism-scss.min.js b/components/prism-scss.min.js index ef62fb7fe4..a8444e438c 100644 --- a/components/prism-scss.min.js +++ b/components/prism-scss.min.js @@ -1 +1 @@ -Prism.languages.scss=Prism.languages.extend("css",{comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|\/\/.*?(\r?\n|$))/,lookbehind:!0},atrule:/@[\w-]+.*?(?=\s+(\(|\{|;))/i,url:/([-a-z]+-)*url(?=\()/i,selector:/([^@;\{\}\(\)]?([^@;\{\}\(\)]|&|#\{\$[-_\w]+\})+)(?=\s*\{(\}|\s|[^\}]+(:|\{)[^\}]+))/m}),Prism.languages.insertBefore("scss","atrule",{keyword:/@(if|else if|else|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)|(?=@for\s+\$[-_\w]+\s)+from/i}),Prism.languages.insertBefore("scss","property",{variable:/((\$[-_\w]+)|(#\{\$[-_\w]+\}))/i}),Prism.languages.insertBefore("scss","function",{placeholder:/%[-_\w]+/i,statement:/\B!(default|optional)\b/i,"boolean":/\b(true|false)\b/,"null":/\b(null)\b/,operator:/\s+([-+]{1,2}|={1,2}|!=|\|?\||\?|\*|\/|%)\s+/}); \ No newline at end of file +Prism.languages.scss=Prism.languages.extend("css",{comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|\/\/.*?(\r?\n|$))/,lookbehind:!0},atrule:{pattern:/@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+(\{|;))/i,inside:{property:Prism.languages.css.property,punctuation:/[():]/}},url:/([-a-z]+-)*url(?=\()/i,selector:/([^@;\{\}\(\)]?([^@;\{\}\(\)]|&|#\{\$[-_\w]+\})+)(?=\s*\{(\}|\s|[^\}]+(:|\{)[^\}]+))/m}),Prism.languages.insertBefore("scss","atrule",{keyword:/@(if|else if|else|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)|(?=@for\s+\$[-_\w]+\s)+from/i}),Prism.languages.insertBefore("scss","property",{variable:/((\$[-_\w]+)|(#\{\$[-_\w]+\}))/i}),Prism.languages.insertBefore("scss","function",{placeholder:/%[-_\w]+/i,statement:/\B!(default|optional)\b/i,"boolean":/\b(true|false)\b/,"null":/\b(null)\b/,operator:/\s+([-+]{1,2}|={1,2}|!=|\|?\||\?|\*|\/|%)\s+/}); \ No newline at end of file From 1ebcb8e65d35d25e5404029312e8fff14e42c328 Mon Sep 17 00:00:00 2001 From: Golmote Date: Wed, 8 Jul 2015 19:17:36 +0200 Subject: [PATCH 078/310] Markup: highlight single quotes in attr-value as punctuation --- components/prism-markup.js | 2 +- components/prism-markup.min.js | 2 +- prism.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/prism-markup.js b/components/prism-markup.js index eeec921065..12dcc68a66 100644 --- a/components/prism-markup.js +++ b/components/prism-markup.js @@ -16,7 +16,7 @@ Prism.languages.markup = { 'attr-value': { pattern: /=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i, inside: { - 'punctuation': /=|>|"/ + 'punctuation': /[=>"']/ } }, 'punctuation': /\/?>/, diff --git a/components/prism-markup.min.js b/components/prism-markup.min.js index 458e87ec48..dc2aa39d5e 100644 --- a/components/prism-markup.min.js +++ b/components/prism-markup.min.js @@ -1 +1 @@ -Prism.languages.markup={comment://,prolog:/<\?.+?\?>/,doctype://,cdata://i,tag:{pattern:/<\/?[^\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(t){"entity"===t.type&&(t.attributes.title=t.content.replace(/&/,"&"))}); \ No newline at end of file +Prism.languages.markup={comment://,prolog:/<\?.+?\?>/,doctype://,cdata://i,tag:{pattern:/<\/?[^\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(t){"entity"===t.type&&(t.attributes.title=t.content.replace(/&/,"&"))}); \ No newline at end of file diff --git a/prism.js b/prism.js index 81a2f0b286..f6cac06edd 100644 --- a/prism.js +++ b/prism.js @@ -453,7 +453,7 @@ Prism.languages.markup = { 'attr-value': { pattern: /=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i, inside: { - 'punctuation': /=|>|"/ + 'punctuation': /[=>"']/ } }, 'punctuation': /\/?>/, From c19a238bd0e8aa9e7030f2316be117de375abdbd Mon Sep 17 00:00:00 2001 From: Golmote Date: Wed, 8 Jul 2015 19:18:35 +0200 Subject: [PATCH 079/310] Markup: doctype and prolog can be multi-line. --- components/prism-markup.js | 4 ++-- components/prism-markup.min.js | 2 +- prism.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/prism-markup.js b/components/prism-markup.js index 12dcc68a66..f3abdf28b5 100644 --- a/components/prism-markup.js +++ b/components/prism-markup.js @@ -1,7 +1,7 @@ Prism.languages.markup = { 'comment': //, - 'prolog': /<\?.+?\?>/, - 'doctype': //, + 'prolog': /<\?[\w\W]+?\?>/, + 'doctype': //, 'cdata': //i, 'tag': { pattern: /<\/?[^\s>\/]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i, diff --git a/components/prism-markup.min.js b/components/prism-markup.min.js index dc2aa39d5e..6a17f5eb13 100644 --- a/components/prism-markup.min.js +++ b/components/prism-markup.min.js @@ -1 +1 @@ -Prism.languages.markup={comment://,prolog:/<\?.+?\?>/,doctype://,cdata://i,tag:{pattern:/<\/?[^\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(t){"entity"===t.type&&(t.attributes.title=t.content.replace(/&/,"&"))}); \ No newline at end of file +Prism.languages.markup={comment://,prolog:/<\?[\w\W]+?\?>/,doctype://,cdata://i,tag:{pattern:/<\/?[^\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(t){"entity"===t.type&&(t.attributes.title=t.content.replace(/&/,"&"))}); \ No newline at end of file diff --git a/prism.js b/prism.js index f6cac06edd..98a851d6bb 100644 --- a/prism.js +++ b/prism.js @@ -437,8 +437,8 @@ if (typeof module !== 'undefined' && module.exports) { Prism.languages.markup = { 'comment': //, - 'prolog': /<\?.+?\?>/, - 'doctype': //, + 'prolog': /<\?[\w\W]+?\?>/, + 'doctype': //, 'cdata': //i, 'tag': { pattern: /<\/?[^\s>\/]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i, From eef42485c5981b841b670ffebbc50ba2c4492c87 Mon Sep 17 00:00:00 2001 From: Golmote Date: Wed, 8 Jul 2015 19:24:19 +0200 Subject: [PATCH 080/310] SCSS: Highlight everything inside atrules --- components/prism-scss.js | 7 +++---- components/prism-scss.min.js | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/components/prism-scss.js b/components/prism-scss.js index 907b6632bc..56d643b892 100644 --- a/components/prism-scss.js +++ b/components/prism-scss.js @@ -3,13 +3,10 @@ Prism.languages.scss = Prism.languages.extend('css', { pattern: /(^|[^\\])(\/\*[\w\W]*?\*\/|\/\/.*?(\r?\n|$))/, lookbehind: true }, - // aturle is just the @***, not the entire rule (to highlight var & stuffs) - // + add ability to highlight number & unit for media queries 'atrule': { pattern: /@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+(\{|;))/i, inside: { - 'property': Prism.languages.css.property, - 'punctuation': /[():]/ + // See rest at the end of the file } }, // url, compassified @@ -40,3 +37,5 @@ Prism.languages.insertBefore('scss', 'function', { 'null': /\b(null)\b/, 'operator': /\s+([-+]{1,2}|={1,2}|!=|\|?\||\?|\*|\/|%)\s+/ }); + +Prism.languages.scss['atrule'].inside.rest = Prism.util.clone(Prism.languages.scss); \ No newline at end of file diff --git a/components/prism-scss.min.js b/components/prism-scss.min.js index a8444e438c..05b354022e 100644 --- a/components/prism-scss.min.js +++ b/components/prism-scss.min.js @@ -1 +1 @@ -Prism.languages.scss=Prism.languages.extend("css",{comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|\/\/.*?(\r?\n|$))/,lookbehind:!0},atrule:{pattern:/@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+(\{|;))/i,inside:{property:Prism.languages.css.property,punctuation:/[():]/}},url:/([-a-z]+-)*url(?=\()/i,selector:/([^@;\{\}\(\)]?([^@;\{\}\(\)]|&|#\{\$[-_\w]+\})+)(?=\s*\{(\}|\s|[^\}]+(:|\{)[^\}]+))/m}),Prism.languages.insertBefore("scss","atrule",{keyword:/@(if|else if|else|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)|(?=@for\s+\$[-_\w]+\s)+from/i}),Prism.languages.insertBefore("scss","property",{variable:/((\$[-_\w]+)|(#\{\$[-_\w]+\}))/i}),Prism.languages.insertBefore("scss","function",{placeholder:/%[-_\w]+/i,statement:/\B!(default|optional)\b/i,"boolean":/\b(true|false)\b/,"null":/\b(null)\b/,operator:/\s+([-+]{1,2}|={1,2}|!=|\|?\||\?|\*|\/|%)\s+/}); \ No newline at end of file +Prism.languages.scss=Prism.languages.extend("css",{comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|\/\/.*?(\r?\n|$))/,lookbehind:!0},atrule:{pattern:/@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+(\{|;))/i,inside:{}},url:/([-a-z]+-)*url(?=\()/i,selector:/([^@;\{\}\(\)]?([^@;\{\}\(\)]|&|#\{\$[-_\w]+\})+)(?=\s*\{(\}|\s|[^\}]+(:|\{)[^\}]+))/m}),Prism.languages.insertBefore("scss","atrule",{keyword:/@(if|else if|else|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)|(?=@for\s+\$[-_\w]+\s)+from/i}),Prism.languages.insertBefore("scss","property",{variable:/((\$[-_\w]+)|(#\{\$[-_\w]+\}))/i}),Prism.languages.insertBefore("scss","function",{placeholder:/%[-_\w]+/i,statement:/\B!(default|optional)\b/i,"boolean":/\b(true|false)\b/,"null":/\b(null)\b/,operator:/\s+([-+]{1,2}|={1,2}|!=|\|?\||\?|\*|\/|%)\s+/}),Prism.languages.scss.atrule.inside.rest=Prism.util.clone(Prism.languages.scss); \ No newline at end of file From cd0273ee23712b9e3edb003e0c327cdfced60c08 Mon Sep 17 00:00:00 2001 From: Golmote Date: Wed, 8 Jul 2015 19:26:35 +0200 Subject: [PATCH 081/310] CSS: Highlight parentheses as punctuation --- components/prism-css.js | 4 ++-- components/prism-css.min.js | 2 +- prism.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/prism-css.js b/components/prism-css.js index 4b0b721889..68ec5e1ec4 100644 --- a/components/prism-css.js +++ b/components/prism-css.js @@ -11,8 +11,8 @@ Prism.languages.css = { 'string': /("|')(\\\n|\\?.)*?\1/, 'property': /(\b|\B)[\w-]+(?=\s*:)/i, 'important': /\B!important\b/i, - 'punctuation': /[\{\};:]/, - 'function': /[-a-z0-9]+(?=\()/i + 'function': /[-a-z0-9]+(?=\()/i, + 'punctuation': /[(){};:]/ }; if (Prism.languages.markup) { diff --git a/components/prism-css.min.js b/components/prism-css.min.js index a7d624b0e6..db3214519d 100644 --- a/components/prism-css.min.js +++ b/components/prism-css.min.js @@ -1 +1 @@ -Prism.languages.css={comment:/\/\*[\w\W]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*\{))/i,inside:{punctuation:/[;:]/}},url:/url\((?:(["'])(\\\n|\\?.)*?\1|.*?)\)/i,selector:/[^\{\}\s][^\{\};]*(?=\s*\{)/,string:/("|')(\\\n|\\?.)*?\1/,property:/(\b|\B)[\w-]+(?=\s*:)/i,important:/\B!important\b/i,punctuation:/[\{\};:]/,"function":/[-a-z0-9]+(?=\()/i},Prism.languages.markup&&(Prism.languages.insertBefore("markup","tag",{style:{pattern:/[\w\W]*?<\/style>/i,inside:{tag:{pattern:/|<\/style>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.css},alias:"language-css"}}),Prism.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|').*?\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:Prism.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:Prism.languages.css}},alias:"language-css"}},Prism.languages.markup.tag)); \ No newline at end of file +Prism.languages.css={comment:/\/\*[\w\W]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*\{))/i,inside:{punctuation:/[;:]/}},url:/url\((?:(["'])(\\\n|\\?.)*?\1|.*?)\)/i,selector:/[^\{\}\s][^\{\};]*(?=\s*\{)/,string:/("|')(\\\n|\\?.)*?\1/,property:/(\b|\B)[\w-]+(?=\s*:)/i,important:/\B!important\b/i,"function":/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:]/},Prism.languages.markup&&(Prism.languages.insertBefore("markup","tag",{style:{pattern:/[\w\W]*?<\/style>/i,inside:{tag:{pattern:/|<\/style>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.css},alias:"language-css"}}),Prism.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|').*?\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:Prism.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:Prism.languages.css}},alias:"language-css"}},Prism.languages.markup.tag)); \ No newline at end of file diff --git a/prism.js b/prism.js index 98a851d6bb..31e0ae9c75 100644 --- a/prism.js +++ b/prism.js @@ -495,8 +495,8 @@ Prism.languages.css = { 'string': /("|')(\\\n|\\?.)*?\1/, 'property': /(\b|\B)[\w-]+(?=\s*:)/i, 'important': /\B!important\b/i, - 'punctuation': /[\{\};:]/, - 'function': /[-a-z0-9]+(?=\()/i + 'function': /[-a-z0-9]+(?=\()/i, + 'punctuation': /[(){};:]/ }; if (Prism.languages.markup) { From e25408898e247646d26d23bc7b744d822d427c5b Mon Sep 17 00:00:00 2001 From: Golmote Date: Wed, 8 Jul 2015 19:32:10 +0200 Subject: [PATCH 082/310] CSS: Improve atrules --- components/prism-css.js | 5 ++++- components/prism-css.min.js | 2 +- components/prism-scss.js | 3 ++- components/prism-scss.min.js | 2 +- prism.js | 5 ++++- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/components/prism-css.js b/components/prism-css.js index 68ec5e1ec4..ca86ba6f9f 100644 --- a/components/prism-css.js +++ b/components/prism-css.js @@ -3,7 +3,8 @@ Prism.languages.css = { 'atrule': { pattern: /@[\w-]+?.*?(;|(?=\s*\{))/i, inside: { - 'punctuation': /[;:]/ + 'rule': /@[\w-]+/ + // See rest below } }, 'url': /url\((?:(["'])(\\\n|\\?.)*?\1|.*?)\)/i, @@ -15,6 +16,8 @@ Prism.languages.css = { 'punctuation': /[(){};:]/ }; +Prism.languages.css['atrule'].inside.rest = Prism.util.clone(Prism.languages.css); + if (Prism.languages.markup) { Prism.languages.insertBefore('markup', 'tag', { 'style': { diff --git a/components/prism-css.min.js b/components/prism-css.min.js index db3214519d..f3d20421d2 100644 --- a/components/prism-css.min.js +++ b/components/prism-css.min.js @@ -1 +1 @@ -Prism.languages.css={comment:/\/\*[\w\W]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*\{))/i,inside:{punctuation:/[;:]/}},url:/url\((?:(["'])(\\\n|\\?.)*?\1|.*?)\)/i,selector:/[^\{\}\s][^\{\};]*(?=\s*\{)/,string:/("|')(\\\n|\\?.)*?\1/,property:/(\b|\B)[\w-]+(?=\s*:)/i,important:/\B!important\b/i,"function":/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:]/},Prism.languages.markup&&(Prism.languages.insertBefore("markup","tag",{style:{pattern:/[\w\W]*?<\/style>/i,inside:{tag:{pattern:/|<\/style>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.css},alias:"language-css"}}),Prism.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|').*?\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:Prism.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:Prism.languages.css}},alias:"language-css"}},Prism.languages.markup.tag)); \ No newline at end of file +Prism.languages.css={comment:/\/\*[\w\W]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(\\\n|\\?.)*?\1|.*?)\)/i,selector:/[^\{\}\s][^\{\};]*(?=\s*\{)/,string:/("|')(\\\n|\\?.)*?\1/,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),Prism.languages.markup&&(Prism.languages.insertBefore("markup","tag",{style:{pattern:/[\w\W]*?<\/style>/i,inside:{tag:{pattern:/|<\/style>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.css},alias:"language-css"}}),Prism.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|').*?\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:Prism.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:Prism.languages.css}},alias:"language-css"}},Prism.languages.markup.tag)); \ No newline at end of file diff --git a/components/prism-scss.js b/components/prism-scss.js index 56d643b892..c798ff86e6 100644 --- a/components/prism-scss.js +++ b/components/prism-scss.js @@ -6,7 +6,8 @@ Prism.languages.scss = Prism.languages.extend('css', { 'atrule': { pattern: /@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+(\{|;))/i, inside: { - // See rest at the end of the file + 'rule': /@[\w-]+/ + // See rest below } }, // url, compassified diff --git a/components/prism-scss.min.js b/components/prism-scss.min.js index 05b354022e..a7469c723c 100644 --- a/components/prism-scss.min.js +++ b/components/prism-scss.min.js @@ -1 +1 @@ -Prism.languages.scss=Prism.languages.extend("css",{comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|\/\/.*?(\r?\n|$))/,lookbehind:!0},atrule:{pattern:/@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+(\{|;))/i,inside:{}},url:/([-a-z]+-)*url(?=\()/i,selector:/([^@;\{\}\(\)]?([^@;\{\}\(\)]|&|#\{\$[-_\w]+\})+)(?=\s*\{(\}|\s|[^\}]+(:|\{)[^\}]+))/m}),Prism.languages.insertBefore("scss","atrule",{keyword:/@(if|else if|else|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)|(?=@for\s+\$[-_\w]+\s)+from/i}),Prism.languages.insertBefore("scss","property",{variable:/((\$[-_\w]+)|(#\{\$[-_\w]+\}))/i}),Prism.languages.insertBefore("scss","function",{placeholder:/%[-_\w]+/i,statement:/\B!(default|optional)\b/i,"boolean":/\b(true|false)\b/,"null":/\b(null)\b/,operator:/\s+([-+]{1,2}|={1,2}|!=|\|?\||\?|\*|\/|%)\s+/}),Prism.languages.scss.atrule.inside.rest=Prism.util.clone(Prism.languages.scss); \ No newline at end of file +Prism.languages.scss=Prism.languages.extend("css",{comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|\/\/.*?(\r?\n|$))/,lookbehind:!0},atrule:{pattern:/@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+(\{|;))/i,inside:{rule:/@[\w-]+/}},url:/([-a-z]+-)*url(?=\()/i,selector:/([^@;\{\}\(\)]?([^@;\{\}\(\)]|&|#\{\$[-_\w]+\})+)(?=\s*\{(\}|\s|[^\}]+(:|\{)[^\}]+))/m}),Prism.languages.insertBefore("scss","atrule",{keyword:/@(if|else if|else|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)|(?=@for\s+\$[-_\w]+\s)+from/i}),Prism.languages.insertBefore("scss","property",{variable:/((\$[-_\w]+)|(#\{\$[-_\w]+\}))/i}),Prism.languages.insertBefore("scss","function",{placeholder:/%[-_\w]+/i,statement:/\B!(default|optional)\b/i,"boolean":/\b(true|false)\b/,"null":/\b(null)\b/,operator:/\s+([-+]{1,2}|={1,2}|!=|\|?\||\?|\*|\/|%)\s+/}),Prism.languages.scss.atrule.inside.rest=Prism.util.clone(Prism.languages.scss); \ No newline at end of file diff --git a/prism.js b/prism.js index 31e0ae9c75..59c1e13bc2 100644 --- a/prism.js +++ b/prism.js @@ -487,7 +487,8 @@ Prism.languages.css = { 'atrule': { pattern: /@[\w-]+?.*?(;|(?=\s*\{))/i, inside: { - 'punctuation': /[;:]/ + 'rule': /@[\w-]+/ + // See rest below } }, 'url': /url\((?:(["'])(\\\n|\\?.)*?\1|.*?)\)/i, @@ -499,6 +500,8 @@ Prism.languages.css = { 'punctuation': /[(){};:]/ }; +Prism.languages.css['atrule'].inside.rest = Prism.util.clone(Prism.languages.css); + if (Prism.languages.markup) { Prism.languages.insertBefore('markup', 'tag', { 'style': { From 901812c1f041188a73b6062ed41d2058e12c2714 Mon Sep 17 00:00:00 2001 From: Golmote Date: Wed, 8 Jul 2015 19:35:57 +0200 Subject: [PATCH 083/310] CSS: Improved url and string regexps + handle \r --- components/prism-css.js | 4 ++-- components/prism-css.min.js | 2 +- prism.js | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/prism-css.js b/components/prism-css.js index ca86ba6f9f..9bc63fa637 100644 --- a/components/prism-css.js +++ b/components/prism-css.js @@ -7,9 +7,9 @@ Prism.languages.css = { // See rest below } }, - 'url': /url\((?:(["'])(\\\n|\\?.)*?\1|.*?)\)/i, + 'url': /url\((?:(["'])(\\[\w\W]|(?!\1)[^\\\r\n])*\1|.*?)\)/i, 'selector': /[^\{\}\s][^\{\};]*(?=\s*\{)/, - 'string': /("|')(\\\n|\\?.)*?\1/, + 'string': /("|')(\\[\w\W]|(?!\1)[^\\\r\n])*\1/, 'property': /(\b|\B)[\w-]+(?=\s*:)/i, 'important': /\B!important\b/i, 'function': /[-a-z0-9]+(?=\()/i, diff --git a/components/prism-css.min.js b/components/prism-css.min.js index f3d20421d2..0fdb8d51da 100644 --- a/components/prism-css.min.js +++ b/components/prism-css.min.js @@ -1 +1 @@ -Prism.languages.css={comment:/\/\*[\w\W]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(\\\n|\\?.)*?\1|.*?)\)/i,selector:/[^\{\}\s][^\{\};]*(?=\s*\{)/,string:/("|')(\\\n|\\?.)*?\1/,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),Prism.languages.markup&&(Prism.languages.insertBefore("markup","tag",{style:{pattern:/[\w\W]*?<\/style>/i,inside:{tag:{pattern:/|<\/style>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.css},alias:"language-css"}}),Prism.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|').*?\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:Prism.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:Prism.languages.css}},alias:"language-css"}},Prism.languages.markup.tag)); \ No newline at end of file +Prism.languages.css={comment:/\/\*[\w\W]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(\\[\w\W]|(?!\1)[^\\\r\n])*\1|.*?)\)/i,selector:/[^\{\}\s][^\{\};]*(?=\s*\{)/,string:/("|')(\\[\w\W]|(?!\1)[^\\\r\n])*\1/,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),Prism.languages.markup&&(Prism.languages.insertBefore("markup","tag",{style:{pattern:/[\w\W]*?<\/style>/i,inside:{tag:{pattern:/|<\/style>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.css},alias:"language-css"}}),Prism.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|').*?\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:Prism.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:Prism.languages.css}},alias:"language-css"}},Prism.languages.markup.tag)); \ No newline at end of file diff --git a/prism.js b/prism.js index 59c1e13bc2..49e0a9090c 100644 --- a/prism.js +++ b/prism.js @@ -491,9 +491,9 @@ Prism.languages.css = { // See rest below } }, - 'url': /url\((?:(["'])(\\\n|\\?.)*?\1|.*?)\)/i, + 'url': /url\((?:(["'])(\\[\w\W]|(?!\1)[^\\\r\n])*\1|.*?)\)/i, 'selector': /[^\{\}\s][^\{\};]*(?=\s*\{)/, - 'string': /("|')(\\\n|\\?.)*?\1/, + 'string': /("|')(\\[\w\W]|(?!\1)[^\\\r\n])*\1/, 'property': /(\b|\B)[\w-]+(?=\s*:)/i, 'important': /\B!important\b/i, 'function': /[-a-z0-9]+(?=\()/i, From f2e2718f2435a56f79b6177d4708a9364161656f Mon Sep 17 00:00:00 2001 From: Golmote Date: Wed, 8 Jul 2015 19:39:35 +0200 Subject: [PATCH 084/310] CSS: Selector regexp should not include last spaces before brace --- components/prism-css.js | 2 +- components/prism-css.min.js | 2 +- prism.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/prism-css.js b/components/prism-css.js index 9bc63fa637..995d37e7ee 100644 --- a/components/prism-css.js +++ b/components/prism-css.js @@ -8,7 +8,7 @@ Prism.languages.css = { } }, 'url': /url\((?:(["'])(\\[\w\W]|(?!\1)[^\\\r\n])*\1|.*?)\)/i, - 'selector': /[^\{\}\s][^\{\};]*(?=\s*\{)/, + 'selector': /[^\{\}\s][^\{\};]*?(?=\s*\{)/, 'string': /("|')(\\[\w\W]|(?!\1)[^\\\r\n])*\1/, 'property': /(\b|\B)[\w-]+(?=\s*:)/i, 'important': /\B!important\b/i, diff --git a/components/prism-css.min.js b/components/prism-css.min.js index 0fdb8d51da..b320fd77ad 100644 --- a/components/prism-css.min.js +++ b/components/prism-css.min.js @@ -1 +1 @@ -Prism.languages.css={comment:/\/\*[\w\W]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(\\[\w\W]|(?!\1)[^\\\r\n])*\1|.*?)\)/i,selector:/[^\{\}\s][^\{\};]*(?=\s*\{)/,string:/("|')(\\[\w\W]|(?!\1)[^\\\r\n])*\1/,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),Prism.languages.markup&&(Prism.languages.insertBefore("markup","tag",{style:{pattern:/[\w\W]*?<\/style>/i,inside:{tag:{pattern:/|<\/style>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.css},alias:"language-css"}}),Prism.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|').*?\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:Prism.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:Prism.languages.css}},alias:"language-css"}},Prism.languages.markup.tag)); \ No newline at end of file +Prism.languages.css={comment:/\/\*[\w\W]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(\\[\w\W]|(?!\1)[^\\\r\n])*\1|.*?)\)/i,selector:/[^\{\}\s][^\{\};]*?(?=\s*\{)/,string:/("|')(\\[\w\W]|(?!\1)[^\\\r\n])*\1/,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),Prism.languages.markup&&(Prism.languages.insertBefore("markup","tag",{style:{pattern:/[\w\W]*?<\/style>/i,inside:{tag:{pattern:/|<\/style>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.css},alias:"language-css"}}),Prism.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|').*?\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:Prism.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:Prism.languages.css}},alias:"language-css"}},Prism.languages.markup.tag)); \ No newline at end of file diff --git a/prism.js b/prism.js index 49e0a9090c..889ef42585 100644 --- a/prism.js +++ b/prism.js @@ -492,7 +492,7 @@ Prism.languages.css = { } }, 'url': /url\((?:(["'])(\\[\w\W]|(?!\1)[^\\\r\n])*\1|.*?)\)/i, - 'selector': /[^\{\}\s][^\{\};]*(?=\s*\{)/, + 'selector': /[^\{\}\s][^\{\};]*?(?=\s*\{)/, 'string': /("|')(\\[\w\W]|(?!\1)[^\\\r\n])*\1/, 'property': /(\b|\B)[\w-]+(?=\s*:)/i, 'important': /\B!important\b/i, From 15760e1805d41bbcb0ac2dd1f75312e61873c270 Mon Sep 17 00:00:00 2001 From: Golmote Date: Wed, 8 Jul 2015 20:23:32 +0200 Subject: [PATCH 085/310] C-like and CSS: Fixes for \r\n --- components/prism-clike.js | 2 +- components/prism-clike.min.js | 2 +- components/prism-css.js | 4 ++-- components/prism-css.min.js | 2 +- prism.js | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/components/prism-clike.js b/components/prism-clike.js index 7a5ba2e5dd..378742bc05 100644 --- a/components/prism-clike.js +++ b/components/prism-clike.js @@ -9,7 +9,7 @@ Prism.languages.clike = { lookbehind: true } ], - 'string': /("|')(\\[\s\S]|(?!\1)[^\\\r\n])*\1/, + 'string': /("|')(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, 'class-name': { pattern: /((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i, lookbehind: true, diff --git a/components/prism-clike.min.js b/components/prism-clike.min.js index 32ad31cfa1..de8f99a09d 100644 --- a/components/prism-clike.min.js +++ b/components/prism-clike.min.js @@ -1 +1 @@ -Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:/("|')(\\[\s\S]|(?!\1)[^\\\r\n])*\1/,"class-name":{pattern:/((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,"boolean":/\b(true|false)\b/,"function":{pattern:/[a-z0-9_]+\(/i,inside:{punctuation:/\(/}},number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,operator:/[-+]{1,2}|!|<=?|>=?|={1,3}|&{1,2}|\|?\||\?|\*|\/|~|\^|%/,ignore:/&(lt|gt|amp);/i,punctuation:/[{}[\];(),.:]/}; \ No newline at end of file +Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:/("|')(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,"class-name":{pattern:/((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,"boolean":/\b(true|false)\b/,"function":{pattern:/[a-z0-9_]+\(/i,inside:{punctuation:/\(/}},number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,operator:/[-+]{1,2}|!|<=?|>=?|={1,3}|&{1,2}|\|?\||\?|\*|\/|~|\^|%/,ignore:/&(lt|gt|amp);/i,punctuation:/[{}[\];(),.:]/}; \ No newline at end of file diff --git a/components/prism-css.js b/components/prism-css.js index 995d37e7ee..05af658a7c 100644 --- a/components/prism-css.js +++ b/components/prism-css.js @@ -7,9 +7,9 @@ Prism.languages.css = { // See rest below } }, - 'url': /url\((?:(["'])(\\[\w\W]|(?!\1)[^\\\r\n])*\1|.*?)\)/i, + 'url': /url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i, 'selector': /[^\{\}\s][^\{\};]*?(?=\s*\{)/, - 'string': /("|')(\\[\w\W]|(?!\1)[^\\\r\n])*\1/, + 'string': /("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/, 'property': /(\b|\B)[\w-]+(?=\s*:)/i, 'important': /\B!important\b/i, 'function': /[-a-z0-9]+(?=\()/i, diff --git a/components/prism-css.min.js b/components/prism-css.min.js index b320fd77ad..da88a59401 100644 --- a/components/prism-css.min.js +++ b/components/prism-css.min.js @@ -1 +1 @@ -Prism.languages.css={comment:/\/\*[\w\W]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(\\[\w\W]|(?!\1)[^\\\r\n])*\1|.*?)\)/i,selector:/[^\{\}\s][^\{\};]*?(?=\s*\{)/,string:/("|')(\\[\w\W]|(?!\1)[^\\\r\n])*\1/,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),Prism.languages.markup&&(Prism.languages.insertBefore("markup","tag",{style:{pattern:/[\w\W]*?<\/style>/i,inside:{tag:{pattern:/|<\/style>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.css},alias:"language-css"}}),Prism.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|').*?\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:Prism.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:Prism.languages.css}},alias:"language-css"}},Prism.languages.markup.tag)); \ No newline at end of file +Prism.languages.css={comment:/\/\*[\w\W]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,selector:/[^\{\}\s][^\{\};]*?(?=\s*\{)/,string:/("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/,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),Prism.languages.markup&&(Prism.languages.insertBefore("markup","tag",{style:{pattern:/[\w\W]*?<\/style>/i,inside:{tag:{pattern:/|<\/style>/i,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.css},alias:"language-css"}}),Prism.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|').*?\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:Prism.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:Prism.languages.css}},alias:"language-css"}},Prism.languages.markup.tag)); \ No newline at end of file diff --git a/prism.js b/prism.js index 889ef42585..c57d55872c 100644 --- a/prism.js +++ b/prism.js @@ -491,9 +491,9 @@ Prism.languages.css = { // See rest below } }, - 'url': /url\((?:(["'])(\\[\w\W]|(?!\1)[^\\\r\n])*\1|.*?)\)/i, + 'url': /url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i, 'selector': /[^\{\}\s][^\{\};]*?(?=\s*\{)/, - 'string': /("|')(\\[\w\W]|(?!\1)[^\\\r\n])*\1/, + 'string': /("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/, 'property': /(\b|\B)[\w-]+(?=\s*:)/i, 'important': /\B!important\b/i, 'function': /[-a-z0-9]+(?=\()/i, @@ -551,7 +551,7 @@ Prism.languages.clike = { lookbehind: true } ], - 'string': /("|')(\\[\s\S]|(?!\1)[^\\\r\n])*\1/, + 'string': /("|')(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, 'class-name': { pattern: /((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i, lookbehind: true, From b6535ddba456c5c8ae0225f8f0bec91ff477cb1e Mon Sep 17 00:00:00 2001 From: Golmote Date: Fri, 10 Jul 2015 08:07:05 +0200 Subject: [PATCH 086/310] C-like: removed unused 'ignore' pattern. --- components/prism-clike.js | 1 - components/prism-clike.min.js | 2 +- prism.js | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/components/prism-clike.js b/components/prism-clike.js index 378742bc05..57679cf2bc 100644 --- a/components/prism-clike.js +++ b/components/prism-clike.js @@ -27,6 +27,5 @@ Prism.languages.clike = { }, 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/, 'operator': /[-+]{1,2}|!|<=?|>=?|={1,3}|&{1,2}|\|?\||\?|\*|\/|~|\^|%/, - 'ignore': /&(lt|gt|amp);/i, 'punctuation': /[{}[\];(),.:]/ }; diff --git a/components/prism-clike.min.js b/components/prism-clike.min.js index de8f99a09d..abae2a8322 100644 --- a/components/prism-clike.min.js +++ b/components/prism-clike.min.js @@ -1 +1 @@ -Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:/("|')(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,"class-name":{pattern:/((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,"boolean":/\b(true|false)\b/,"function":{pattern:/[a-z0-9_]+\(/i,inside:{punctuation:/\(/}},number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,operator:/[-+]{1,2}|!|<=?|>=?|={1,3}|&{1,2}|\|?\||\?|\*|\/|~|\^|%/,ignore:/&(lt|gt|amp);/i,punctuation:/[{}[\];(),.:]/}; \ No newline at end of file +Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:/("|')(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,"class-name":{pattern:/((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,"boolean":/\b(true|false)\b/,"function":{pattern:/[a-z0-9_]+\(/i,inside:{punctuation:/\(/}},number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,operator:/[-+]{1,2}|!|<=?|>=?|={1,3}|&{1,2}|\|?\||\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/}; \ No newline at end of file diff --git a/prism.js b/prism.js index c57d55872c..bca193ab34 100644 --- a/prism.js +++ b/prism.js @@ -569,7 +569,6 @@ Prism.languages.clike = { }, 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/, 'operator': /[-+]{1,2}|!|<=?|>=?|={1,3}|&{1,2}|\|?\||\?|\*|\/|~|\^|%/, - 'ignore': /&(lt|gt|amp);/i, 'punctuation': /[{}[\];(),.:]/ }; From 6bf0794c62a80ba21cc78fa5eb12c85f7a01f234 Mon Sep 17 00:00:00 2001 From: Golmote Date: Fri, 10 Jul 2015 08:23:19 +0200 Subject: [PATCH 087/310] ActionScript: Fix ! operator and add ++ and -- as whole operators --- components/prism-actionscript.js | 2 +- components/prism-actionscript.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/prism-actionscript.js b/components/prism-actionscript.js index 66b3f7269e..62d8ee5d3f 100644 --- a/components/prism-actionscript.js +++ b/components/prism-actionscript.js @@ -4,7 +4,7 @@ Prism.languages.actionscript = Prism.languages.extend('javascript', { 'keyword': /\b(?:as|break|case|catch|class|const|default|delete|do|else|extends|finally|for|function|if|implements|import|in|instanceof|interface|internal|is|native|new|null|package|private|protected|public|return|super|switch|this|throw|try|typeof|use|var|void|while|with|dynamic|each|final|get|include|namespace|native|override|set|static)\b/, - 'operator': /(?:[+\-*\/%^]|&&?|\|\|?|<>?>?|[!=]=)=?|[=~?@]/ + 'operator': /\+\+|--|(?:[+\-*\/%^]|&&?|\|\|?|<>?>?|[!=]=?)=?|[~?@]/ }); Prism.languages.actionscript['class-name'].alias = 'function'; diff --git a/components/prism-actionscript.min.js b/components/prism-actionscript.min.js index cbe958c936..d2368bac3a 100644 --- a/components/prism-actionscript.min.js +++ b/components/prism-actionscript.min.js @@ -1 +1 @@ -Prism.languages.actionscript=Prism.languages.extend("javascript",{keyword:/\b(?:as|break|case|catch|class|const|default|delete|do|else|extends|finally|for|function|if|implements|import|in|instanceof|interface|internal|is|native|new|null|package|private|protected|public|return|super|switch|this|throw|try|typeof|use|var|void|while|with|dynamic|each|final|get|include|namespace|native|override|set|static)\b/,operator:/(?:[+\-*\/%^]|&&?|\|\|?|<>?>?|[!=]=)=?|[=~?@]/}),Prism.languages.actionscript["class-name"].alias="function",Prism.languages.markup&&Prism.languages.insertBefore("actionscript","operator",{xml:{pattern:/(^|[^.])<[\s\S]*>(?=\s*($|[\r\n,.;\]})<]))/,inside:{rest:Prism.languages.markup}}}); \ No newline at end of file +Prism.languages.actionscript=Prism.languages.extend("javascript",{keyword:/\b(?:as|break|case|catch|class|const|default|delete|do|else|extends|finally|for|function|if|implements|import|in|instanceof|interface|internal|is|native|new|null|package|private|protected|public|return|super|switch|this|throw|try|typeof|use|var|void|while|with|dynamic|each|final|get|include|namespace|native|override|set|static)\b/,operator:/\+\+|--|(?:[+\-*\/%^]|&&?|\|\|?|<>?>?|[!=]=?)=?|[~?@]/}),Prism.languages.actionscript["class-name"].alias="function",Prism.languages.markup&&Prism.languages.insertBefore("actionscript","operator",{xml:{pattern:/(^|[^.])<[\s\S]*>(?=\s*($|[\r\n,.;\]})<]))/,inside:{rest:Prism.languages.markup}}}); \ No newline at end of file From 90257b0de107ca592c3c6a44eea67fd7169c7c47 Mon Sep 17 00:00:00 2001 From: Golmote Date: Fri, 10 Jul 2015 21:49:55 +0200 Subject: [PATCH 088/310] ActionScript: Fix XML highlighting --- components/prism-actionscript.js | 9 +++------ components/prism-actionscript.min.js | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/components/prism-actionscript.js b/components/prism-actionscript.js index 62d8ee5d3f..ff5804d4d3 100644 --- a/components/prism-actionscript.js +++ b/components/prism-actionscript.js @@ -1,7 +1,3 @@ -/* TODO - Fix XML highlighting - */ - Prism.languages.actionscript = Prism.languages.extend('javascript', { 'keyword': /\b(?:as|break|case|catch|class|const|default|delete|do|else|extends|finally|for|function|if|implements|import|in|instanceof|interface|internal|is|native|new|null|package|private|protected|public|return|super|switch|this|throw|try|typeof|use|var|void|while|with|dynamic|each|final|get|include|namespace|native|override|set|static)\b/, 'operator': /\+\+|--|(?:[+\-*\/%^]|&&?|\|\|?|<>?>?|[!=]=?)=?|[~?@]/ @@ -9,9 +5,10 @@ Prism.languages.actionscript = Prism.languages.extend('javascript', { Prism.languages.actionscript['class-name'].alias = 'function'; if (Prism.languages.markup) { - Prism.languages.insertBefore('actionscript', 'operator', { + Prism.languages.insertBefore('actionscript', 'string', { 'xml': { - pattern: /(^|[^.])<[\s\S]*>(?=\s*($|[\r\n,.;\]})<]))/, + pattern: /(^|[^.])<\/?\w+(?:\s+[^\s>\/=]+=("|')(?:\\\1|\\?(?!\1)[\w\W])*\2)*\s*\/?>/, + lookbehind: true, inside: { rest: Prism.languages.markup } diff --git a/components/prism-actionscript.min.js b/components/prism-actionscript.min.js index d2368bac3a..91a859074c 100644 --- a/components/prism-actionscript.min.js +++ b/components/prism-actionscript.min.js @@ -1 +1 @@ -Prism.languages.actionscript=Prism.languages.extend("javascript",{keyword:/\b(?:as|break|case|catch|class|const|default|delete|do|else|extends|finally|for|function|if|implements|import|in|instanceof|interface|internal|is|native|new|null|package|private|protected|public|return|super|switch|this|throw|try|typeof|use|var|void|while|with|dynamic|each|final|get|include|namespace|native|override|set|static)\b/,operator:/\+\+|--|(?:[+\-*\/%^]|&&?|\|\|?|<>?>?|[!=]=?)=?|[~?@]/}),Prism.languages.actionscript["class-name"].alias="function",Prism.languages.markup&&Prism.languages.insertBefore("actionscript","operator",{xml:{pattern:/(^|[^.])<[\s\S]*>(?=\s*($|[\r\n,.;\]})<]))/,inside:{rest:Prism.languages.markup}}}); \ No newline at end of file +Prism.languages.actionscript=Prism.languages.extend("javascript",{keyword:/\b(?:as|break|case|catch|class|const|default|delete|do|else|extends|finally|for|function|if|implements|import|in|instanceof|interface|internal|is|native|new|null|package|private|protected|public|return|super|switch|this|throw|try|typeof|use|var|void|while|with|dynamic|each|final|get|include|namespace|native|override|set|static)\b/,operator:/\+\+|--|(?:[+\-*\/%^]|&&?|\|\|?|<>?>?|[!=]=?)=?|[~?@]/}),Prism.languages.actionscript["class-name"].alias="function",Prism.languages.markup&&Prism.languages.insertBefore("actionscript","string",{xml:{pattern:/(^|[^.])<\/?\w+(?:\s+[^\s>\/=]+=("|')(?:\\\1|\\?(?!\1)[\w\W])*\2)*\s*\/?>/,lookbehind:!0,inside:{rest:Prism.languages.markup}}}); \ No newline at end of file From 2c1626a731321b55a38c7a8ba2d142641d65a29d Mon Sep 17 00:00:00 2001 From: Golmote Date: Fri, 10 Jul 2015 22:01:06 +0200 Subject: [PATCH 089/310] ActionScript: Update examples to add inline XML --- examples/prism-actionscript.html | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/examples/prism-actionscript.html b/examples/prism-actionscript.html index cf4e33462e..416bae2f7e 100644 --- a/examples/prism-actionscript.html +++ b/examples/prism-actionscript.html @@ -19,6 +19,29 @@

Classes

class A {}
 class B extends A {}
+

Inline XML

+
var employees:XML =
+    <employees>
+        <employee ssn="123-123-1234">
+            <name first="John" last="Doe"/>
+            <address>
+                <street>11 Main St.</street>
+                <city>San Francisco</city>
+                <state>CA</state>
+                <zip>98765</zip>
+            </address>
+        </employee>
+        <employee ssn="789-789-7890">
+            <name first="Mary" last="Roe"/>
+            <address>
+                <street>99 Broad St.</street>
+                <city>Newton</city>
+                <state>MA</state>
+                <zip>01234</zip>
+            </address>
+        </employee>
+    </employees>;
+

Full example

package {
   import flash.display.*;

From 39877114faecb0235f6e19e35686572a4eee07fa Mon Sep 17 00:00:00 2001
From: Golmote 
Date: Fri, 10 Jul 2015 22:04:05 +0200
Subject: [PATCH 090/310] ActionScript: Update examples to add inline XML

---
 examples/prism-actionscript.html | 2 --
 1 file changed, 2 deletions(-)

diff --git a/examples/prism-actionscript.html b/examples/prism-actionscript.html
index 416bae2f7e..5c3f297f8c 100644
--- a/examples/prism-actionscript.html
+++ b/examples/prism-actionscript.html
@@ -25,7 +25,6 @@ 

Inline XML

<employee ssn="123-123-1234"> <name first="John" last="Doe"/> <address> - <street>11 Main St.</street> <city>San Francisco</city> <state>CA</state> <zip>98765</zip> @@ -34,7 +33,6 @@

Inline XML

<employee ssn="789-789-7890"> <name first="Mary" last="Roe"/> <address> - <street>99 Broad St.</street> <city>Newton</city> <state>MA</state> <zip>01234</zip> From e87efd8bd703542aabf8c6cb0d6f91d13e2c6970 Mon Sep 17 00:00:00 2001 From: Golmote Date: Fri, 10 Jul 2015 22:21:08 +0200 Subject: [PATCH 091/310] Apacheconf: don't include the spaces in directive-inline --- components/prism-apacheconf.js | 3 ++- components/prism-apacheconf.min.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/components/prism-apacheconf.js b/components/prism-apacheconf.js index 8fac6dfc09..31db26bfd6 100644 --- a/components/prism-apacheconf.js +++ b/components/prism-apacheconf.js @@ -1,7 +1,8 @@ Prism.languages.apacheconf = { 'comment': /#.*/, 'directive-inline': { - pattern: /^\s*\b(AcceptFilter|AcceptPathInfo|AccessFileName|Action|AddAlt|AddAltByEncoding|AddAltByType|AddCharset|AddDefaultCharset|AddDescription|AddEncoding|AddHandler|AddIcon|AddIconByEncoding|AddIconByType|AddInputFilter|AddLanguage|AddModuleInfo|AddOutputFilter|AddOutputFilterByType|AddType|Alias|AliasMatch|Allow|AllowCONNECT|AllowEncodedSlashes|AllowMethods|AllowOverride|AllowOverrideList|Anonymous|Anonymous_LogEmail|Anonymous_MustGiveEmail|Anonymous_NoUserID|Anonymous_VerifyEmail|AsyncRequestWorkerFactor|AuthBasicAuthoritative|AuthBasicFake|AuthBasicProvider|AuthBasicUseDigestAlgorithm|AuthDBDUserPWQuery|AuthDBDUserRealmQuery|AuthDBMGroupFile|AuthDBMType|AuthDBMUserFile|AuthDigestAlgorithm|AuthDigestDomain|AuthDigestNonceLifetime|AuthDigestProvider|AuthDigestQop|AuthDigestShmemSize|AuthFormAuthoritative|AuthFormBody|AuthFormDisableNoStore|AuthFormFakeBasicAuth|AuthFormLocation|AuthFormLoginRequiredLocation|AuthFormLoginSuccessLocation|AuthFormLogoutLocation|AuthFormMethod|AuthFormMimetype|AuthFormPassword|AuthFormProvider|AuthFormSitePassphrase|AuthFormSize|AuthFormUsername|AuthGroupFile|AuthLDAPAuthorizePrefix|AuthLDAPBindAuthoritative|AuthLDAPBindDN|AuthLDAPBindPassword|AuthLDAPCharsetConfig|AuthLDAPCompareAsUser|AuthLDAPCompareDNOnServer|AuthLDAPDereferenceAliases|AuthLDAPGroupAttribute|AuthLDAPGroupAttributeIsDN|AuthLDAPInitialBindAsUser|AuthLDAPInitialBindPattern|AuthLDAPMaxSubGroupDepth|AuthLDAPRemoteUserAttribute|AuthLDAPRemoteUserIsDN|AuthLDAPSearchAsUser|AuthLDAPSubGroupAttribute|AuthLDAPSubGroupClass|AuthLDAPUrl|AuthMerging|AuthName|AuthnCacheContext|AuthnCacheEnable|AuthnCacheProvideFor|AuthnCacheSOCache|AuthnCacheTimeout|AuthnzFcgiCheckAuthnProvider|AuthnzFcgiDefineProvider|AuthType|AuthUserFile|AuthzDBDLoginToReferer|AuthzDBDQuery|AuthzDBDRedirectQuery|AuthzDBMType|AuthzSendForbiddenOnFailure|BalancerGrowth|BalancerInherit|BalancerMember|BalancerPersist|BrowserMatch|BrowserMatchNoCase|BufferedLogs|BufferSize|CacheDefaultExpire|CacheDetailHeader|CacheDirLength|CacheDirLevels|CacheDisable|CacheEnable|CacheFile|CacheHeader|CacheIgnoreCacheControl|CacheIgnoreHeaders|CacheIgnoreNoLastMod|CacheIgnoreQueryString|CacheIgnoreURLSessionIdentifiers|CacheKeyBaseURL|CacheLastModifiedFactor|CacheLock|CacheLockMaxAge|CacheLockPath|CacheMaxExpire|CacheMaxFileSize|CacheMinExpire|CacheMinFileSize|CacheNegotiatedDocs|CacheQuickHandler|CacheReadSize|CacheReadTime|CacheRoot|CacheSocache|CacheSocacheMaxSize|CacheSocacheMaxTime|CacheSocacheMinTime|CacheSocacheReadSize|CacheSocacheReadTime|CacheStaleOnError|CacheStoreExpired|CacheStoreNoStore|CacheStorePrivate|CGIDScriptTimeout|CGIMapExtension|CharsetDefault|CharsetOptions|CharsetSourceEnc|CheckCaseOnly|CheckSpelling|ChrootDir|ContentDigest|CookieDomain|CookieExpires|CookieName|CookieStyle|CookieTracking|CoreDumpDirectory|CustomLog|Dav|DavDepthInfinity|DavGenericLockDB|DavLockDB|DavMinTimeout|DBDExptime|DBDInitSQL|DBDKeep|DBDMax|DBDMin|DBDParams|DBDPersist|DBDPrepareSQL|DBDriver|DefaultIcon|DefaultLanguage|DefaultRuntimeDir|DefaultType|Define|DeflateBufferSize|DeflateCompressionLevel|DeflateFilterNote|DeflateInflateLimitRequestBody|DeflateInflateRatioBurst|DeflateInflateRatioLimit|DeflateMemLevel|DeflateWindowSize|Deny|DirectoryCheckHandler|DirectoryIndex|DirectoryIndexRedirect|DirectorySlash|DocumentRoot|DTracePrivileges|DumpIOInput|DumpIOOutput|EnableExceptionHook|EnableMMAP|EnableSendfile|Error|ErrorDocument|ErrorLog|ErrorLogFormat|Example|ExpiresActive|ExpiresByType|ExpiresDefault|ExtendedStatus|ExtFilterDefine|ExtFilterOptions|FallbackResource|FileETag|FilterChain|FilterDeclare|FilterProtocol|FilterProvider|FilterTrace|ForceLanguagePriority|ForceType|ForensicLog|GprofDir|GracefulShutdownTimeout|Group|Header|HeaderName|HeartbeatAddress|HeartbeatListen|HeartbeatMaxServers|HeartbeatStorage|HeartbeatStorage|HostnameLookups|IdentityCheck|IdentityCheckTimeout|ImapBase|ImapDefault|ImapMenu|Include|IncludeOptional|IndexHeadInsert|IndexIgnore|IndexIgnoreReset|IndexOptions|IndexOrderDefault|IndexStyleSheet|InputSed|ISAPIAppendLogToErrors|ISAPIAppendLogToQuery|ISAPICacheFile|ISAPIFakeAsync|ISAPILogNotSupported|ISAPIReadAheadBuffer|KeepAlive|KeepAliveTimeout|KeptBodySize|LanguagePriority|LDAPCacheEntries|LDAPCacheTTL|LDAPConnectionPoolTTL|LDAPConnectionTimeout|LDAPLibraryDebug|LDAPOpCacheEntries|LDAPOpCacheTTL|LDAPReferralHopLimit|LDAPReferrals|LDAPRetries|LDAPRetryDelay|LDAPSharedCacheFile|LDAPSharedCacheSize|LDAPTimeout|LDAPTrustedClientCert|LDAPTrustedGlobalCert|LDAPTrustedMode|LDAPVerifyServerCert|LimitInternalRecursion|LimitRequestBody|LimitRequestFields|LimitRequestFieldSize|LimitRequestLine|LimitXMLRequestBody|Listen|ListenBackLog|LoadFile|LoadModule|LogFormat|LogLevel|LogMessage|LuaAuthzProvider|LuaCodeCache|LuaHookAccessChecker|LuaHookAuthChecker|LuaHookCheckUserID|LuaHookFixups|LuaHookInsertFilter|LuaHookLog|LuaHookMapToStorage|LuaHookTranslateName|LuaHookTypeChecker|LuaInherit|LuaInputFilter|LuaMapHandler|LuaOutputFilter|LuaPackageCPath|LuaPackagePath|LuaQuickHandler|LuaRoot|LuaScope|MaxConnectionsPerChild|MaxKeepAliveRequests|MaxMemFree|MaxRangeOverlaps|MaxRangeReversals|MaxRanges|MaxRequestWorkers|MaxSpareServers|MaxSpareThreads|MaxThreads|MergeTrailers|MetaDir|MetaFiles|MetaSuffix|MimeMagicFile|MinSpareServers|MinSpareThreads|MMapFile|ModemStandard|ModMimeUsePathInfo|MultiviewsMatch|Mutex|NameVirtualHost|NoProxy|NWSSLTrustedCerts|NWSSLUpgradeable|Options|Order|OutputSed|PassEnv|PidFile|PrivilegesMode|Protocol|ProtocolEcho|ProxyAddHeaders|ProxyBadHeader|ProxyBlock|ProxyDomain|ProxyErrorOverride|ProxyExpressDBMFile|ProxyExpressDBMType|ProxyExpressEnable|ProxyFtpDirCharset|ProxyFtpEscapeWildcards|ProxyFtpListOnWildcard|ProxyHTMLBufSize|ProxyHTMLCharsetOut|ProxyHTMLDocType|ProxyHTMLEnable|ProxyHTMLEvents|ProxyHTMLExtended|ProxyHTMLFixups|ProxyHTMLInterp|ProxyHTMLLinks|ProxyHTMLMeta|ProxyHTMLStripComments|ProxyHTMLURLMap|ProxyIOBufferSize|ProxyMaxForwards|ProxyPass|ProxyPassInherit|ProxyPassInterpolateEnv|ProxyPassMatch|ProxyPassReverse|ProxyPassReverseCookieDomain|ProxyPassReverseCookiePath|ProxyPreserveHost|ProxyReceiveBufferSize|ProxyRemote|ProxyRemoteMatch|ProxyRequests|ProxySCGIInternalRedirect|ProxySCGISendfile|ProxySet|ProxySourceAddress|ProxyStatus|ProxyTimeout|ProxyVia|ReadmeName|ReceiveBufferSize|Redirect|RedirectMatch|RedirectPermanent|RedirectTemp|ReflectorHeader|RemoteIPHeader|RemoteIPInternalProxy|RemoteIPInternalProxyList|RemoteIPProxiesHeader|RemoteIPTrustedProxy|RemoteIPTrustedProxyList|RemoveCharset|RemoveEncoding|RemoveHandler|RemoveInputFilter|RemoveLanguage|RemoveOutputFilter|RemoveType|RequestHeader|RequestReadTimeout|Require|RewriteBase|RewriteCond|RewriteEngine|RewriteMap|RewriteOptions|RewriteRule|RLimitCPU|RLimitMEM|RLimitNPROC|Satisfy|ScoreBoardFile|Script|ScriptAlias|ScriptAliasMatch|ScriptInterpreterSource|ScriptLog|ScriptLogBuffer|ScriptLogLength|ScriptSock|SecureListen|SeeRequestTail|SendBufferSize|ServerAdmin|ServerAlias|ServerLimit|ServerName|ServerPath|ServerRoot|ServerSignature|ServerTokens|Session|SessionCookieName|SessionCookieName2|SessionCookieRemove|SessionCryptoCipher|SessionCryptoDriver|SessionCryptoPassphrase|SessionCryptoPassphraseFile|SessionDBDCookieName|SessionDBDCookieName2|SessionDBDCookieRemove|SessionDBDDeleteLabel|SessionDBDInsertLabel|SessionDBDPerUser|SessionDBDSelectLabel|SessionDBDUpdateLabel|SessionEnv|SessionExclude|SessionHeader|SessionInclude|SessionMaxAge|SetEnv|SetEnvIf|SetEnvIfExpr|SetEnvIfNoCase|SetHandler|SetInputFilter|SetOutputFilter|SSIEndTag|SSIErrorMsg|SSIETag|SSILastModified|SSILegacyExprParser|SSIStartTag|SSITimeFormat|SSIUndefinedEcho|SSLCACertificateFile|SSLCACertificatePath|SSLCADNRequestFile|SSLCADNRequestPath|SSLCARevocationCheck|SSLCARevocationFile|SSLCARevocationPath|SSLCertificateChainFile|SSLCertificateFile|SSLCertificateKeyFile|SSLCipherSuite|SSLCompression|SSLCryptoDevice|SSLEngine|SSLFIPS|SSLHonorCipherOrder|SSLInsecureRenegotiation|SSLOCSPDefaultResponder|SSLOCSPEnable|SSLOCSPOverrideResponder|SSLOCSPResponderTimeout|SSLOCSPResponseMaxAge|SSLOCSPResponseTimeSkew|SSLOCSPUseRequestNonce|SSLOpenSSLConfCmd|SSLOptions|SSLPassPhraseDialog|SSLProtocol|SSLProxyCACertificateFile|SSLProxyCACertificatePath|SSLProxyCARevocationCheck|SSLProxyCARevocationFile|SSLProxyCARevocationPath|SSLProxyCheckPeerCN|SSLProxyCheckPeerExpire|SSLProxyCheckPeerName|SSLProxyCipherSuite|SSLProxyEngine|SSLProxyMachineCertificateChainFile|SSLProxyMachineCertificateFile|SSLProxyMachineCertificatePath|SSLProxyProtocol|SSLProxyVerify|SSLProxyVerifyDepth|SSLRandomSeed|SSLRenegBufferSize|SSLRequire|SSLRequireSSL|SSLSessionCache|SSLSessionCacheTimeout|SSLSessionTicketKeyFile|SSLSRPUnknownUserSeed|SSLSRPVerifierFile|SSLStaplingCache|SSLStaplingErrorCacheTimeout|SSLStaplingFakeTryLater|SSLStaplingForceURL|SSLStaplingResponderTimeout|SSLStaplingResponseMaxAge|SSLStaplingResponseTimeSkew|SSLStaplingReturnResponderErrors|SSLStaplingStandardCacheTimeout|SSLStrictSNIVHostCheck|SSLUserName|SSLUseStapling|SSLVerifyClient|SSLVerifyDepth|StartServers|StartThreads|Substitute|Suexec|SuexecUserGroup|ThreadLimit|ThreadsPerChild|ThreadStackSize|TimeOut|TraceEnable|TransferLog|TypesConfig|UnDefine|UndefMacro|UnsetEnv|Use|UseCanonicalName|UseCanonicalPhysicalPort|User|UserDir|VHostCGIMode|VHostCGIPrivs|VHostGroup|VHostPrivs|VHostSecure|VHostUser|VirtualDocumentRoot|VirtualDocumentRootIP|VirtualScriptAlias|VirtualScriptAliasIP|WatchdogInterval|XBitHack|xml2EncAlias|xml2EncDefault|xml2StartParse)\b/mi, + pattern: /^(\s*)\b(AcceptFilter|AcceptPathInfo|AccessFileName|Action|AddAlt|AddAltByEncoding|AddAltByType|AddCharset|AddDefaultCharset|AddDescription|AddEncoding|AddHandler|AddIcon|AddIconByEncoding|AddIconByType|AddInputFilter|AddLanguage|AddModuleInfo|AddOutputFilter|AddOutputFilterByType|AddType|Alias|AliasMatch|Allow|AllowCONNECT|AllowEncodedSlashes|AllowMethods|AllowOverride|AllowOverrideList|Anonymous|Anonymous_LogEmail|Anonymous_MustGiveEmail|Anonymous_NoUserID|Anonymous_VerifyEmail|AsyncRequestWorkerFactor|AuthBasicAuthoritative|AuthBasicFake|AuthBasicProvider|AuthBasicUseDigestAlgorithm|AuthDBDUserPWQuery|AuthDBDUserRealmQuery|AuthDBMGroupFile|AuthDBMType|AuthDBMUserFile|AuthDigestAlgorithm|AuthDigestDomain|AuthDigestNonceLifetime|AuthDigestProvider|AuthDigestQop|AuthDigestShmemSize|AuthFormAuthoritative|AuthFormBody|AuthFormDisableNoStore|AuthFormFakeBasicAuth|AuthFormLocation|AuthFormLoginRequiredLocation|AuthFormLoginSuccessLocation|AuthFormLogoutLocation|AuthFormMethod|AuthFormMimetype|AuthFormPassword|AuthFormProvider|AuthFormSitePassphrase|AuthFormSize|AuthFormUsername|AuthGroupFile|AuthLDAPAuthorizePrefix|AuthLDAPBindAuthoritative|AuthLDAPBindDN|AuthLDAPBindPassword|AuthLDAPCharsetConfig|AuthLDAPCompareAsUser|AuthLDAPCompareDNOnServer|AuthLDAPDereferenceAliases|AuthLDAPGroupAttribute|AuthLDAPGroupAttributeIsDN|AuthLDAPInitialBindAsUser|AuthLDAPInitialBindPattern|AuthLDAPMaxSubGroupDepth|AuthLDAPRemoteUserAttribute|AuthLDAPRemoteUserIsDN|AuthLDAPSearchAsUser|AuthLDAPSubGroupAttribute|AuthLDAPSubGroupClass|AuthLDAPUrl|AuthMerging|AuthName|AuthnCacheContext|AuthnCacheEnable|AuthnCacheProvideFor|AuthnCacheSOCache|AuthnCacheTimeout|AuthnzFcgiCheckAuthnProvider|AuthnzFcgiDefineProvider|AuthType|AuthUserFile|AuthzDBDLoginToReferer|AuthzDBDQuery|AuthzDBDRedirectQuery|AuthzDBMType|AuthzSendForbiddenOnFailure|BalancerGrowth|BalancerInherit|BalancerMember|BalancerPersist|BrowserMatch|BrowserMatchNoCase|BufferedLogs|BufferSize|CacheDefaultExpire|CacheDetailHeader|CacheDirLength|CacheDirLevels|CacheDisable|CacheEnable|CacheFile|CacheHeader|CacheIgnoreCacheControl|CacheIgnoreHeaders|CacheIgnoreNoLastMod|CacheIgnoreQueryString|CacheIgnoreURLSessionIdentifiers|CacheKeyBaseURL|CacheLastModifiedFactor|CacheLock|CacheLockMaxAge|CacheLockPath|CacheMaxExpire|CacheMaxFileSize|CacheMinExpire|CacheMinFileSize|CacheNegotiatedDocs|CacheQuickHandler|CacheReadSize|CacheReadTime|CacheRoot|CacheSocache|CacheSocacheMaxSize|CacheSocacheMaxTime|CacheSocacheMinTime|CacheSocacheReadSize|CacheSocacheReadTime|CacheStaleOnError|CacheStoreExpired|CacheStoreNoStore|CacheStorePrivate|CGIDScriptTimeout|CGIMapExtension|CharsetDefault|CharsetOptions|CharsetSourceEnc|CheckCaseOnly|CheckSpelling|ChrootDir|ContentDigest|CookieDomain|CookieExpires|CookieName|CookieStyle|CookieTracking|CoreDumpDirectory|CustomLog|Dav|DavDepthInfinity|DavGenericLockDB|DavLockDB|DavMinTimeout|DBDExptime|DBDInitSQL|DBDKeep|DBDMax|DBDMin|DBDParams|DBDPersist|DBDPrepareSQL|DBDriver|DefaultIcon|DefaultLanguage|DefaultRuntimeDir|DefaultType|Define|DeflateBufferSize|DeflateCompressionLevel|DeflateFilterNote|DeflateInflateLimitRequestBody|DeflateInflateRatioBurst|DeflateInflateRatioLimit|DeflateMemLevel|DeflateWindowSize|Deny|DirectoryCheckHandler|DirectoryIndex|DirectoryIndexRedirect|DirectorySlash|DocumentRoot|DTracePrivileges|DumpIOInput|DumpIOOutput|EnableExceptionHook|EnableMMAP|EnableSendfile|Error|ErrorDocument|ErrorLog|ErrorLogFormat|Example|ExpiresActive|ExpiresByType|ExpiresDefault|ExtendedStatus|ExtFilterDefine|ExtFilterOptions|FallbackResource|FileETag|FilterChain|FilterDeclare|FilterProtocol|FilterProvider|FilterTrace|ForceLanguagePriority|ForceType|ForensicLog|GprofDir|GracefulShutdownTimeout|Group|Header|HeaderName|HeartbeatAddress|HeartbeatListen|HeartbeatMaxServers|HeartbeatStorage|HeartbeatStorage|HostnameLookups|IdentityCheck|IdentityCheckTimeout|ImapBase|ImapDefault|ImapMenu|Include|IncludeOptional|IndexHeadInsert|IndexIgnore|IndexIgnoreReset|IndexOptions|IndexOrderDefault|IndexStyleSheet|InputSed|ISAPIAppendLogToErrors|ISAPIAppendLogToQuery|ISAPICacheFile|ISAPIFakeAsync|ISAPILogNotSupported|ISAPIReadAheadBuffer|KeepAlive|KeepAliveTimeout|KeptBodySize|LanguagePriority|LDAPCacheEntries|LDAPCacheTTL|LDAPConnectionPoolTTL|LDAPConnectionTimeout|LDAPLibraryDebug|LDAPOpCacheEntries|LDAPOpCacheTTL|LDAPReferralHopLimit|LDAPReferrals|LDAPRetries|LDAPRetryDelay|LDAPSharedCacheFile|LDAPSharedCacheSize|LDAPTimeout|LDAPTrustedClientCert|LDAPTrustedGlobalCert|LDAPTrustedMode|LDAPVerifyServerCert|LimitInternalRecursion|LimitRequestBody|LimitRequestFields|LimitRequestFieldSize|LimitRequestLine|LimitXMLRequestBody|Listen|ListenBackLog|LoadFile|LoadModule|LogFormat|LogLevel|LogMessage|LuaAuthzProvider|LuaCodeCache|LuaHookAccessChecker|LuaHookAuthChecker|LuaHookCheckUserID|LuaHookFixups|LuaHookInsertFilter|LuaHookLog|LuaHookMapToStorage|LuaHookTranslateName|LuaHookTypeChecker|LuaInherit|LuaInputFilter|LuaMapHandler|LuaOutputFilter|LuaPackageCPath|LuaPackagePath|LuaQuickHandler|LuaRoot|LuaScope|MaxConnectionsPerChild|MaxKeepAliveRequests|MaxMemFree|MaxRangeOverlaps|MaxRangeReversals|MaxRanges|MaxRequestWorkers|MaxSpareServers|MaxSpareThreads|MaxThreads|MergeTrailers|MetaDir|MetaFiles|MetaSuffix|MimeMagicFile|MinSpareServers|MinSpareThreads|MMapFile|ModemStandard|ModMimeUsePathInfo|MultiviewsMatch|Mutex|NameVirtualHost|NoProxy|NWSSLTrustedCerts|NWSSLUpgradeable|Options|Order|OutputSed|PassEnv|PidFile|PrivilegesMode|Protocol|ProtocolEcho|ProxyAddHeaders|ProxyBadHeader|ProxyBlock|ProxyDomain|ProxyErrorOverride|ProxyExpressDBMFile|ProxyExpressDBMType|ProxyExpressEnable|ProxyFtpDirCharset|ProxyFtpEscapeWildcards|ProxyFtpListOnWildcard|ProxyHTMLBufSize|ProxyHTMLCharsetOut|ProxyHTMLDocType|ProxyHTMLEnable|ProxyHTMLEvents|ProxyHTMLExtended|ProxyHTMLFixups|ProxyHTMLInterp|ProxyHTMLLinks|ProxyHTMLMeta|ProxyHTMLStripComments|ProxyHTMLURLMap|ProxyIOBufferSize|ProxyMaxForwards|ProxyPass|ProxyPassInherit|ProxyPassInterpolateEnv|ProxyPassMatch|ProxyPassReverse|ProxyPassReverseCookieDomain|ProxyPassReverseCookiePath|ProxyPreserveHost|ProxyReceiveBufferSize|ProxyRemote|ProxyRemoteMatch|ProxyRequests|ProxySCGIInternalRedirect|ProxySCGISendfile|ProxySet|ProxySourceAddress|ProxyStatus|ProxyTimeout|ProxyVia|ReadmeName|ReceiveBufferSize|Redirect|RedirectMatch|RedirectPermanent|RedirectTemp|ReflectorHeader|RemoteIPHeader|RemoteIPInternalProxy|RemoteIPInternalProxyList|RemoteIPProxiesHeader|RemoteIPTrustedProxy|RemoteIPTrustedProxyList|RemoveCharset|RemoveEncoding|RemoveHandler|RemoveInputFilter|RemoveLanguage|RemoveOutputFilter|RemoveType|RequestHeader|RequestReadTimeout|Require|RewriteBase|RewriteCond|RewriteEngine|RewriteMap|RewriteOptions|RewriteRule|RLimitCPU|RLimitMEM|RLimitNPROC|Satisfy|ScoreBoardFile|Script|ScriptAlias|ScriptAliasMatch|ScriptInterpreterSource|ScriptLog|ScriptLogBuffer|ScriptLogLength|ScriptSock|SecureListen|SeeRequestTail|SendBufferSize|ServerAdmin|ServerAlias|ServerLimit|ServerName|ServerPath|ServerRoot|ServerSignature|ServerTokens|Session|SessionCookieName|SessionCookieName2|SessionCookieRemove|SessionCryptoCipher|SessionCryptoDriver|SessionCryptoPassphrase|SessionCryptoPassphraseFile|SessionDBDCookieName|SessionDBDCookieName2|SessionDBDCookieRemove|SessionDBDDeleteLabel|SessionDBDInsertLabel|SessionDBDPerUser|SessionDBDSelectLabel|SessionDBDUpdateLabel|SessionEnv|SessionExclude|SessionHeader|SessionInclude|SessionMaxAge|SetEnv|SetEnvIf|SetEnvIfExpr|SetEnvIfNoCase|SetHandler|SetInputFilter|SetOutputFilter|SSIEndTag|SSIErrorMsg|SSIETag|SSILastModified|SSILegacyExprParser|SSIStartTag|SSITimeFormat|SSIUndefinedEcho|SSLCACertificateFile|SSLCACertificatePath|SSLCADNRequestFile|SSLCADNRequestPath|SSLCARevocationCheck|SSLCARevocationFile|SSLCARevocationPath|SSLCertificateChainFile|SSLCertificateFile|SSLCertificateKeyFile|SSLCipherSuite|SSLCompression|SSLCryptoDevice|SSLEngine|SSLFIPS|SSLHonorCipherOrder|SSLInsecureRenegotiation|SSLOCSPDefaultResponder|SSLOCSPEnable|SSLOCSPOverrideResponder|SSLOCSPResponderTimeout|SSLOCSPResponseMaxAge|SSLOCSPResponseTimeSkew|SSLOCSPUseRequestNonce|SSLOpenSSLConfCmd|SSLOptions|SSLPassPhraseDialog|SSLProtocol|SSLProxyCACertificateFile|SSLProxyCACertificatePath|SSLProxyCARevocationCheck|SSLProxyCARevocationFile|SSLProxyCARevocationPath|SSLProxyCheckPeerCN|SSLProxyCheckPeerExpire|SSLProxyCheckPeerName|SSLProxyCipherSuite|SSLProxyEngine|SSLProxyMachineCertificateChainFile|SSLProxyMachineCertificateFile|SSLProxyMachineCertificatePath|SSLProxyProtocol|SSLProxyVerify|SSLProxyVerifyDepth|SSLRandomSeed|SSLRenegBufferSize|SSLRequire|SSLRequireSSL|SSLSessionCache|SSLSessionCacheTimeout|SSLSessionTicketKeyFile|SSLSRPUnknownUserSeed|SSLSRPVerifierFile|SSLStaplingCache|SSLStaplingErrorCacheTimeout|SSLStaplingFakeTryLater|SSLStaplingForceURL|SSLStaplingResponderTimeout|SSLStaplingResponseMaxAge|SSLStaplingResponseTimeSkew|SSLStaplingReturnResponderErrors|SSLStaplingStandardCacheTimeout|SSLStrictSNIVHostCheck|SSLUserName|SSLUseStapling|SSLVerifyClient|SSLVerifyDepth|StartServers|StartThreads|Substitute|Suexec|SuexecUserGroup|ThreadLimit|ThreadsPerChild|ThreadStackSize|TimeOut|TraceEnable|TransferLog|TypesConfig|UnDefine|UndefMacro|UnsetEnv|Use|UseCanonicalName|UseCanonicalPhysicalPort|User|UserDir|VHostCGIMode|VHostCGIPrivs|VHostGroup|VHostPrivs|VHostSecure|VHostUser|VirtualDocumentRoot|VirtualDocumentRootIP|VirtualScriptAlias|VirtualScriptAliasIP|WatchdogInterval|XBitHack|xml2EncAlias|xml2EncDefault|xml2StartParse)\b/mi, + lookbehind: true, alias: 'property' }, 'directive-block': { diff --git a/components/prism-apacheconf.min.js b/components/prism-apacheconf.min.js index 6ccefa7d74..05577c5be3 100644 --- a/components/prism-apacheconf.min.js +++ b/components/prism-apacheconf.min.js @@ -1 +1 @@ -Prism.languages.apacheconf={comment:/#.*/,"directive-inline":{pattern:/^\s*\b(AcceptFilter|AcceptPathInfo|AccessFileName|Action|AddAlt|AddAltByEncoding|AddAltByType|AddCharset|AddDefaultCharset|AddDescription|AddEncoding|AddHandler|AddIcon|AddIconByEncoding|AddIconByType|AddInputFilter|AddLanguage|AddModuleInfo|AddOutputFilter|AddOutputFilterByType|AddType|Alias|AliasMatch|Allow|AllowCONNECT|AllowEncodedSlashes|AllowMethods|AllowOverride|AllowOverrideList|Anonymous|Anonymous_LogEmail|Anonymous_MustGiveEmail|Anonymous_NoUserID|Anonymous_VerifyEmail|AsyncRequestWorkerFactor|AuthBasicAuthoritative|AuthBasicFake|AuthBasicProvider|AuthBasicUseDigestAlgorithm|AuthDBDUserPWQuery|AuthDBDUserRealmQuery|AuthDBMGroupFile|AuthDBMType|AuthDBMUserFile|AuthDigestAlgorithm|AuthDigestDomain|AuthDigestNonceLifetime|AuthDigestProvider|AuthDigestQop|AuthDigestShmemSize|AuthFormAuthoritative|AuthFormBody|AuthFormDisableNoStore|AuthFormFakeBasicAuth|AuthFormLocation|AuthFormLoginRequiredLocation|AuthFormLoginSuccessLocation|AuthFormLogoutLocation|AuthFormMethod|AuthFormMimetype|AuthFormPassword|AuthFormProvider|AuthFormSitePassphrase|AuthFormSize|AuthFormUsername|AuthGroupFile|AuthLDAPAuthorizePrefix|AuthLDAPBindAuthoritative|AuthLDAPBindDN|AuthLDAPBindPassword|AuthLDAPCharsetConfig|AuthLDAPCompareAsUser|AuthLDAPCompareDNOnServer|AuthLDAPDereferenceAliases|AuthLDAPGroupAttribute|AuthLDAPGroupAttributeIsDN|AuthLDAPInitialBindAsUser|AuthLDAPInitialBindPattern|AuthLDAPMaxSubGroupDepth|AuthLDAPRemoteUserAttribute|AuthLDAPRemoteUserIsDN|AuthLDAPSearchAsUser|AuthLDAPSubGroupAttribute|AuthLDAPSubGroupClass|AuthLDAPUrl|AuthMerging|AuthName|AuthnCacheContext|AuthnCacheEnable|AuthnCacheProvideFor|AuthnCacheSOCache|AuthnCacheTimeout|AuthnzFcgiCheckAuthnProvider|AuthnzFcgiDefineProvider|AuthType|AuthUserFile|AuthzDBDLoginToReferer|AuthzDBDQuery|AuthzDBDRedirectQuery|AuthzDBMType|AuthzSendForbiddenOnFailure|BalancerGrowth|BalancerInherit|BalancerMember|BalancerPersist|BrowserMatch|BrowserMatchNoCase|BufferedLogs|BufferSize|CacheDefaultExpire|CacheDetailHeader|CacheDirLength|CacheDirLevels|CacheDisable|CacheEnable|CacheFile|CacheHeader|CacheIgnoreCacheControl|CacheIgnoreHeaders|CacheIgnoreNoLastMod|CacheIgnoreQueryString|CacheIgnoreURLSessionIdentifiers|CacheKeyBaseURL|CacheLastModifiedFactor|CacheLock|CacheLockMaxAge|CacheLockPath|CacheMaxExpire|CacheMaxFileSize|CacheMinExpire|CacheMinFileSize|CacheNegotiatedDocs|CacheQuickHandler|CacheReadSize|CacheReadTime|CacheRoot|CacheSocache|CacheSocacheMaxSize|CacheSocacheMaxTime|CacheSocacheMinTime|CacheSocacheReadSize|CacheSocacheReadTime|CacheStaleOnError|CacheStoreExpired|CacheStoreNoStore|CacheStorePrivate|CGIDScriptTimeout|CGIMapExtension|CharsetDefault|CharsetOptions|CharsetSourceEnc|CheckCaseOnly|CheckSpelling|ChrootDir|ContentDigest|CookieDomain|CookieExpires|CookieName|CookieStyle|CookieTracking|CoreDumpDirectory|CustomLog|Dav|DavDepthInfinity|DavGenericLockDB|DavLockDB|DavMinTimeout|DBDExptime|DBDInitSQL|DBDKeep|DBDMax|DBDMin|DBDParams|DBDPersist|DBDPrepareSQL|DBDriver|DefaultIcon|DefaultLanguage|DefaultRuntimeDir|DefaultType|Define|DeflateBufferSize|DeflateCompressionLevel|DeflateFilterNote|DeflateInflateLimitRequestBody|DeflateInflateRatioBurst|DeflateInflateRatioLimit|DeflateMemLevel|DeflateWindowSize|Deny|DirectoryCheckHandler|DirectoryIndex|DirectoryIndexRedirect|DirectorySlash|DocumentRoot|DTracePrivileges|DumpIOInput|DumpIOOutput|EnableExceptionHook|EnableMMAP|EnableSendfile|Error|ErrorDocument|ErrorLog|ErrorLogFormat|Example|ExpiresActive|ExpiresByType|ExpiresDefault|ExtendedStatus|ExtFilterDefine|ExtFilterOptions|FallbackResource|FileETag|FilterChain|FilterDeclare|FilterProtocol|FilterProvider|FilterTrace|ForceLanguagePriority|ForceType|ForensicLog|GprofDir|GracefulShutdownTimeout|Group|Header|HeaderName|HeartbeatAddress|HeartbeatListen|HeartbeatMaxServers|HeartbeatStorage|HeartbeatStorage|HostnameLookups|IdentityCheck|IdentityCheckTimeout|ImapBase|ImapDefault|ImapMenu|Include|IncludeOptional|IndexHeadInsert|IndexIgnore|IndexIgnoreReset|IndexOptions|IndexOrderDefault|IndexStyleSheet|InputSed|ISAPIAppendLogToErrors|ISAPIAppendLogToQuery|ISAPICacheFile|ISAPIFakeAsync|ISAPILogNotSupported|ISAPIReadAheadBuffer|KeepAlive|KeepAliveTimeout|KeptBodySize|LanguagePriority|LDAPCacheEntries|LDAPCacheTTL|LDAPConnectionPoolTTL|LDAPConnectionTimeout|LDAPLibraryDebug|LDAPOpCacheEntries|LDAPOpCacheTTL|LDAPReferralHopLimit|LDAPReferrals|LDAPRetries|LDAPRetryDelay|LDAPSharedCacheFile|LDAPSharedCacheSize|LDAPTimeout|LDAPTrustedClientCert|LDAPTrustedGlobalCert|LDAPTrustedMode|LDAPVerifyServerCert|LimitInternalRecursion|LimitRequestBody|LimitRequestFields|LimitRequestFieldSize|LimitRequestLine|LimitXMLRequestBody|Listen|ListenBackLog|LoadFile|LoadModule|LogFormat|LogLevel|LogMessage|LuaAuthzProvider|LuaCodeCache|LuaHookAccessChecker|LuaHookAuthChecker|LuaHookCheckUserID|LuaHookFixups|LuaHookInsertFilter|LuaHookLog|LuaHookMapToStorage|LuaHookTranslateName|LuaHookTypeChecker|LuaInherit|LuaInputFilter|LuaMapHandler|LuaOutputFilter|LuaPackageCPath|LuaPackagePath|LuaQuickHandler|LuaRoot|LuaScope|MaxConnectionsPerChild|MaxKeepAliveRequests|MaxMemFree|MaxRangeOverlaps|MaxRangeReversals|MaxRanges|MaxRequestWorkers|MaxSpareServers|MaxSpareThreads|MaxThreads|MergeTrailers|MetaDir|MetaFiles|MetaSuffix|MimeMagicFile|MinSpareServers|MinSpareThreads|MMapFile|ModemStandard|ModMimeUsePathInfo|MultiviewsMatch|Mutex|NameVirtualHost|NoProxy|NWSSLTrustedCerts|NWSSLUpgradeable|Options|Order|OutputSed|PassEnv|PidFile|PrivilegesMode|Protocol|ProtocolEcho|ProxyAddHeaders|ProxyBadHeader|ProxyBlock|ProxyDomain|ProxyErrorOverride|ProxyExpressDBMFile|ProxyExpressDBMType|ProxyExpressEnable|ProxyFtpDirCharset|ProxyFtpEscapeWildcards|ProxyFtpListOnWildcard|ProxyHTMLBufSize|ProxyHTMLCharsetOut|ProxyHTMLDocType|ProxyHTMLEnable|ProxyHTMLEvents|ProxyHTMLExtended|ProxyHTMLFixups|ProxyHTMLInterp|ProxyHTMLLinks|ProxyHTMLMeta|ProxyHTMLStripComments|ProxyHTMLURLMap|ProxyIOBufferSize|ProxyMaxForwards|ProxyPass|ProxyPassInherit|ProxyPassInterpolateEnv|ProxyPassMatch|ProxyPassReverse|ProxyPassReverseCookieDomain|ProxyPassReverseCookiePath|ProxyPreserveHost|ProxyReceiveBufferSize|ProxyRemote|ProxyRemoteMatch|ProxyRequests|ProxySCGIInternalRedirect|ProxySCGISendfile|ProxySet|ProxySourceAddress|ProxyStatus|ProxyTimeout|ProxyVia|ReadmeName|ReceiveBufferSize|Redirect|RedirectMatch|RedirectPermanent|RedirectTemp|ReflectorHeader|RemoteIPHeader|RemoteIPInternalProxy|RemoteIPInternalProxyList|RemoteIPProxiesHeader|RemoteIPTrustedProxy|RemoteIPTrustedProxyList|RemoveCharset|RemoveEncoding|RemoveHandler|RemoveInputFilter|RemoveLanguage|RemoveOutputFilter|RemoveType|RequestHeader|RequestReadTimeout|Require|RewriteBase|RewriteCond|RewriteEngine|RewriteMap|RewriteOptions|RewriteRule|RLimitCPU|RLimitMEM|RLimitNPROC|Satisfy|ScoreBoardFile|Script|ScriptAlias|ScriptAliasMatch|ScriptInterpreterSource|ScriptLog|ScriptLogBuffer|ScriptLogLength|ScriptSock|SecureListen|SeeRequestTail|SendBufferSize|ServerAdmin|ServerAlias|ServerLimit|ServerName|ServerPath|ServerRoot|ServerSignature|ServerTokens|Session|SessionCookieName|SessionCookieName2|SessionCookieRemove|SessionCryptoCipher|SessionCryptoDriver|SessionCryptoPassphrase|SessionCryptoPassphraseFile|SessionDBDCookieName|SessionDBDCookieName2|SessionDBDCookieRemove|SessionDBDDeleteLabel|SessionDBDInsertLabel|SessionDBDPerUser|SessionDBDSelectLabel|SessionDBDUpdateLabel|SessionEnv|SessionExclude|SessionHeader|SessionInclude|SessionMaxAge|SetEnv|SetEnvIf|SetEnvIfExpr|SetEnvIfNoCase|SetHandler|SetInputFilter|SetOutputFilter|SSIEndTag|SSIErrorMsg|SSIETag|SSILastModified|SSILegacyExprParser|SSIStartTag|SSITimeFormat|SSIUndefinedEcho|SSLCACertificateFile|SSLCACertificatePath|SSLCADNRequestFile|SSLCADNRequestPath|SSLCARevocationCheck|SSLCARevocationFile|SSLCARevocationPath|SSLCertificateChainFile|SSLCertificateFile|SSLCertificateKeyFile|SSLCipherSuite|SSLCompression|SSLCryptoDevice|SSLEngine|SSLFIPS|SSLHonorCipherOrder|SSLInsecureRenegotiation|SSLOCSPDefaultResponder|SSLOCSPEnable|SSLOCSPOverrideResponder|SSLOCSPResponderTimeout|SSLOCSPResponseMaxAge|SSLOCSPResponseTimeSkew|SSLOCSPUseRequestNonce|SSLOpenSSLConfCmd|SSLOptions|SSLPassPhraseDialog|SSLProtocol|SSLProxyCACertificateFile|SSLProxyCACertificatePath|SSLProxyCARevocationCheck|SSLProxyCARevocationFile|SSLProxyCARevocationPath|SSLProxyCheckPeerCN|SSLProxyCheckPeerExpire|SSLProxyCheckPeerName|SSLProxyCipherSuite|SSLProxyEngine|SSLProxyMachineCertificateChainFile|SSLProxyMachineCertificateFile|SSLProxyMachineCertificatePath|SSLProxyProtocol|SSLProxyVerify|SSLProxyVerifyDepth|SSLRandomSeed|SSLRenegBufferSize|SSLRequire|SSLRequireSSL|SSLSessionCache|SSLSessionCacheTimeout|SSLSessionTicketKeyFile|SSLSRPUnknownUserSeed|SSLSRPVerifierFile|SSLStaplingCache|SSLStaplingErrorCacheTimeout|SSLStaplingFakeTryLater|SSLStaplingForceURL|SSLStaplingResponderTimeout|SSLStaplingResponseMaxAge|SSLStaplingResponseTimeSkew|SSLStaplingReturnResponderErrors|SSLStaplingStandardCacheTimeout|SSLStrictSNIVHostCheck|SSLUserName|SSLUseStapling|SSLVerifyClient|SSLVerifyDepth|StartServers|StartThreads|Substitute|Suexec|SuexecUserGroup|ThreadLimit|ThreadsPerChild|ThreadStackSize|TimeOut|TraceEnable|TransferLog|TypesConfig|UnDefine|UndefMacro|UnsetEnv|Use|UseCanonicalName|UseCanonicalPhysicalPort|User|UserDir|VHostCGIMode|VHostCGIPrivs|VHostGroup|VHostPrivs|VHostSecure|VHostUser|VirtualDocumentRoot|VirtualDocumentRootIP|VirtualScriptAlias|VirtualScriptAliasIP|WatchdogInterval|XBitHack|xml2EncAlias|xml2EncDefault|xml2StartParse)\b/im,alias:"property"},"directive-block":{pattern:/<\/?\b(AuthnProviderAlias|AuthzProviderAlias|Directory|DirectoryMatch|Else|ElseIf|Files|FilesMatch|If|IfDefine|IfModule|IfVersion|Limit|LimitExcept|Location|LocationMatch|Macro|Proxy|RequireAll|RequireAny|RequireNone|VirtualHost)\b *.*>/i,inside:{"directive-block":{pattern:/^<\/?\w+/,inside:{punctuation:/^<\/?/},alias:"tag"},"directive-block-parameter":{pattern:/.*[^>]/,inside:{punctuation:/:/,string:{pattern:/("|').*\1/,inside:{variable:/(\$|%)\{?(\w\.?(\+|\-|:)?)+\}?/}}},alias:"attr-value"},punctuation:/>/},alias:"tag"},"directive-flags":{pattern:/\[(\w,?)+\]/,alias:"keyword"},string:{pattern:/("|').*\1/,inside:{variable:/(\$|%)\{?(\w\.?(\+|\-|:)?)+\}?/}},variable:/(\$|%)\{?(\w\.?(\+|\-|:)?)+\}?/,regex:/\^?.*\$|\^.*\$?/}; \ No newline at end of file +Prism.languages.apacheconf={comment:/#.*/,"directive-inline":{pattern:/^(\s*)\b(AcceptFilter|AcceptPathInfo|AccessFileName|Action|AddAlt|AddAltByEncoding|AddAltByType|AddCharset|AddDefaultCharset|AddDescription|AddEncoding|AddHandler|AddIcon|AddIconByEncoding|AddIconByType|AddInputFilter|AddLanguage|AddModuleInfo|AddOutputFilter|AddOutputFilterByType|AddType|Alias|AliasMatch|Allow|AllowCONNECT|AllowEncodedSlashes|AllowMethods|AllowOverride|AllowOverrideList|Anonymous|Anonymous_LogEmail|Anonymous_MustGiveEmail|Anonymous_NoUserID|Anonymous_VerifyEmail|AsyncRequestWorkerFactor|AuthBasicAuthoritative|AuthBasicFake|AuthBasicProvider|AuthBasicUseDigestAlgorithm|AuthDBDUserPWQuery|AuthDBDUserRealmQuery|AuthDBMGroupFile|AuthDBMType|AuthDBMUserFile|AuthDigestAlgorithm|AuthDigestDomain|AuthDigestNonceLifetime|AuthDigestProvider|AuthDigestQop|AuthDigestShmemSize|AuthFormAuthoritative|AuthFormBody|AuthFormDisableNoStore|AuthFormFakeBasicAuth|AuthFormLocation|AuthFormLoginRequiredLocation|AuthFormLoginSuccessLocation|AuthFormLogoutLocation|AuthFormMethod|AuthFormMimetype|AuthFormPassword|AuthFormProvider|AuthFormSitePassphrase|AuthFormSize|AuthFormUsername|AuthGroupFile|AuthLDAPAuthorizePrefix|AuthLDAPBindAuthoritative|AuthLDAPBindDN|AuthLDAPBindPassword|AuthLDAPCharsetConfig|AuthLDAPCompareAsUser|AuthLDAPCompareDNOnServer|AuthLDAPDereferenceAliases|AuthLDAPGroupAttribute|AuthLDAPGroupAttributeIsDN|AuthLDAPInitialBindAsUser|AuthLDAPInitialBindPattern|AuthLDAPMaxSubGroupDepth|AuthLDAPRemoteUserAttribute|AuthLDAPRemoteUserIsDN|AuthLDAPSearchAsUser|AuthLDAPSubGroupAttribute|AuthLDAPSubGroupClass|AuthLDAPUrl|AuthMerging|AuthName|AuthnCacheContext|AuthnCacheEnable|AuthnCacheProvideFor|AuthnCacheSOCache|AuthnCacheTimeout|AuthnzFcgiCheckAuthnProvider|AuthnzFcgiDefineProvider|AuthType|AuthUserFile|AuthzDBDLoginToReferer|AuthzDBDQuery|AuthzDBDRedirectQuery|AuthzDBMType|AuthzSendForbiddenOnFailure|BalancerGrowth|BalancerInherit|BalancerMember|BalancerPersist|BrowserMatch|BrowserMatchNoCase|BufferedLogs|BufferSize|CacheDefaultExpire|CacheDetailHeader|CacheDirLength|CacheDirLevels|CacheDisable|CacheEnable|CacheFile|CacheHeader|CacheIgnoreCacheControl|CacheIgnoreHeaders|CacheIgnoreNoLastMod|CacheIgnoreQueryString|CacheIgnoreURLSessionIdentifiers|CacheKeyBaseURL|CacheLastModifiedFactor|CacheLock|CacheLockMaxAge|CacheLockPath|CacheMaxExpire|CacheMaxFileSize|CacheMinExpire|CacheMinFileSize|CacheNegotiatedDocs|CacheQuickHandler|CacheReadSize|CacheReadTime|CacheRoot|CacheSocache|CacheSocacheMaxSize|CacheSocacheMaxTime|CacheSocacheMinTime|CacheSocacheReadSize|CacheSocacheReadTime|CacheStaleOnError|CacheStoreExpired|CacheStoreNoStore|CacheStorePrivate|CGIDScriptTimeout|CGIMapExtension|CharsetDefault|CharsetOptions|CharsetSourceEnc|CheckCaseOnly|CheckSpelling|ChrootDir|ContentDigest|CookieDomain|CookieExpires|CookieName|CookieStyle|CookieTracking|CoreDumpDirectory|CustomLog|Dav|DavDepthInfinity|DavGenericLockDB|DavLockDB|DavMinTimeout|DBDExptime|DBDInitSQL|DBDKeep|DBDMax|DBDMin|DBDParams|DBDPersist|DBDPrepareSQL|DBDriver|DefaultIcon|DefaultLanguage|DefaultRuntimeDir|DefaultType|Define|DeflateBufferSize|DeflateCompressionLevel|DeflateFilterNote|DeflateInflateLimitRequestBody|DeflateInflateRatioBurst|DeflateInflateRatioLimit|DeflateMemLevel|DeflateWindowSize|Deny|DirectoryCheckHandler|DirectoryIndex|DirectoryIndexRedirect|DirectorySlash|DocumentRoot|DTracePrivileges|DumpIOInput|DumpIOOutput|EnableExceptionHook|EnableMMAP|EnableSendfile|Error|ErrorDocument|ErrorLog|ErrorLogFormat|Example|ExpiresActive|ExpiresByType|ExpiresDefault|ExtendedStatus|ExtFilterDefine|ExtFilterOptions|FallbackResource|FileETag|FilterChain|FilterDeclare|FilterProtocol|FilterProvider|FilterTrace|ForceLanguagePriority|ForceType|ForensicLog|GprofDir|GracefulShutdownTimeout|Group|Header|HeaderName|HeartbeatAddress|HeartbeatListen|HeartbeatMaxServers|HeartbeatStorage|HeartbeatStorage|HostnameLookups|IdentityCheck|IdentityCheckTimeout|ImapBase|ImapDefault|ImapMenu|Include|IncludeOptional|IndexHeadInsert|IndexIgnore|IndexIgnoreReset|IndexOptions|IndexOrderDefault|IndexStyleSheet|InputSed|ISAPIAppendLogToErrors|ISAPIAppendLogToQuery|ISAPICacheFile|ISAPIFakeAsync|ISAPILogNotSupported|ISAPIReadAheadBuffer|KeepAlive|KeepAliveTimeout|KeptBodySize|LanguagePriority|LDAPCacheEntries|LDAPCacheTTL|LDAPConnectionPoolTTL|LDAPConnectionTimeout|LDAPLibraryDebug|LDAPOpCacheEntries|LDAPOpCacheTTL|LDAPReferralHopLimit|LDAPReferrals|LDAPRetries|LDAPRetryDelay|LDAPSharedCacheFile|LDAPSharedCacheSize|LDAPTimeout|LDAPTrustedClientCert|LDAPTrustedGlobalCert|LDAPTrustedMode|LDAPVerifyServerCert|LimitInternalRecursion|LimitRequestBody|LimitRequestFields|LimitRequestFieldSize|LimitRequestLine|LimitXMLRequestBody|Listen|ListenBackLog|LoadFile|LoadModule|LogFormat|LogLevel|LogMessage|LuaAuthzProvider|LuaCodeCache|LuaHookAccessChecker|LuaHookAuthChecker|LuaHookCheckUserID|LuaHookFixups|LuaHookInsertFilter|LuaHookLog|LuaHookMapToStorage|LuaHookTranslateName|LuaHookTypeChecker|LuaInherit|LuaInputFilter|LuaMapHandler|LuaOutputFilter|LuaPackageCPath|LuaPackagePath|LuaQuickHandler|LuaRoot|LuaScope|MaxConnectionsPerChild|MaxKeepAliveRequests|MaxMemFree|MaxRangeOverlaps|MaxRangeReversals|MaxRanges|MaxRequestWorkers|MaxSpareServers|MaxSpareThreads|MaxThreads|MergeTrailers|MetaDir|MetaFiles|MetaSuffix|MimeMagicFile|MinSpareServers|MinSpareThreads|MMapFile|ModemStandard|ModMimeUsePathInfo|MultiviewsMatch|Mutex|NameVirtualHost|NoProxy|NWSSLTrustedCerts|NWSSLUpgradeable|Options|Order|OutputSed|PassEnv|PidFile|PrivilegesMode|Protocol|ProtocolEcho|ProxyAddHeaders|ProxyBadHeader|ProxyBlock|ProxyDomain|ProxyErrorOverride|ProxyExpressDBMFile|ProxyExpressDBMType|ProxyExpressEnable|ProxyFtpDirCharset|ProxyFtpEscapeWildcards|ProxyFtpListOnWildcard|ProxyHTMLBufSize|ProxyHTMLCharsetOut|ProxyHTMLDocType|ProxyHTMLEnable|ProxyHTMLEvents|ProxyHTMLExtended|ProxyHTMLFixups|ProxyHTMLInterp|ProxyHTMLLinks|ProxyHTMLMeta|ProxyHTMLStripComments|ProxyHTMLURLMap|ProxyIOBufferSize|ProxyMaxForwards|ProxyPass|ProxyPassInherit|ProxyPassInterpolateEnv|ProxyPassMatch|ProxyPassReverse|ProxyPassReverseCookieDomain|ProxyPassReverseCookiePath|ProxyPreserveHost|ProxyReceiveBufferSize|ProxyRemote|ProxyRemoteMatch|ProxyRequests|ProxySCGIInternalRedirect|ProxySCGISendfile|ProxySet|ProxySourceAddress|ProxyStatus|ProxyTimeout|ProxyVia|ReadmeName|ReceiveBufferSize|Redirect|RedirectMatch|RedirectPermanent|RedirectTemp|ReflectorHeader|RemoteIPHeader|RemoteIPInternalProxy|RemoteIPInternalProxyList|RemoteIPProxiesHeader|RemoteIPTrustedProxy|RemoteIPTrustedProxyList|RemoveCharset|RemoveEncoding|RemoveHandler|RemoveInputFilter|RemoveLanguage|RemoveOutputFilter|RemoveType|RequestHeader|RequestReadTimeout|Require|RewriteBase|RewriteCond|RewriteEngine|RewriteMap|RewriteOptions|RewriteRule|RLimitCPU|RLimitMEM|RLimitNPROC|Satisfy|ScoreBoardFile|Script|ScriptAlias|ScriptAliasMatch|ScriptInterpreterSource|ScriptLog|ScriptLogBuffer|ScriptLogLength|ScriptSock|SecureListen|SeeRequestTail|SendBufferSize|ServerAdmin|ServerAlias|ServerLimit|ServerName|ServerPath|ServerRoot|ServerSignature|ServerTokens|Session|SessionCookieName|SessionCookieName2|SessionCookieRemove|SessionCryptoCipher|SessionCryptoDriver|SessionCryptoPassphrase|SessionCryptoPassphraseFile|SessionDBDCookieName|SessionDBDCookieName2|SessionDBDCookieRemove|SessionDBDDeleteLabel|SessionDBDInsertLabel|SessionDBDPerUser|SessionDBDSelectLabel|SessionDBDUpdateLabel|SessionEnv|SessionExclude|SessionHeader|SessionInclude|SessionMaxAge|SetEnv|SetEnvIf|SetEnvIfExpr|SetEnvIfNoCase|SetHandler|SetInputFilter|SetOutputFilter|SSIEndTag|SSIErrorMsg|SSIETag|SSILastModified|SSILegacyExprParser|SSIStartTag|SSITimeFormat|SSIUndefinedEcho|SSLCACertificateFile|SSLCACertificatePath|SSLCADNRequestFile|SSLCADNRequestPath|SSLCARevocationCheck|SSLCARevocationFile|SSLCARevocationPath|SSLCertificateChainFile|SSLCertificateFile|SSLCertificateKeyFile|SSLCipherSuite|SSLCompression|SSLCryptoDevice|SSLEngine|SSLFIPS|SSLHonorCipherOrder|SSLInsecureRenegotiation|SSLOCSPDefaultResponder|SSLOCSPEnable|SSLOCSPOverrideResponder|SSLOCSPResponderTimeout|SSLOCSPResponseMaxAge|SSLOCSPResponseTimeSkew|SSLOCSPUseRequestNonce|SSLOpenSSLConfCmd|SSLOptions|SSLPassPhraseDialog|SSLProtocol|SSLProxyCACertificateFile|SSLProxyCACertificatePath|SSLProxyCARevocationCheck|SSLProxyCARevocationFile|SSLProxyCARevocationPath|SSLProxyCheckPeerCN|SSLProxyCheckPeerExpire|SSLProxyCheckPeerName|SSLProxyCipherSuite|SSLProxyEngine|SSLProxyMachineCertificateChainFile|SSLProxyMachineCertificateFile|SSLProxyMachineCertificatePath|SSLProxyProtocol|SSLProxyVerify|SSLProxyVerifyDepth|SSLRandomSeed|SSLRenegBufferSize|SSLRequire|SSLRequireSSL|SSLSessionCache|SSLSessionCacheTimeout|SSLSessionTicketKeyFile|SSLSRPUnknownUserSeed|SSLSRPVerifierFile|SSLStaplingCache|SSLStaplingErrorCacheTimeout|SSLStaplingFakeTryLater|SSLStaplingForceURL|SSLStaplingResponderTimeout|SSLStaplingResponseMaxAge|SSLStaplingResponseTimeSkew|SSLStaplingReturnResponderErrors|SSLStaplingStandardCacheTimeout|SSLStrictSNIVHostCheck|SSLUserName|SSLUseStapling|SSLVerifyClient|SSLVerifyDepth|StartServers|StartThreads|Substitute|Suexec|SuexecUserGroup|ThreadLimit|ThreadsPerChild|ThreadStackSize|TimeOut|TraceEnable|TransferLog|TypesConfig|UnDefine|UndefMacro|UnsetEnv|Use|UseCanonicalName|UseCanonicalPhysicalPort|User|UserDir|VHostCGIMode|VHostCGIPrivs|VHostGroup|VHostPrivs|VHostSecure|VHostUser|VirtualDocumentRoot|VirtualDocumentRootIP|VirtualScriptAlias|VirtualScriptAliasIP|WatchdogInterval|XBitHack|xml2EncAlias|xml2EncDefault|xml2StartParse)\b/im,lookbehind:!0,alias:"property"},"directive-block":{pattern:/<\/?\b(AuthnProviderAlias|AuthzProviderAlias|Directory|DirectoryMatch|Else|ElseIf|Files|FilesMatch|If|IfDefine|IfModule|IfVersion|Limit|LimitExcept|Location|LocationMatch|Macro|Proxy|RequireAll|RequireAny|RequireNone|VirtualHost)\b *.*>/i,inside:{"directive-block":{pattern:/^<\/?\w+/,inside:{punctuation:/^<\/?/},alias:"tag"},"directive-block-parameter":{pattern:/.*[^>]/,inside:{punctuation:/:/,string:{pattern:/("|').*\1/,inside:{variable:/(\$|%)\{?(\w\.?(\+|\-|:)?)+\}?/}}},alias:"attr-value"},punctuation:/>/},alias:"tag"},"directive-flags":{pattern:/\[(\w,?)+\]/,alias:"keyword"},string:{pattern:/("|').*\1/,inside:{variable:/(\$|%)\{?(\w\.?(\+|\-|:)?)+\}?/}},variable:/(\$|%)\{?(\w\.?(\+|\-|:)?)+\}?/,regex:/\^?.*\$|\^.*\$?/}; \ No newline at end of file From 65894c599fbf4d330fa0f76a6e75b8911a24d7c9 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sat, 11 Jul 2015 08:11:33 +0200 Subject: [PATCH 092/310] AppleScript: Allow one level of nesting in block comments --- components/prism-applescript.js | 7 ++----- components/prism-applescript.min.js | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/components/prism-applescript.js b/components/prism-applescript.js index 5d74020431..06338599cc 100644 --- a/components/prism-applescript.js +++ b/components/prism-applescript.js @@ -1,10 +1,7 @@ -/* TODO - Add support for nested block comments... -*/ - Prism.languages.applescript = { 'comment': [ - /\(\*[\w\W]*?\*\)/, + // Allow one level of nesting + /\(\*(?:\(\*[\w\W]*?\*\)|[\w\W])*?\*\)/, /--.+/, /#.+/ ], diff --git a/components/prism-applescript.min.js b/components/prism-applescript.min.js index 30e1ffd7e4..ff9c1595f7 100644 --- a/components/prism-applescript.min.js +++ b/components/prism-applescript.min.js @@ -1 +1 @@ -Prism.languages.applescript={comment:[/\(\*[\w\W]*?\*\)/,/--.+/,/#.+/],string:/"(?:\\?.)*?"/,operator:[/[&=≠≤≥*+\-\/÷^]|[<>]=?/,/\b(?:(?:start|begin|end)s? with|(?:(?:does not|doesn't) contain|contains?)|(?:is|isn't|is not) (?:in|contained by)|(?:(?:is|isn't|is not) )?(?:greater|less) than(?: or equal)?(?: to)?|(?:(?:does not|doesn't) come|comes) (?:before|after)|(?:is|isn't|is not) equal(?: to)?|(?:(?:does not|doesn't) equal|equals|equal to|isn't|is not)|(?:a )?(?:ref(?: to)?|reference to)|(?:and|or|div|mod|as|not))\b/],keyword:/\b(?:about|above|after|against|and|apart from|around|as|aside from|at|back|before|beginning|behind|below|beneath|beside|between|but|by|considering|contain|contains|continue|copy|div|does|eighth|else|end|equal|equals|error|every|exit|false|fifth|first|for|fourth|from|front|get|given|global|if|ignoring|in|instead of|into|is|it|its|last|local|me|middle|mod|my|ninth|not|of|on|onto|or|out of|over|prop|property|put|ref|reference|repeat|return|returning|script|second|set|seventh|since|sixth|some|tell|tenth|that|the|then|third|through|thru|timeout|times|to|transaction|true|try|until|where|while|whose|with|without)\b/,"class":{pattern:/\b(?:alias|application|boolean|class|constant|date|file|integer|list|number|POSIX file|real|record|reference|RGB color|script|text|centimetres|centimeters|feet|inches|kilometres|kilometers|metres|meters|miles|yards|square feet|square kilometres|square kilometers|square metres|square meters|square miles|square yards|cubic centimetres|cubic centimeters|cubic feet|cubic inches|cubic metres|cubic meters|cubic yards|gallons|litres|liters|quarts|grams|kilograms|ounces|pounds|degrees Celsius|degrees Fahrenheit|degrees Kelvin)\b/,alias:"builtin"},number:/\b-?\d*\.?\d+([Ee]-?\d+)?\b/,punctuation:/[{}():,¬«»《》]/}; \ No newline at end of file +Prism.languages.applescript={comment:[/\(\*(?:\(\*[\w\W]*?\*\)|[\w\W])*?\*\)/,/--.+/,/#.+/],string:/"(?:\\?.)*?"/,operator:[/[&=≠≤≥*+\-\/÷^]|[<>]=?/,/\b(?:(?:start|begin|end)s? with|(?:(?:does not|doesn't) contain|contains?)|(?:is|isn't|is not) (?:in|contained by)|(?:(?:is|isn't|is not) )?(?:greater|less) than(?: or equal)?(?: to)?|(?:(?:does not|doesn't) come|comes) (?:before|after)|(?:is|isn't|is not) equal(?: to)?|(?:(?:does not|doesn't) equal|equals|equal to|isn't|is not)|(?:a )?(?:ref(?: to)?|reference to)|(?:and|or|div|mod|as|not))\b/],keyword:/\b(?:about|above|after|against|and|apart from|around|as|aside from|at|back|before|beginning|behind|below|beneath|beside|between|but|by|considering|contain|contains|continue|copy|div|does|eighth|else|end|equal|equals|error|every|exit|false|fifth|first|for|fourth|from|front|get|given|global|if|ignoring|in|instead of|into|is|it|its|last|local|me|middle|mod|my|ninth|not|of|on|onto|or|out of|over|prop|property|put|ref|reference|repeat|return|returning|script|second|set|seventh|since|sixth|some|tell|tenth|that|the|then|third|through|thru|timeout|times|to|transaction|true|try|until|where|while|whose|with|without)\b/,"class":{pattern:/\b(?:alias|application|boolean|class|constant|date|file|integer|list|number|POSIX file|real|record|reference|RGB color|script|text|centimetres|centimeters|feet|inches|kilometres|kilometers|metres|meters|miles|yards|square feet|square kilometres|square kilometers|square metres|square meters|square miles|square yards|cubic centimetres|cubic centimeters|cubic feet|cubic inches|cubic metres|cubic meters|cubic yards|gallons|litres|liters|quarts|grams|kilograms|ounces|pounds|degrees Celsius|degrees Fahrenheit|degrees Kelvin)\b/,alias:"builtin"},number:/\b-?\d*\.?\d+([Ee]-?\d+)?\b/,punctuation:/[{}():,¬«»《》]/}; \ No newline at end of file From 1ec5a81ea0056ffe4316282b77b30f6242069130 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sat, 11 Jul 2015 09:12:47 +0200 Subject: [PATCH 093/310] AppleScript: Removed duplicates between operators and keywords --- components/prism-applescript.js | 2 +- components/prism-applescript.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/prism-applescript.js b/components/prism-applescript.js index 06338599cc..5ac745f6c5 100644 --- a/components/prism-applescript.js +++ b/components/prism-applescript.js @@ -10,7 +10,7 @@ Prism.languages.applescript = { /[&=≠≤≥*+\-\/÷^]|[<>]=?/, /\b(?:(?:start|begin|end)s? with|(?:(?:does not|doesn't) contain|contains?)|(?:is|isn't|is not) (?:in|contained by)|(?:(?:is|isn't|is not) )?(?:greater|less) than(?: or equal)?(?: to)?|(?:(?:does not|doesn't) come|comes) (?:before|after)|(?:is|isn't|is not) equal(?: to)?|(?:(?:does not|doesn't) equal|equals|equal to|isn't|is not)|(?:a )?(?:ref(?: to)?|reference to)|(?:and|or|div|mod|as|not))\b/ ], - 'keyword': /\b(?:about|above|after|against|and|apart from|around|as|aside from|at|back|before|beginning|behind|below|beneath|beside|between|but|by|considering|contain|contains|continue|copy|div|does|eighth|else|end|equal|equals|error|every|exit|false|fifth|first|for|fourth|from|front|get|given|global|if|ignoring|in|instead of|into|is|it|its|last|local|me|middle|mod|my|ninth|not|of|on|onto|or|out of|over|prop|property|put|ref|reference|repeat|return|returning|script|second|set|seventh|since|sixth|some|tell|tenth|that|the|then|third|through|thru|timeout|times|to|transaction|true|try|until|where|while|whose|with|without)\b/, + 'keyword': /\b(?:about|above|after|against|apart from|around|aside from|at|back|before|beginning|behind|below|beneath|beside|between|but|by|considering|continue|copy|does|eighth|else|end|equal|error|every|exit|false|fifth|first|for|fourth|from|front|get|given|global|if|ignoring|in|instead of|into|is|it|its|last|local|me|middle|my|ninth|of|on|onto|out of|over|prop|property|put|reference|repeat|return|returning|script|second|set|seventh|since|sixth|some|tell|tenth|that|the|then|third|through|thru|timeout|times|to|transaction|true|try|until|where|while|whose|with|without)\b/, 'class': { pattern: /\b(?:alias|application|boolean|class|constant|date|file|integer|list|number|POSIX file|real|record|reference|RGB color|script|text|centimetres|centimeters|feet|inches|kilometres|kilometers|metres|meters|miles|yards|square feet|square kilometres|square kilometers|square metres|square meters|square miles|square yards|cubic centimetres|cubic centimeters|cubic feet|cubic inches|cubic metres|cubic meters|cubic yards|gallons|litres|liters|quarts|grams|kilograms|ounces|pounds|degrees Celsius|degrees Fahrenheit|degrees Kelvin)\b/, alias: 'builtin' diff --git a/components/prism-applescript.min.js b/components/prism-applescript.min.js index ff9c1595f7..0c7cd2abbb 100644 --- a/components/prism-applescript.min.js +++ b/components/prism-applescript.min.js @@ -1 +1 @@ -Prism.languages.applescript={comment:[/\(\*(?:\(\*[\w\W]*?\*\)|[\w\W])*?\*\)/,/--.+/,/#.+/],string:/"(?:\\?.)*?"/,operator:[/[&=≠≤≥*+\-\/÷^]|[<>]=?/,/\b(?:(?:start|begin|end)s? with|(?:(?:does not|doesn't) contain|contains?)|(?:is|isn't|is not) (?:in|contained by)|(?:(?:is|isn't|is not) )?(?:greater|less) than(?: or equal)?(?: to)?|(?:(?:does not|doesn't) come|comes) (?:before|after)|(?:is|isn't|is not) equal(?: to)?|(?:(?:does not|doesn't) equal|equals|equal to|isn't|is not)|(?:a )?(?:ref(?: to)?|reference to)|(?:and|or|div|mod|as|not))\b/],keyword:/\b(?:about|above|after|against|and|apart from|around|as|aside from|at|back|before|beginning|behind|below|beneath|beside|between|but|by|considering|contain|contains|continue|copy|div|does|eighth|else|end|equal|equals|error|every|exit|false|fifth|first|for|fourth|from|front|get|given|global|if|ignoring|in|instead of|into|is|it|its|last|local|me|middle|mod|my|ninth|not|of|on|onto|or|out of|over|prop|property|put|ref|reference|repeat|return|returning|script|second|set|seventh|since|sixth|some|tell|tenth|that|the|then|third|through|thru|timeout|times|to|transaction|true|try|until|where|while|whose|with|without)\b/,"class":{pattern:/\b(?:alias|application|boolean|class|constant|date|file|integer|list|number|POSIX file|real|record|reference|RGB color|script|text|centimetres|centimeters|feet|inches|kilometres|kilometers|metres|meters|miles|yards|square feet|square kilometres|square kilometers|square metres|square meters|square miles|square yards|cubic centimetres|cubic centimeters|cubic feet|cubic inches|cubic metres|cubic meters|cubic yards|gallons|litres|liters|quarts|grams|kilograms|ounces|pounds|degrees Celsius|degrees Fahrenheit|degrees Kelvin)\b/,alias:"builtin"},number:/\b-?\d*\.?\d+([Ee]-?\d+)?\b/,punctuation:/[{}():,¬«»《》]/}; \ No newline at end of file +Prism.languages.applescript={comment:[/\(\*(?:\(\*[\w\W]*?\*\)|[\w\W])*?\*\)/,/--.+/,/#.+/],string:/"(?:\\?.)*?"/,operator:[/[&=≠≤≥*+\-\/÷^]|[<>]=?/,/\b(?:(?:start|begin|end)s? with|(?:(?:does not|doesn't) contain|contains?)|(?:is|isn't|is not) (?:in|contained by)|(?:(?:is|isn't|is not) )?(?:greater|less) than(?: or equal)?(?: to)?|(?:(?:does not|doesn't) come|comes) (?:before|after)|(?:is|isn't|is not) equal(?: to)?|(?:(?:does not|doesn't) equal|equals|equal to|isn't|is not)|(?:a )?(?:ref(?: to)?|reference to)|(?:and|or|div|mod|as|not))\b/],keyword:/\b(?:about|above|after|against|apart from|around|aside from|at|back|before|beginning|behind|below|beneath|beside|between|but|by|considering|continue|copy|does|eighth|else|end|equal|error|every|exit|false|fifth|first|for|fourth|from|front|get|given|global|if|ignoring|in|instead of|into|is|it|its|last|local|me|middle|my|ninth|of|on|onto|out of|over|prop|property|put|reference|repeat|return|returning|script|second|set|seventh|since|sixth|some|tell|tenth|that|the|then|third|through|thru|timeout|times|to|transaction|true|try|until|where|while|whose|with|without)\b/,"class":{pattern:/\b(?:alias|application|boolean|class|constant|date|file|integer|list|number|POSIX file|real|record|reference|RGB color|script|text|centimetres|centimeters|feet|inches|kilometres|kilometers|metres|meters|miles|yards|square feet|square kilometres|square kilometers|square metres|square meters|square miles|square yards|cubic centimetres|cubic centimeters|cubic feet|cubic inches|cubic metres|cubic meters|cubic yards|gallons|litres|liters|quarts|grams|kilograms|ounces|pounds|degrees Celsius|degrees Fahrenheit|degrees Kelvin)\b/,alias:"builtin"},number:/\b-?\d*\.?\d+([Ee]-?\d+)?\b/,punctuation:/[{}():,¬«»《》]/}; \ No newline at end of file From e8d09f6aa34a78d19ea361c36c7c70c3275d56f3 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sat, 11 Jul 2015 09:18:50 +0200 Subject: [PATCH 094/310] AppleScript: Removed duplicates between keywords and classes --- components/prism-applescript.js | 2 +- components/prism-applescript.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/prism-applescript.js b/components/prism-applescript.js index 5ac745f6c5..9acaf5db13 100644 --- a/components/prism-applescript.js +++ b/components/prism-applescript.js @@ -10,7 +10,7 @@ Prism.languages.applescript = { /[&=≠≤≥*+\-\/÷^]|[<>]=?/, /\b(?:(?:start|begin|end)s? with|(?:(?:does not|doesn't) contain|contains?)|(?:is|isn't|is not) (?:in|contained by)|(?:(?:is|isn't|is not) )?(?:greater|less) than(?: or equal)?(?: to)?|(?:(?:does not|doesn't) come|comes) (?:before|after)|(?:is|isn't|is not) equal(?: to)?|(?:(?:does not|doesn't) equal|equals|equal to|isn't|is not)|(?:a )?(?:ref(?: to)?|reference to)|(?:and|or|div|mod|as|not))\b/ ], - 'keyword': /\b(?:about|above|after|against|apart from|around|aside from|at|back|before|beginning|behind|below|beneath|beside|between|but|by|considering|continue|copy|does|eighth|else|end|equal|error|every|exit|false|fifth|first|for|fourth|from|front|get|given|global|if|ignoring|in|instead of|into|is|it|its|last|local|me|middle|my|ninth|of|on|onto|out of|over|prop|property|put|reference|repeat|return|returning|script|second|set|seventh|since|sixth|some|tell|tenth|that|the|then|third|through|thru|timeout|times|to|transaction|true|try|until|where|while|whose|with|without)\b/, + 'keyword': /\b(?:about|above|after|against|apart from|around|aside from|at|back|before|beginning|behind|below|beneath|beside|between|but|by|considering|continue|copy|does|eighth|else|end|equal|error|every|exit|false|fifth|first|for|fourth|from|front|get|given|global|if|ignoring|in|instead of|into|is|it|its|last|local|me|middle|my|ninth|of|on|onto|out of|over|prop|property|put|repeat|return|returning|second|set|seventh|since|sixth|some|tell|tenth|that|the|then|third|through|thru|timeout|times|to|transaction|true|try|until|where|while|whose|with|without)\b/, 'class': { pattern: /\b(?:alias|application|boolean|class|constant|date|file|integer|list|number|POSIX file|real|record|reference|RGB color|script|text|centimetres|centimeters|feet|inches|kilometres|kilometers|metres|meters|miles|yards|square feet|square kilometres|square kilometers|square metres|square meters|square miles|square yards|cubic centimetres|cubic centimeters|cubic feet|cubic inches|cubic metres|cubic meters|cubic yards|gallons|litres|liters|quarts|grams|kilograms|ounces|pounds|degrees Celsius|degrees Fahrenheit|degrees Kelvin)\b/, alias: 'builtin' diff --git a/components/prism-applescript.min.js b/components/prism-applescript.min.js index 0c7cd2abbb..5d8bbb7ff8 100644 --- a/components/prism-applescript.min.js +++ b/components/prism-applescript.min.js @@ -1 +1 @@ -Prism.languages.applescript={comment:[/\(\*(?:\(\*[\w\W]*?\*\)|[\w\W])*?\*\)/,/--.+/,/#.+/],string:/"(?:\\?.)*?"/,operator:[/[&=≠≤≥*+\-\/÷^]|[<>]=?/,/\b(?:(?:start|begin|end)s? with|(?:(?:does not|doesn't) contain|contains?)|(?:is|isn't|is not) (?:in|contained by)|(?:(?:is|isn't|is not) )?(?:greater|less) than(?: or equal)?(?: to)?|(?:(?:does not|doesn't) come|comes) (?:before|after)|(?:is|isn't|is not) equal(?: to)?|(?:(?:does not|doesn't) equal|equals|equal to|isn't|is not)|(?:a )?(?:ref(?: to)?|reference to)|(?:and|or|div|mod|as|not))\b/],keyword:/\b(?:about|above|after|against|apart from|around|aside from|at|back|before|beginning|behind|below|beneath|beside|between|but|by|considering|continue|copy|does|eighth|else|end|equal|error|every|exit|false|fifth|first|for|fourth|from|front|get|given|global|if|ignoring|in|instead of|into|is|it|its|last|local|me|middle|my|ninth|of|on|onto|out of|over|prop|property|put|reference|repeat|return|returning|script|second|set|seventh|since|sixth|some|tell|tenth|that|the|then|third|through|thru|timeout|times|to|transaction|true|try|until|where|while|whose|with|without)\b/,"class":{pattern:/\b(?:alias|application|boolean|class|constant|date|file|integer|list|number|POSIX file|real|record|reference|RGB color|script|text|centimetres|centimeters|feet|inches|kilometres|kilometers|metres|meters|miles|yards|square feet|square kilometres|square kilometers|square metres|square meters|square miles|square yards|cubic centimetres|cubic centimeters|cubic feet|cubic inches|cubic metres|cubic meters|cubic yards|gallons|litres|liters|quarts|grams|kilograms|ounces|pounds|degrees Celsius|degrees Fahrenheit|degrees Kelvin)\b/,alias:"builtin"},number:/\b-?\d*\.?\d+([Ee]-?\d+)?\b/,punctuation:/[{}():,¬«»《》]/}; \ No newline at end of file +Prism.languages.applescript={comment:[/\(\*(?:\(\*[\w\W]*?\*\)|[\w\W])*?\*\)/,/--.+/,/#.+/],string:/"(?:\\?.)*?"/,operator:[/[&=≠≤≥*+\-\/÷^]|[<>]=?/,/\b(?:(?:start|begin|end)s? with|(?:(?:does not|doesn't) contain|contains?)|(?:is|isn't|is not) (?:in|contained by)|(?:(?:is|isn't|is not) )?(?:greater|less) than(?: or equal)?(?: to)?|(?:(?:does not|doesn't) come|comes) (?:before|after)|(?:is|isn't|is not) equal(?: to)?|(?:(?:does not|doesn't) equal|equals|equal to|isn't|is not)|(?:a )?(?:ref(?: to)?|reference to)|(?:and|or|div|mod|as|not))\b/],keyword:/\b(?:about|above|after|against|apart from|around|aside from|at|back|before|beginning|behind|below|beneath|beside|between|but|by|considering|continue|copy|does|eighth|else|end|equal|error|every|exit|false|fifth|first|for|fourth|from|front|get|given|global|if|ignoring|in|instead of|into|is|it|its|last|local|me|middle|my|ninth|of|on|onto|out of|over|prop|property|put|repeat|return|returning|second|set|seventh|since|sixth|some|tell|tenth|that|the|then|third|through|thru|timeout|times|to|transaction|true|try|until|where|while|whose|with|without)\b/,"class":{pattern:/\b(?:alias|application|boolean|class|constant|date|file|integer|list|number|POSIX file|real|record|reference|RGB color|script|text|centimetres|centimeters|feet|inches|kilometres|kilometers|metres|meters|miles|yards|square feet|square kilometres|square kilometers|square metres|square meters|square miles|square yards|cubic centimetres|cubic centimeters|cubic feet|cubic inches|cubic metres|cubic meters|cubic yards|gallons|litres|liters|quarts|grams|kilograms|ounces|pounds|degrees Celsius|degrees Fahrenheit|degrees Kelvin)\b/,alias:"builtin"},number:/\b-?\d*\.?\d+([Ee]-?\d+)?\b/,punctuation:/[{}():,¬«»《》]/}; \ No newline at end of file From 66dac311516091fb3726440439c403961b508cd8 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sat, 11 Jul 2015 09:23:11 +0200 Subject: [PATCH 095/310] AppleScript: Move numbers up so they are not broken by operator pattern --- components/prism-applescript.js | 2 +- components/prism-applescript.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/prism-applescript.js b/components/prism-applescript.js index 9acaf5db13..52d0aeee04 100644 --- a/components/prism-applescript.js +++ b/components/prism-applescript.js @@ -6,6 +6,7 @@ Prism.languages.applescript = { /#.+/ ], 'string': /"(?:\\?.)*?"/, + 'number': /\b-?\d*\.?\d+([Ee]-?\d+)?\b/, 'operator': [ /[&=≠≤≥*+\-\/÷^]|[<>]=?/, /\b(?:(?:start|begin|end)s? with|(?:(?:does not|doesn't) contain|contains?)|(?:is|isn't|is not) (?:in|contained by)|(?:(?:is|isn't|is not) )?(?:greater|less) than(?: or equal)?(?: to)?|(?:(?:does not|doesn't) come|comes) (?:before|after)|(?:is|isn't|is not) equal(?: to)?|(?:(?:does not|doesn't) equal|equals|equal to|isn't|is not)|(?:a )?(?:ref(?: to)?|reference to)|(?:and|or|div|mod|as|not))\b/ @@ -15,6 +16,5 @@ Prism.languages.applescript = { pattern: /\b(?:alias|application|boolean|class|constant|date|file|integer|list|number|POSIX file|real|record|reference|RGB color|script|text|centimetres|centimeters|feet|inches|kilometres|kilometers|metres|meters|miles|yards|square feet|square kilometres|square kilometers|square metres|square meters|square miles|square yards|cubic centimetres|cubic centimeters|cubic feet|cubic inches|cubic metres|cubic meters|cubic yards|gallons|litres|liters|quarts|grams|kilograms|ounces|pounds|degrees Celsius|degrees Fahrenheit|degrees Kelvin)\b/, alias: 'builtin' }, - 'number': /\b-?\d*\.?\d+([Ee]-?\d+)?\b/, 'punctuation': /[{}():,¬«»《》]/ }; \ No newline at end of file diff --git a/components/prism-applescript.min.js b/components/prism-applescript.min.js index 5d8bbb7ff8..9bcb2cbb33 100644 --- a/components/prism-applescript.min.js +++ b/components/prism-applescript.min.js @@ -1 +1 @@ -Prism.languages.applescript={comment:[/\(\*(?:\(\*[\w\W]*?\*\)|[\w\W])*?\*\)/,/--.+/,/#.+/],string:/"(?:\\?.)*?"/,operator:[/[&=≠≤≥*+\-\/÷^]|[<>]=?/,/\b(?:(?:start|begin|end)s? with|(?:(?:does not|doesn't) contain|contains?)|(?:is|isn't|is not) (?:in|contained by)|(?:(?:is|isn't|is not) )?(?:greater|less) than(?: or equal)?(?: to)?|(?:(?:does not|doesn't) come|comes) (?:before|after)|(?:is|isn't|is not) equal(?: to)?|(?:(?:does not|doesn't) equal|equals|equal to|isn't|is not)|(?:a )?(?:ref(?: to)?|reference to)|(?:and|or|div|mod|as|not))\b/],keyword:/\b(?:about|above|after|against|apart from|around|aside from|at|back|before|beginning|behind|below|beneath|beside|between|but|by|considering|continue|copy|does|eighth|else|end|equal|error|every|exit|false|fifth|first|for|fourth|from|front|get|given|global|if|ignoring|in|instead of|into|is|it|its|last|local|me|middle|my|ninth|of|on|onto|out of|over|prop|property|put|repeat|return|returning|second|set|seventh|since|sixth|some|tell|tenth|that|the|then|third|through|thru|timeout|times|to|transaction|true|try|until|where|while|whose|with|without)\b/,"class":{pattern:/\b(?:alias|application|boolean|class|constant|date|file|integer|list|number|POSIX file|real|record|reference|RGB color|script|text|centimetres|centimeters|feet|inches|kilometres|kilometers|metres|meters|miles|yards|square feet|square kilometres|square kilometers|square metres|square meters|square miles|square yards|cubic centimetres|cubic centimeters|cubic feet|cubic inches|cubic metres|cubic meters|cubic yards|gallons|litres|liters|quarts|grams|kilograms|ounces|pounds|degrees Celsius|degrees Fahrenheit|degrees Kelvin)\b/,alias:"builtin"},number:/\b-?\d*\.?\d+([Ee]-?\d+)?\b/,punctuation:/[{}():,¬«»《》]/}; \ No newline at end of file +Prism.languages.applescript={comment:[/\(\*(?:\(\*[\w\W]*?\*\)|[\w\W])*?\*\)/,/--.+/,/#.+/],string:/"(?:\\?.)*?"/,number:/\b-?\d*\.?\d+([Ee]-?\d+)?\b/,operator:[/[&=≠≤≥*+\-\/÷^]|[<>]=?/,/\b(?:(?:start|begin|end)s? with|(?:(?:does not|doesn't) contain|contains?)|(?:is|isn't|is not) (?:in|contained by)|(?:(?:is|isn't|is not) )?(?:greater|less) than(?: or equal)?(?: to)?|(?:(?:does not|doesn't) come|comes) (?:before|after)|(?:is|isn't|is not) equal(?: to)?|(?:(?:does not|doesn't) equal|equals|equal to|isn't|is not)|(?:a )?(?:ref(?: to)?|reference to)|(?:and|or|div|mod|as|not))\b/],keyword:/\b(?:about|above|after|against|apart from|around|aside from|at|back|before|beginning|behind|below|beneath|beside|between|but|by|considering|continue|copy|does|eighth|else|end|equal|error|every|exit|false|fifth|first|for|fourth|from|front|get|given|global|if|ignoring|in|instead of|into|is|it|its|last|local|me|middle|my|ninth|of|on|onto|out of|over|prop|property|put|repeat|return|returning|second|set|seventh|since|sixth|some|tell|tenth|that|the|then|third|through|thru|timeout|times|to|transaction|true|try|until|where|while|whose|with|without)\b/,"class":{pattern:/\b(?:alias|application|boolean|class|constant|date|file|integer|list|number|POSIX file|real|record|reference|RGB color|script|text|centimetres|centimeters|feet|inches|kilometres|kilometers|metres|meters|miles|yards|square feet|square kilometres|square kilometers|square metres|square meters|square miles|square yards|cubic centimetres|cubic centimeters|cubic feet|cubic inches|cubic metres|cubic meters|cubic yards|gallons|litres|liters|quarts|grams|kilograms|ounces|pounds|degrees Celsius|degrees Fahrenheit|degrees Kelvin)\b/,alias:"builtin"},punctuation:/[{}():,¬«»《》]/}; \ No newline at end of file From 7bf6b880639fac824c863591bdc255722207189c Mon Sep 17 00:00:00 2001 From: Golmote Date: Sat, 11 Jul 2015 10:23:26 +0200 Subject: [PATCH 096/310] Run gulp task --- components/prism-ruby.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/prism-ruby.min.js b/components/prism-ruby.min.js index 4e551c4db2..f8f899dcd3 100644 --- a/components/prism-ruby.min.js +++ b/components/prism-ruby.min.js @@ -1 +1 @@ -Prism.languages.ruby=Prism.languages.extend("clike",{comment:/#[^\r\n]*(\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/,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/}),Prism.languages.insertBefore("ruby","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0},variable:/[@$]+\b[a-zA-Z_][a-zA-Z_0-9]*[?!]?\b/,symbol:/:\b[a-zA-Z_][a-zA-Z_0-9]*[?!]?\b/}); \ No newline at end of file +Prism.languages.ruby=Prism.languages.extend("clike",{comment:/#(?!\{[^\r\n]*?\})[^\r\n]*(\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/,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/}),Prism.languages.insertBefore("ruby","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0},variable:/[@$]+\b[a-zA-Z_][a-zA-Z_0-9]*[?!]?\b/,symbol:/:\b[a-zA-Z_][a-zA-Z_0-9]*[?!]?\b/}),Prism.languages.ruby.string={pattern:/("|')(#\{[^}]+\}|\\\n|\\?.)*?\1/,inside:{interpolation:{pattern:/#\{[^}]+\}/,inside:{delimiter:{pattern:/^#\{|\}$/,alias:"tag"},rest:Prism.util.clone(Prism.languages.ruby)}}}}; \ No newline at end of file From fbf5cdae62752021fadd78af3a68bbfa3c48f8d0 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sat, 11 Jul 2015 18:48:48 +0200 Subject: [PATCH 097/310] ASP.NET: Prevent Markup tags from breaking ASP tags + fix MasterType directive --- components/prism-aspnet.js | 4 +++- components/prism-aspnet.min.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/components/prism-aspnet.js b/components/prism-aspnet.js index 534a46ceba..291823e2a5 100644 --- a/components/prism-aspnet.js +++ b/components/prism-aspnet.js @@ -2,7 +2,7 @@ Prism.languages.aspnet = Prism.languages.extend('markup', { 'page-directive tag': { pattern: /<%\s*@.*%>/i, inside: { - 'page-directive tag': /<%\s*@\s*(?:Assembly|Control|Implements|Import|Master|MasterType|OutputCache|Page|PreviousPageType|Reference|Register)?|%>/i, + 'page-directive tag': /<%\s*@\s*(?:Assembly|Control|Implements|Import|Master(?:Type)?|OutputCache|Page|PreviousPageType|Reference|Register)?|%>/i, rest: Prism.languages.markup.tag.inside } }, @@ -14,6 +14,8 @@ Prism.languages.aspnet = Prism.languages.extend('markup', { } } }); +// Regexp copied from prism-markup, with a negative look-ahead added +Prism.languages.aspnet.tag.pattern = /<(?!%)\/?[^\s>\/]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i; // match directives of attribute value foo="<% Bar %>" Prism.languages.insertBefore('inside', 'punctuation', { diff --git a/components/prism-aspnet.min.js b/components/prism-aspnet.min.js index 71adac9259..f315148d36 100644 --- a/components/prism-aspnet.min.js +++ b/components/prism-aspnet.min.js @@ -1 +1 @@ -Prism.languages.aspnet=Prism.languages.extend("markup",{"page-directive tag":{pattern:/<%\s*@.*%>/i,inside:{"page-directive tag":/<%\s*@\s*(?:Assembly|Control|Implements|Import|Master|MasterType|OutputCache|Page|PreviousPageType|Reference|Register)?|%>/i,rest:Prism.languages.markup.tag.inside}},"directive tag":{pattern:/<%.*%>/i,inside:{"directive tag":/<%\s*?[$=%#:]{0,2}|%>/i,rest:Prism.languages.csharp}}}),Prism.languages.insertBefore("inside","punctuation",{"directive tag":Prism.languages.aspnet["directive tag"]},Prism.languages.aspnet.tag.inside["attr-value"]),Prism.languages.insertBefore("aspnet","comment",{"asp comment":/<%--[\w\W]*?--%>/}),Prism.languages.insertBefore("aspnet",Prism.languages.javascript?"script":"tag",{"asp script":{pattern:/[\w\W]*?<\/script>/i,inside:{tag:{pattern:/<\/?script\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|\w+))?\s*)*\/?>/i,inside:Prism.languages.aspnet.tag.inside},rest:Prism.languages.csharp||{}}}}),Prism.languages.aspnet.style&&(Prism.languages.aspnet.style.inside.tag.pattern=/<\/?style\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|\w+))?\s*)*\/?>/i,Prism.languages.aspnet.style.inside.tag.inside=Prism.languages.aspnet.tag.inside),Prism.languages.aspnet.script&&(Prism.languages.aspnet.script.inside.tag.pattern=Prism.languages.aspnet["asp script"].inside.tag.pattern,Prism.languages.aspnet.script.inside.tag.inside=Prism.languages.aspnet.tag.inside); \ No newline at end of file +Prism.languages.aspnet=Prism.languages.extend("markup",{"page-directive tag":{pattern:/<%\s*@.*%>/i,inside:{"page-directive tag":/<%\s*@\s*(?:Assembly|Control|Implements|Import|Master(?:Type)?|OutputCache|Page|PreviousPageType|Reference|Register)?|%>/i,rest:Prism.languages.markup.tag.inside}},"directive tag":{pattern:/<%.*%>/i,inside:{"directive tag":/<%\s*?[$=%#:]{0,2}|%>/i,rest:Prism.languages.csharp}}}),Prism.languages.aspnet.tag.pattern=/<(?!%)\/?[^\s>\/]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,Prism.languages.insertBefore("inside","punctuation",{"directive tag":Prism.languages.aspnet["directive tag"]},Prism.languages.aspnet.tag.inside["attr-value"]),Prism.languages.insertBefore("aspnet","comment",{"asp comment":/<%--[\w\W]*?--%>/}),Prism.languages.insertBefore("aspnet",Prism.languages.javascript?"script":"tag",{"asp script":{pattern:/[\w\W]*?<\/script>/i,inside:{tag:{pattern:/<\/?script\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|\w+))?\s*)*\/?>/i,inside:Prism.languages.aspnet.tag.inside},rest:Prism.languages.csharp||{}}}}),Prism.languages.aspnet.style&&(Prism.languages.aspnet.style.inside.tag.pattern=/<\/?style\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|\w+))?\s*)*\/?>/i,Prism.languages.aspnet.style.inside.tag.inside=Prism.languages.aspnet.tag.inside),Prism.languages.aspnet.script&&(Prism.languages.aspnet.script.inside.tag.pattern=Prism.languages.aspnet["asp script"].inside.tag.pattern,Prism.languages.aspnet.script.inside.tag.inside=Prism.languages.aspnet.tag.inside); \ No newline at end of file From 1f0a3364eed3939dfaea1fe3b1b274473c976e70 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sat, 11 Jul 2015 18:50:14 +0200 Subject: [PATCH 098/310] ASP.NET: Prevent Markup tags from breaking ASP tags + fix MasterType directive --- components/prism-aspnet.js | 4 +++- components/prism-aspnet.min.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/components/prism-aspnet.js b/components/prism-aspnet.js index 534a46ceba..291823e2a5 100644 --- a/components/prism-aspnet.js +++ b/components/prism-aspnet.js @@ -2,7 +2,7 @@ Prism.languages.aspnet = Prism.languages.extend('markup', { 'page-directive tag': { pattern: /<%\s*@.*%>/i, inside: { - 'page-directive tag': /<%\s*@\s*(?:Assembly|Control|Implements|Import|Master|MasterType|OutputCache|Page|PreviousPageType|Reference|Register)?|%>/i, + 'page-directive tag': /<%\s*@\s*(?:Assembly|Control|Implements|Import|Master(?:Type)?|OutputCache|Page|PreviousPageType|Reference|Register)?|%>/i, rest: Prism.languages.markup.tag.inside } }, @@ -14,6 +14,8 @@ Prism.languages.aspnet = Prism.languages.extend('markup', { } } }); +// Regexp copied from prism-markup, with a negative look-ahead added +Prism.languages.aspnet.tag.pattern = /<(?!%)\/?[^\s>\/]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i; // match directives of attribute value foo="<% Bar %>" Prism.languages.insertBefore('inside', 'punctuation', { diff --git a/components/prism-aspnet.min.js b/components/prism-aspnet.min.js index 71adac9259..f315148d36 100644 --- a/components/prism-aspnet.min.js +++ b/components/prism-aspnet.min.js @@ -1 +1 @@ -Prism.languages.aspnet=Prism.languages.extend("markup",{"page-directive tag":{pattern:/<%\s*@.*%>/i,inside:{"page-directive tag":/<%\s*@\s*(?:Assembly|Control|Implements|Import|Master|MasterType|OutputCache|Page|PreviousPageType|Reference|Register)?|%>/i,rest:Prism.languages.markup.tag.inside}},"directive tag":{pattern:/<%.*%>/i,inside:{"directive tag":/<%\s*?[$=%#:]{0,2}|%>/i,rest:Prism.languages.csharp}}}),Prism.languages.insertBefore("inside","punctuation",{"directive tag":Prism.languages.aspnet["directive tag"]},Prism.languages.aspnet.tag.inside["attr-value"]),Prism.languages.insertBefore("aspnet","comment",{"asp comment":/<%--[\w\W]*?--%>/}),Prism.languages.insertBefore("aspnet",Prism.languages.javascript?"script":"tag",{"asp script":{pattern:/[\w\W]*?<\/script>/i,inside:{tag:{pattern:/<\/?script\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|\w+))?\s*)*\/?>/i,inside:Prism.languages.aspnet.tag.inside},rest:Prism.languages.csharp||{}}}}),Prism.languages.aspnet.style&&(Prism.languages.aspnet.style.inside.tag.pattern=/<\/?style\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|\w+))?\s*)*\/?>/i,Prism.languages.aspnet.style.inside.tag.inside=Prism.languages.aspnet.tag.inside),Prism.languages.aspnet.script&&(Prism.languages.aspnet.script.inside.tag.pattern=Prism.languages.aspnet["asp script"].inside.tag.pattern,Prism.languages.aspnet.script.inside.tag.inside=Prism.languages.aspnet.tag.inside); \ No newline at end of file +Prism.languages.aspnet=Prism.languages.extend("markup",{"page-directive tag":{pattern:/<%\s*@.*%>/i,inside:{"page-directive tag":/<%\s*@\s*(?:Assembly|Control|Implements|Import|Master(?:Type)?|OutputCache|Page|PreviousPageType|Reference|Register)?|%>/i,rest:Prism.languages.markup.tag.inside}},"directive tag":{pattern:/<%.*%>/i,inside:{"directive tag":/<%\s*?[$=%#:]{0,2}|%>/i,rest:Prism.languages.csharp}}}),Prism.languages.aspnet.tag.pattern=/<(?!%)\/?[^\s>\/]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,Prism.languages.insertBefore("inside","punctuation",{"directive tag":Prism.languages.aspnet["directive tag"]},Prism.languages.aspnet.tag.inside["attr-value"]),Prism.languages.insertBefore("aspnet","comment",{"asp comment":/<%--[\w\W]*?--%>/}),Prism.languages.insertBefore("aspnet",Prism.languages.javascript?"script":"tag",{"asp script":{pattern:/[\w\W]*?<\/script>/i,inside:{tag:{pattern:/<\/?script\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|\w+))?\s*)*\/?>/i,inside:Prism.languages.aspnet.tag.inside},rest:Prism.languages.csharp||{}}}}),Prism.languages.aspnet.style&&(Prism.languages.aspnet.style.inside.tag.pattern=/<\/?style\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|\w+))?\s*)*\/?>/i,Prism.languages.aspnet.style.inside.tag.inside=Prism.languages.aspnet.tag.inside),Prism.languages.aspnet.script&&(Prism.languages.aspnet.script.inside.tag.pattern=Prism.languages.aspnet["asp script"].inside.tag.pattern,Prism.languages.aspnet.script.inside.tag.inside=Prism.languages.aspnet.tag.inside); \ No newline at end of file From d4194c93cfec0982a851a8a3dc1e89842ee72a64 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sat, 11 Jul 2015 18:56:55 +0200 Subject: [PATCH 099/310] C-like: use look-ahead instead of inside to match functions --- components/prism-clike.js | 7 +------ components/prism-clike.min.js | 2 +- prism.js | 7 +------ 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/components/prism-clike.js b/components/prism-clike.js index 57679cf2bc..c497995abc 100644 --- a/components/prism-clike.js +++ b/components/prism-clike.js @@ -19,12 +19,7 @@ Prism.languages.clike = { }, 'keyword': /\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/, 'boolean': /\b(true|false)\b/, - 'function': { - pattern: /[a-z0-9_]+\(/i, - inside: { - punctuation: /\(/ - } - }, + 'function': /[a-z0-9_]+(?=\()/i, 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/, 'operator': /[-+]{1,2}|!|<=?|>=?|={1,3}|&{1,2}|\|?\||\?|\*|\/|~|\^|%/, 'punctuation': /[{}[\];(),.:]/ diff --git a/components/prism-clike.min.js b/components/prism-clike.min.js index abae2a8322..f79d3a4aea 100644 --- a/components/prism-clike.min.js +++ b/components/prism-clike.min.js @@ -1 +1 @@ -Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:/("|')(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,"class-name":{pattern:/((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,"boolean":/\b(true|false)\b/,"function":{pattern:/[a-z0-9_]+\(/i,inside:{punctuation:/\(/}},number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,operator:/[-+]{1,2}|!|<=?|>=?|={1,3}|&{1,2}|\|?\||\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/}; \ No newline at end of file +Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:/("|')(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,"class-name":{pattern:/((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,"boolean":/\b(true|false)\b/,"function":/[a-z0-9_]+(?=\()/i,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,operator:/[-+]{1,2}|!|<=?|>=?|={1,3}|&{1,2}|\|?\||\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/}; \ No newline at end of file diff --git a/prism.js b/prism.js index bca193ab34..91fa896622 100644 --- a/prism.js +++ b/prism.js @@ -561,12 +561,7 @@ Prism.languages.clike = { }, 'keyword': /\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/, 'boolean': /\b(true|false)\b/, - 'function': { - pattern: /[a-z0-9_]+\(/i, - inside: { - punctuation: /\(/ - } - }, + 'function': /[a-z0-9_]+(?=\()/i, 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/, 'operator': /[-+]{1,2}|!|<=?|>=?|={1,3}|&{1,2}|\|?\||\?|\*|\/|~|\^|%/, 'punctuation': /[{}[\];(),.:]/ From 4e42e260c6d9ac597f1f3e322402808cbf6393e7 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sat, 11 Jul 2015 19:11:45 +0200 Subject: [PATCH 100/310] SCSS: Match placeholders inside selectors + alias other placeholders as selectors (fix #238) --- components/prism-scss.js | 12 ++++++++++-- components/prism-scss.min.js | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/components/prism-scss.js b/components/prism-scss.js index c798ff86e6..b7a872ac1e 100644 --- a/components/prism-scss.js +++ b/components/prism-scss.js @@ -19,7 +19,12 @@ Prism.languages.scss = Prism.languages.extend('css', { // the end of a selector is found when there is no rules in it ( {} or {\s}) or if there is a property (because an interpolated var // can "pass" as a selector- e.g: proper#{$erty}) // this one was ard to do, so please be careful if you edit this one :) - 'selector': /([^@;\{\}\(\)]?([^@;\{\}\(\)]|&|#\{\$[-_\w]+\})+)(?=\s*\{(\}|\s|[^\}]+(:|\{)[^\}]+))/m + 'selector': { + pattern: /([^@;\{\}\(\)]?([^@;\{\}\(\)]|&|#\{\$[-_\w]+\})+)(?=\s*\{(\}|\s|[^\}]+(:|\{)[^\}]+))/m, + inside: { + 'placeholder': /%[-_\w]+/i + } + } }); Prism.languages.insertBefore('scss', 'atrule', { @@ -32,7 +37,10 @@ Prism.languages.insertBefore('scss', 'property', { }); Prism.languages.insertBefore('scss', 'function', { - 'placeholder': /%[-_\w]+/i, + 'placeholder': { + pattern: /%[-_\w]+/i, + alias: 'selector' + }, 'statement': /\B!(default|optional)\b/i, 'boolean': /\b(true|false)\b/, 'null': /\b(null)\b/, diff --git a/components/prism-scss.min.js b/components/prism-scss.min.js index a7469c723c..d8837a441e 100644 --- a/components/prism-scss.min.js +++ b/components/prism-scss.min.js @@ -1 +1 @@ -Prism.languages.scss=Prism.languages.extend("css",{comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|\/\/.*?(\r?\n|$))/,lookbehind:!0},atrule:{pattern:/@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+(\{|;))/i,inside:{rule:/@[\w-]+/}},url:/([-a-z]+-)*url(?=\()/i,selector:/([^@;\{\}\(\)]?([^@;\{\}\(\)]|&|#\{\$[-_\w]+\})+)(?=\s*\{(\}|\s|[^\}]+(:|\{)[^\}]+))/m}),Prism.languages.insertBefore("scss","atrule",{keyword:/@(if|else if|else|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)|(?=@for\s+\$[-_\w]+\s)+from/i}),Prism.languages.insertBefore("scss","property",{variable:/((\$[-_\w]+)|(#\{\$[-_\w]+\}))/i}),Prism.languages.insertBefore("scss","function",{placeholder:/%[-_\w]+/i,statement:/\B!(default|optional)\b/i,"boolean":/\b(true|false)\b/,"null":/\b(null)\b/,operator:/\s+([-+]{1,2}|={1,2}|!=|\|?\||\?|\*|\/|%)\s+/}),Prism.languages.scss.atrule.inside.rest=Prism.util.clone(Prism.languages.scss); \ No newline at end of file +Prism.languages.scss=Prism.languages.extend("css",{comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|\/\/.*?(\r?\n|$))/,lookbehind:!0},atrule:{pattern:/@[\w-]+(?:\([^()]+\)|[^(])*?(?=\s+(\{|;))/i,inside:{rule:/@[\w-]+/}},url:/([-a-z]+-)*url(?=\()/i,selector:{pattern:/([^@;\{\}\(\)]?([^@;\{\}\(\)]|&|#\{\$[-_\w]+\})+)(?=\s*\{(\}|\s|[^\}]+(:|\{)[^\}]+))/m,inside:{placeholder:/%[-_\w]+/i}}}),Prism.languages.insertBefore("scss","atrule",{keyword:/@(if|else if|else|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)|(?=@for\s+\$[-_\w]+\s)+from/i}),Prism.languages.insertBefore("scss","property",{variable:/((\$[-_\w]+)|(#\{\$[-_\w]+\}))/i}),Prism.languages.insertBefore("scss","function",{placeholder:{pattern:/%[-_\w]+/i,alias:"selector"},statement:/\B!(default|optional)\b/i,"boolean":/\b(true|false)\b/,"null":/\b(null)\b/,operator:/\s+([-+]{1,2}|={1,2}|!=|\|?\||\?|\*|\/|%)\s+/}),Prism.languages.scss.atrule.inside.rest=Prism.util.clone(Prism.languages.scss); \ No newline at end of file From 0a1fc4b32d536ded55b946c97aa66dd1f16cb41f Mon Sep 17 00:00:00 2001 From: Golmote Date: Sat, 11 Jul 2015 19:29:50 +0200 Subject: [PATCH 101/310] AutoHotkey: allow tags (labels) to be highlighted at the end of the code --- components/prism-autohotkey.js | 2 +- components/prism-autohotkey.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/prism-autohotkey.js b/components/prism-autohotkey.js index c3bdebe65e..4b8694411d 100644 --- a/components/prism-autohotkey.js +++ b/components/prism-autohotkey.js @@ -6,7 +6,7 @@ Prism.languages.autohotkey= { }, 'string': /"(([^"\n\r]|"")*)"/m, 'function': /[^\(\); \t,\n\+\*\-=\?>:\\\/<&%\[\]]+?(?=\()/m, //function - don't use .*\) in the end bcoz string locks it - 'tag': /^[ \t]*[^\s:]+?(?=:[^:])/m, //labels + 'tag': /^[ \t]*[^\s:]+?(?=:(?:[^:]|$))/m, //labels 'variable': /%\w+%/, 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/, 'operator': /[\+\-\*\\\/:=\?&\|<>]/, diff --git a/components/prism-autohotkey.min.js b/components/prism-autohotkey.min.js index be036372ef..4d00538940 100644 --- a/components/prism-autohotkey.min.js +++ b/components/prism-autohotkey.min.js @@ -1 +1 @@ -Prism.languages.autohotkey={comment:{pattern:/(^[^";\n]*("[^"\n]*?"[^"\n]*?)*)(;.*$|^\s*\/\*[\s\S]*\n\*\/)/m,lookbehind:!0},string:/"(([^"\n\r]|"")*)"/m,"function":/[^\(\); \t,\n\+\*\-=\?>:\\\/<&%\[\]]+?(?=\()/m,tag:/^[ \t]*[^\s:]+?(?=:[^:])/m,variable:/%\w+%/,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,operator:/[\+\-\*\\\/:=\?&\|<>]/,punctuation:/[\{}[\]\(\):]/,"boolean":/\b(true|false)\b/,selector:/\b(AutoTrim|BlockInput|Break|Click|ClipWait|Continue|Control|ControlClick|ControlFocus|ControlGet|ControlGetFocus|ControlGetPos|ControlGetText|ControlMove|ControlSend|ControlSendRaw|ControlSetText|CoordMode|Critical|DetectHiddenText|DetectHiddenWindows|Drive|DriveGet|DriveSpaceFree|EnvAdd|EnvDiv|EnvGet|EnvMult|EnvSet|EnvSub|EnvUpdate|Exit|ExitApp|FileAppend|FileCopy|FileCopyDir|FileCreateDir|FileCreateShortcut|FileDelete|FileEncoding|FileGetAttrib|FileGetShortcut|FileGetSize|FileGetTime|FileGetVersion|FileInstall|FileMove|FileMoveDir|FileRead|FileReadLine|FileRecycle|FileRecycleEmpty|FileRemoveDir|FileSelectFile|FileSelectFolder|FileSetAttrib|FileSetTime|FormatTime|GetKeyState|Gosub|Goto|GroupActivate|GroupAdd|GroupClose|GroupDeactivate|Gui|GuiControl|GuiControlGet|Hotkey|ImageSearch|IniDelete|IniRead|IniWrite|Input|InputBox|KeyWait|ListHotkeys|ListLines|ListVars|Loop|Menu|MouseClick|MouseClickDrag|MouseGetPos|MouseMove|MsgBox|OnExit|OutputDebug|Pause|PixelGetColor|PixelSearch|PostMessage|Process|Progress|Random|RegDelete|RegRead|RegWrite|Reload|Repeat|Return|Run|RunAs|RunWait|Send|SendEvent|SendInput|SendMessage|SendMode|SendPlay|SendRaw|SetBatchLines|SetCapslockState|SetControlDelay|SetDefaultMouseSpeed|SetEnv|SetFormat|SetKeyDelay|SetMouseDelay|SetNumlockState|SetScrollLockState|SetStoreCapslockMode|SetTimer|SetTitleMatchMode|SetWinDelay|SetWorkingDir|Shutdown|Sleep|Sort|SoundBeep|SoundGet|SoundGetWaveVolume|SoundPlay|SoundSet|SoundSetWaveVolume|SplashImage|SplashTextOff|SplashTextOn|SplitPath|StatusBarGetText|StatusBarWait|StringCaseSense|StringGetPos|StringLeft|StringLen|StringLower|StringMid|StringReplace|StringRight|StringSplit|StringTrimLeft|StringTrimRight|StringUpper|Suspend|SysGet|Thread|ToolTip|Transform|TrayTip|URLDownloadToFile|WinActivate|WinActivateBottom|WinClose|WinGet|WinGetActiveStats|WinGetActiveTitle|WinGetClass|WinGetPos|WinGetText|WinGetTitle|WinHide|WinKill|WinMaximize|WinMenuSelectItem|WinMinimize|WinMinimizeAll|WinMinimizeAllUndo|WinMove|WinRestore|WinSet|WinSetTitle|WinShow|WinWait|WinWaitActive|WinWaitClose|WinWaitNotActive)\b/i,constant:/\b(a_ahkpath|a_ahkversion|a_appdata|a_appdatacommon|a_autotrim|a_batchlines|a_caretx|a_carety|a_computername|a_controldelay|a_cursor|a_dd|a_ddd|a_dddd|a_defaultmousespeed|a_desktop|a_desktopcommon|a_detecthiddentext|a_detecthiddenwindows|a_endchar|a_eventinfo|a_exitreason|a_formatfloat|a_formatinteger|a_gui|a_guievent|a_guicontrol|a_guicontrolevent|a_guiheight|a_guiwidth|a_guix|a_guiy|a_hour|a_iconfile|a_iconhidden|a_iconnumber|a_icontip|a_index|a_ipaddress1|a_ipaddress2|a_ipaddress3|a_ipaddress4|a_isadmin|a_iscompiled|a_iscritical|a_ispaused|a_issuspended|a_isunicode|a_keydelay|a_language|a_lasterror|a_linefile|a_linenumber|a_loopfield|a_loopfileattrib|a_loopfiledir|a_loopfileext|a_loopfilefullpath|a_loopfilelongpath|a_loopfilename|a_loopfileshortname|a_loopfileshortpath|a_loopfilesize|a_loopfilesizekb|a_loopfilesizemb|a_loopfiletimeaccessed|a_loopfiletimecreated|a_loopfiletimemodified|a_loopreadline|a_loopregkey|a_loopregname|a_loopregsubkey|a_loopregtimemodified|a_loopregtype|a_mday|a_min|a_mm|a_mmm|a_mmmm|a_mon|a_mousedelay|a_msec|a_mydocuments|a_now|a_nowutc|a_numbatchlines|a_ostype|a_osversion|a_priorhotkey|programfiles|a_programfiles|a_programs|a_programscommon|a_screenheight|a_screenwidth|a_scriptdir|a_scriptfullpath|a_scriptname|a_sec|a_space|a_startmenu|a_startmenucommon|a_startup|a_startupcommon|a_stringcasesense|a_tab|a_temp|a_thisfunc|a_thishotkey|a_thislabel|a_thismenu|a_thismenuitem|a_thismenuitempos|a_tickcount|a_timeidle|a_timeidlephysical|a_timesincepriorhotkey|a_timesincethishotkey|a_titlematchmode|a_titlematchmodespeed|a_username|a_wday|a_windelay|a_windir|a_workingdir|a_yday|a_year|a_yweek|a_yyyy|clipboard|clipboardall|comspec|errorlevel)\b/i,builtin:/\b(abs|acos|asc|asin|atan|ceil|chr|class|cos|dllcall|exp|fileexist|Fileopen|floor|getkeystate|il_add|il_create|il_destroy|instr|substr|isfunc|islabel|IsObject|ln|log|lv_add|lv_delete|lv_deletecol|lv_getcount|lv_getnext|lv_gettext|lv_insert|lv_insertcol|lv_modify|lv_modifycol|lv_setimagelist|mod|onmessage|numget|numput|registercallback|regexmatch|regexreplace|round|sin|tan|sqrt|strlen|sb_seticon|sb_setparts|sb_settext|strsplit|tv_add|tv_delete|tv_getchild|tv_getcount|tv_getnext|tv_get|tv_getparent|tv_getprev|tv_getselection|tv_gettext|tv_modify|varsetcapacity|winactive|winexist|__New|__Call|__Get|__Set)\b/i,symbol:/\b(alt|altdown|altup|appskey|backspace|browser_back|browser_favorites|browser_forward|browser_home|browser_refresh|browser_search|browser_stop|bs|capslock|control|ctrl|ctrlbreak|ctrldown|ctrlup|del|delete|down|end|enter|esc|escape|f1|f10|f11|f12|f13|f14|f15|f16|f17|f18|f19|f2|f20|f21|f22|f23|f24|f3|f4|f5|f6|f7|f8|f9|home|ins|insert|joy1|joy10|joy11|joy12|joy13|joy14|joy15|joy16|joy17|joy18|joy19|joy2|joy20|joy21|joy22|joy23|joy24|joy25|joy26|joy27|joy28|joy29|joy3|joy30|joy31|joy32|joy4|joy5|joy6|joy7|joy8|joy9|joyaxes|joybuttons|joyinfo|joyname|joypov|joyr|joyu|joyv|joyx|joyy|joyz|lalt|launch_app1|launch_app2|launch_mail|launch_media|lbutton|lcontrol|lctrl|left|lshift|lwin|lwindown|lwinup|mbutton|media_next|media_play_pause|media_prev|media_stop|numlock|numpad0|numpad1|numpad2|numpad3|numpad4|numpad5|numpad6|numpad7|numpad8|numpad9|numpadadd|numpadclear|numpaddel|numpaddiv|numpaddot|numpaddown|numpadend|numpadenter|numpadhome|numpadins|numpadleft|numpadmult|numpadpgdn|numpadpgup|numpadright|numpadsub|numpadup|pause|pgdn|pgup|printscreen|ralt|rbutton|rcontrol|rctrl|right|rshift|rwin|rwindown|rwinup|scrolllock|shift|shiftdown|shiftup|space|tab|up|volume_down|volume_mute|volume_up|wheeldown|wheelleft|wheelright|wheelup|xbutton1|xbutton2)\b/i,important:/#\b(AllowSameLineComments|ClipboardTimeout|CommentFlag|ErrorStdOut|EscapeChar|HotkeyInterval|HotkeyModifierTimeout|Hotstring|IfWinActive|IfWinExist|IfWinNotActive|IfWinNotExist|Include|IncludeAgain|InstallKeybdHook|InstallMouseHook|KeyHistory|LTrim|MaxHotkeysPerInterval|MaxMem|MaxThreads|MaxThreadsBuffer|MaxThreadsPerHotkey|NoEnv|NoTrayIcon|Persistent|SingleInstance|UseHook|WinActivateForce)\b/i,keyword:/\b(Abort|AboveNormal|Add|ahk_class|ahk_group|ahk_id|ahk_pid|All|Alnum|Alpha|AltSubmit|AltTab|AltTabAndMenu|AltTabMenu|AltTabMenuDismiss|AlwaysOnTop|AutoSize|Background|BackgroundTrans|BelowNormal|between|BitAnd|BitNot|BitOr|BitShiftLeft|BitShiftRight|BitXOr|Bold|Border|Button|ByRef|Checkbox|Checked|CheckedGray|Choose|ChooseString|Click|Close|Color|ComboBox|Contains|ControlList|Count|Date|DateTime|Days|DDL|Default|Delete|DeleteAll|Delimiter|Deref|Destroy|Digit|Disable|Disabled|DropDownList|Edit|Eject|Else|Enable|Enabled|Error|Exist|Exp|Expand|ExStyle|FileSystem|First|Flash|Float|FloatFast|Focus|Font|for|global|Grid|Group|GroupBox|GuiClose|GuiContextMenu|GuiDropFiles|GuiEscape|GuiSize|Hdr|Hidden|Hide|High|HKCC|HKCR|HKCU|HKEY_CLASSES_ROOT|HKEY_CURRENT_CONFIG|HKEY_CURRENT_USER|HKEY_LOCAL_MACHINE|HKEY_USERS|HKLM|HKU|Hours|HScroll|Icon|IconSmall|ID|IDLast|If|IfEqual|IfExist|IfGreater|IfGreaterOrEqual|IfInString|IfLess|IfLessOrEqual|IfMsgBox|IfNotEqual|IfNotExist|IfNotInString|IfWinActive|IfWinExist|IfWinNotActive|IfWinNotExist|Ignore|ImageList|in|Integer|IntegerFast|Interrupt|is|italic|Join|Label|LastFound|LastFoundExist|Limit|Lines|List|ListBox|ListView|Ln|local|Lock|Logoff|Low|Lower|Lowercase|MainWindow|Margin|Maximize|MaximizeBox|MaxSize|Minimize|MinimizeBox|MinMax|MinSize|Minutes|MonthCal|Mouse|Move|Multi|NA|No|NoActivate|NoDefault|NoHide|NoIcon|NoMainWindow|norm|Normal|NoSort|NoSortHdr|NoStandard|Not|NoTab|NoTimers|Number|Off|Ok|On|OwnDialogs|Owner|Parse|Password|Picture|Pixel|Pos|Pow|Priority|ProcessName|Radio|Range|Read|ReadOnly|Realtime|Redraw|REG_BINARY|REG_DWORD|REG_EXPAND_SZ|REG_MULTI_SZ|REG_SZ|Region|Relative|Rename|Report|Resize|Restore|Retry|RGB|Right|Screen|Seconds|Section|Serial|SetLabel|ShiftAltTab|Show|Single|Slider|SortDesc|Standard|static|Status|StatusBar|StatusCD|strike|Style|Submit|SysMenu|Tab|Tab2|TabStop|Text|Theme|Tile|ToggleCheck|ToggleEnable|ToolWindow|Top|Topmost|TransColor|Transparent|Tray|TreeView|TryAgain|Type|UnCheck|underline|Unicode|Unlock|UpDown|Upper|Uppercase|UseErrorLevel|Vis|VisFirst|Visible|VScroll|Wait|WaitClose|WantCtrlA|WantF2|WantReturn|While|Wrap|Xdigit|xm|xp|xs|Yes|ym|yp|ys)\b/i}; \ No newline at end of file +Prism.languages.autohotkey={comment:{pattern:/(^[^";\n]*("[^"\n]*?"[^"\n]*?)*)(;.*$|^\s*\/\*[\s\S]*\n\*\/)/m,lookbehind:!0},string:/"(([^"\n\r]|"")*)"/m,"function":/[^\(\); \t,\n\+\*\-=\?>:\\\/<&%\[\]]+?(?=\()/m,tag:/^[ \t]*[^\s:]+?(?=:(?:[^:]|$))/m,variable:/%\w+%/,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,operator:/[\+\-\*\\\/:=\?&\|<>]/,punctuation:/[\{}[\]\(\):]/,"boolean":/\b(true|false)\b/,selector:/\b(AutoTrim|BlockInput|Break|Click|ClipWait|Continue|Control|ControlClick|ControlFocus|ControlGet|ControlGetFocus|ControlGetPos|ControlGetText|ControlMove|ControlSend|ControlSendRaw|ControlSetText|CoordMode|Critical|DetectHiddenText|DetectHiddenWindows|Drive|DriveGet|DriveSpaceFree|EnvAdd|EnvDiv|EnvGet|EnvMult|EnvSet|EnvSub|EnvUpdate|Exit|ExitApp|FileAppend|FileCopy|FileCopyDir|FileCreateDir|FileCreateShortcut|FileDelete|FileEncoding|FileGetAttrib|FileGetShortcut|FileGetSize|FileGetTime|FileGetVersion|FileInstall|FileMove|FileMoveDir|FileRead|FileReadLine|FileRecycle|FileRecycleEmpty|FileRemoveDir|FileSelectFile|FileSelectFolder|FileSetAttrib|FileSetTime|FormatTime|GetKeyState|Gosub|Goto|GroupActivate|GroupAdd|GroupClose|GroupDeactivate|Gui|GuiControl|GuiControlGet|Hotkey|ImageSearch|IniDelete|IniRead|IniWrite|Input|InputBox|KeyWait|ListHotkeys|ListLines|ListVars|Loop|Menu|MouseClick|MouseClickDrag|MouseGetPos|MouseMove|MsgBox|OnExit|OutputDebug|Pause|PixelGetColor|PixelSearch|PostMessage|Process|Progress|Random|RegDelete|RegRead|RegWrite|Reload|Repeat|Return|Run|RunAs|RunWait|Send|SendEvent|SendInput|SendMessage|SendMode|SendPlay|SendRaw|SetBatchLines|SetCapslockState|SetControlDelay|SetDefaultMouseSpeed|SetEnv|SetFormat|SetKeyDelay|SetMouseDelay|SetNumlockState|SetScrollLockState|SetStoreCapslockMode|SetTimer|SetTitleMatchMode|SetWinDelay|SetWorkingDir|Shutdown|Sleep|Sort|SoundBeep|SoundGet|SoundGetWaveVolume|SoundPlay|SoundSet|SoundSetWaveVolume|SplashImage|SplashTextOff|SplashTextOn|SplitPath|StatusBarGetText|StatusBarWait|StringCaseSense|StringGetPos|StringLeft|StringLen|StringLower|StringMid|StringReplace|StringRight|StringSplit|StringTrimLeft|StringTrimRight|StringUpper|Suspend|SysGet|Thread|ToolTip|Transform|TrayTip|URLDownloadToFile|WinActivate|WinActivateBottom|WinClose|WinGet|WinGetActiveStats|WinGetActiveTitle|WinGetClass|WinGetPos|WinGetText|WinGetTitle|WinHide|WinKill|WinMaximize|WinMenuSelectItem|WinMinimize|WinMinimizeAll|WinMinimizeAllUndo|WinMove|WinRestore|WinSet|WinSetTitle|WinShow|WinWait|WinWaitActive|WinWaitClose|WinWaitNotActive)\b/i,constant:/\b(a_ahkpath|a_ahkversion|a_appdata|a_appdatacommon|a_autotrim|a_batchlines|a_caretx|a_carety|a_computername|a_controldelay|a_cursor|a_dd|a_ddd|a_dddd|a_defaultmousespeed|a_desktop|a_desktopcommon|a_detecthiddentext|a_detecthiddenwindows|a_endchar|a_eventinfo|a_exitreason|a_formatfloat|a_formatinteger|a_gui|a_guievent|a_guicontrol|a_guicontrolevent|a_guiheight|a_guiwidth|a_guix|a_guiy|a_hour|a_iconfile|a_iconhidden|a_iconnumber|a_icontip|a_index|a_ipaddress1|a_ipaddress2|a_ipaddress3|a_ipaddress4|a_isadmin|a_iscompiled|a_iscritical|a_ispaused|a_issuspended|a_isunicode|a_keydelay|a_language|a_lasterror|a_linefile|a_linenumber|a_loopfield|a_loopfileattrib|a_loopfiledir|a_loopfileext|a_loopfilefullpath|a_loopfilelongpath|a_loopfilename|a_loopfileshortname|a_loopfileshortpath|a_loopfilesize|a_loopfilesizekb|a_loopfilesizemb|a_loopfiletimeaccessed|a_loopfiletimecreated|a_loopfiletimemodified|a_loopreadline|a_loopregkey|a_loopregname|a_loopregsubkey|a_loopregtimemodified|a_loopregtype|a_mday|a_min|a_mm|a_mmm|a_mmmm|a_mon|a_mousedelay|a_msec|a_mydocuments|a_now|a_nowutc|a_numbatchlines|a_ostype|a_osversion|a_priorhotkey|programfiles|a_programfiles|a_programs|a_programscommon|a_screenheight|a_screenwidth|a_scriptdir|a_scriptfullpath|a_scriptname|a_sec|a_space|a_startmenu|a_startmenucommon|a_startup|a_startupcommon|a_stringcasesense|a_tab|a_temp|a_thisfunc|a_thishotkey|a_thislabel|a_thismenu|a_thismenuitem|a_thismenuitempos|a_tickcount|a_timeidle|a_timeidlephysical|a_timesincepriorhotkey|a_timesincethishotkey|a_titlematchmode|a_titlematchmodespeed|a_username|a_wday|a_windelay|a_windir|a_workingdir|a_yday|a_year|a_yweek|a_yyyy|clipboard|clipboardall|comspec|errorlevel)\b/i,builtin:/\b(abs|acos|asc|asin|atan|ceil|chr|class|cos|dllcall|exp|fileexist|Fileopen|floor|getkeystate|il_add|il_create|il_destroy|instr|substr|isfunc|islabel|IsObject|ln|log|lv_add|lv_delete|lv_deletecol|lv_getcount|lv_getnext|lv_gettext|lv_insert|lv_insertcol|lv_modify|lv_modifycol|lv_setimagelist|mod|onmessage|numget|numput|registercallback|regexmatch|regexreplace|round|sin|tan|sqrt|strlen|sb_seticon|sb_setparts|sb_settext|strsplit|tv_add|tv_delete|tv_getchild|tv_getcount|tv_getnext|tv_get|tv_getparent|tv_getprev|tv_getselection|tv_gettext|tv_modify|varsetcapacity|winactive|winexist|__New|__Call|__Get|__Set)\b/i,symbol:/\b(alt|altdown|altup|appskey|backspace|browser_back|browser_favorites|browser_forward|browser_home|browser_refresh|browser_search|browser_stop|bs|capslock|control|ctrl|ctrlbreak|ctrldown|ctrlup|del|delete|down|end|enter|esc|escape|f1|f10|f11|f12|f13|f14|f15|f16|f17|f18|f19|f2|f20|f21|f22|f23|f24|f3|f4|f5|f6|f7|f8|f9|home|ins|insert|joy1|joy10|joy11|joy12|joy13|joy14|joy15|joy16|joy17|joy18|joy19|joy2|joy20|joy21|joy22|joy23|joy24|joy25|joy26|joy27|joy28|joy29|joy3|joy30|joy31|joy32|joy4|joy5|joy6|joy7|joy8|joy9|joyaxes|joybuttons|joyinfo|joyname|joypov|joyr|joyu|joyv|joyx|joyy|joyz|lalt|launch_app1|launch_app2|launch_mail|launch_media|lbutton|lcontrol|lctrl|left|lshift|lwin|lwindown|lwinup|mbutton|media_next|media_play_pause|media_prev|media_stop|numlock|numpad0|numpad1|numpad2|numpad3|numpad4|numpad5|numpad6|numpad7|numpad8|numpad9|numpadadd|numpadclear|numpaddel|numpaddiv|numpaddot|numpaddown|numpadend|numpadenter|numpadhome|numpadins|numpadleft|numpadmult|numpadpgdn|numpadpgup|numpadright|numpadsub|numpadup|pause|pgdn|pgup|printscreen|ralt|rbutton|rcontrol|rctrl|right|rshift|rwin|rwindown|rwinup|scrolllock|shift|shiftdown|shiftup|space|tab|up|volume_down|volume_mute|volume_up|wheeldown|wheelleft|wheelright|wheelup|xbutton1|xbutton2)\b/i,important:/#\b(AllowSameLineComments|ClipboardTimeout|CommentFlag|ErrorStdOut|EscapeChar|HotkeyInterval|HotkeyModifierTimeout|Hotstring|IfWinActive|IfWinExist|IfWinNotActive|IfWinNotExist|Include|IncludeAgain|InstallKeybdHook|InstallMouseHook|KeyHistory|LTrim|MaxHotkeysPerInterval|MaxMem|MaxThreads|MaxThreadsBuffer|MaxThreadsPerHotkey|NoEnv|NoTrayIcon|Persistent|SingleInstance|UseHook|WinActivateForce)\b/i,keyword:/\b(Abort|AboveNormal|Add|ahk_class|ahk_group|ahk_id|ahk_pid|All|Alnum|Alpha|AltSubmit|AltTab|AltTabAndMenu|AltTabMenu|AltTabMenuDismiss|AlwaysOnTop|AutoSize|Background|BackgroundTrans|BelowNormal|between|BitAnd|BitNot|BitOr|BitShiftLeft|BitShiftRight|BitXOr|Bold|Border|Button|ByRef|Checkbox|Checked|CheckedGray|Choose|ChooseString|Click|Close|Color|ComboBox|Contains|ControlList|Count|Date|DateTime|Days|DDL|Default|Delete|DeleteAll|Delimiter|Deref|Destroy|Digit|Disable|Disabled|DropDownList|Edit|Eject|Else|Enable|Enabled|Error|Exist|Exp|Expand|ExStyle|FileSystem|First|Flash|Float|FloatFast|Focus|Font|for|global|Grid|Group|GroupBox|GuiClose|GuiContextMenu|GuiDropFiles|GuiEscape|GuiSize|Hdr|Hidden|Hide|High|HKCC|HKCR|HKCU|HKEY_CLASSES_ROOT|HKEY_CURRENT_CONFIG|HKEY_CURRENT_USER|HKEY_LOCAL_MACHINE|HKEY_USERS|HKLM|HKU|Hours|HScroll|Icon|IconSmall|ID|IDLast|If|IfEqual|IfExist|IfGreater|IfGreaterOrEqual|IfInString|IfLess|IfLessOrEqual|IfMsgBox|IfNotEqual|IfNotExist|IfNotInString|IfWinActive|IfWinExist|IfWinNotActive|IfWinNotExist|Ignore|ImageList|in|Integer|IntegerFast|Interrupt|is|italic|Join|Label|LastFound|LastFoundExist|Limit|Lines|List|ListBox|ListView|Ln|local|Lock|Logoff|Low|Lower|Lowercase|MainWindow|Margin|Maximize|MaximizeBox|MaxSize|Minimize|MinimizeBox|MinMax|MinSize|Minutes|MonthCal|Mouse|Move|Multi|NA|No|NoActivate|NoDefault|NoHide|NoIcon|NoMainWindow|norm|Normal|NoSort|NoSortHdr|NoStandard|Not|NoTab|NoTimers|Number|Off|Ok|On|OwnDialogs|Owner|Parse|Password|Picture|Pixel|Pos|Pow|Priority|ProcessName|Radio|Range|Read|ReadOnly|Realtime|Redraw|REG_BINARY|REG_DWORD|REG_EXPAND_SZ|REG_MULTI_SZ|REG_SZ|Region|Relative|Rename|Report|Resize|Restore|Retry|RGB|Right|Screen|Seconds|Section|Serial|SetLabel|ShiftAltTab|Show|Single|Slider|SortDesc|Standard|static|Status|StatusBar|StatusCD|strike|Style|Submit|SysMenu|Tab|Tab2|TabStop|Text|Theme|Tile|ToggleCheck|ToggleEnable|ToolWindow|Top|Topmost|TransColor|Transparent|Tray|TreeView|TryAgain|Type|UnCheck|underline|Unicode|Unlock|UpDown|Upper|Uppercase|UseErrorLevel|Vis|VisFirst|Visible|VScroll|Wait|WaitClose|WantCtrlA|WantF2|WantReturn|While|Wrap|Xdigit|xm|xp|xs|Yes|ym|yp|ys)\b/i}; \ No newline at end of file From f0ccb1b0fe390e7840769f5beccc2b83330f5fa8 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sat, 11 Jul 2015 19:48:16 +0200 Subject: [PATCH 102/310] AutoHotkey: match all operators + add comma to punctuation --- components/prism-autohotkey.js | 4 ++-- components/prism-autohotkey.min.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/prism-autohotkey.js b/components/prism-autohotkey.js index 4b8694411d..223309527f 100644 --- a/components/prism-autohotkey.js +++ b/components/prism-autohotkey.js @@ -9,8 +9,8 @@ Prism.languages.autohotkey= { 'tag': /^[ \t]*[^\s:]+?(?=:(?:[^:]|$))/m, //labels 'variable': /%\w+%/, 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/, - 'operator': /[\+\-\*\\\/:=\?&\|<>]/, - 'punctuation': /[\{}[\]\(\):]/, + 'operator': /\?|\/\/?=?|:=|\|[=|]?|&[=&]?|\+[=+]?|-[=-]?|\*[=*]?|<(?:<=?|>|=)?|>>?=?|[.^!=~]=?|\b(?:AND|NOT|OR)\b/, + 'punctuation': /[\{}[\]\(\):,]/, 'boolean': /\b(true|false)\b/, 'selector': /\b(AutoTrim|BlockInput|Break|Click|ClipWait|Continue|Control|ControlClick|ControlFocus|ControlGet|ControlGetFocus|ControlGetPos|ControlGetText|ControlMove|ControlSend|ControlSendRaw|ControlSetText|CoordMode|Critical|DetectHiddenText|DetectHiddenWindows|Drive|DriveGet|DriveSpaceFree|EnvAdd|EnvDiv|EnvGet|EnvMult|EnvSet|EnvSub|EnvUpdate|Exit|ExitApp|FileAppend|FileCopy|FileCopyDir|FileCreateDir|FileCreateShortcut|FileDelete|FileEncoding|FileGetAttrib|FileGetShortcut|FileGetSize|FileGetTime|FileGetVersion|FileInstall|FileMove|FileMoveDir|FileRead|FileReadLine|FileRecycle|FileRecycleEmpty|FileRemoveDir|FileSelectFile|FileSelectFolder|FileSetAttrib|FileSetTime|FormatTime|GetKeyState|Gosub|Goto|GroupActivate|GroupAdd|GroupClose|GroupDeactivate|Gui|GuiControl|GuiControlGet|Hotkey|ImageSearch|IniDelete|IniRead|IniWrite|Input|InputBox|KeyWait|ListHotkeys|ListLines|ListVars|Loop|Menu|MouseClick|MouseClickDrag|MouseGetPos|MouseMove|MsgBox|OnExit|OutputDebug|Pause|PixelGetColor|PixelSearch|PostMessage|Process|Progress|Random|RegDelete|RegRead|RegWrite|Reload|Repeat|Return|Run|RunAs|RunWait|Send|SendEvent|SendInput|SendMessage|SendMode|SendPlay|SendRaw|SetBatchLines|SetCapslockState|SetControlDelay|SetDefaultMouseSpeed|SetEnv|SetFormat|SetKeyDelay|SetMouseDelay|SetNumlockState|SetScrollLockState|SetStoreCapslockMode|SetTimer|SetTitleMatchMode|SetWinDelay|SetWorkingDir|Shutdown|Sleep|Sort|SoundBeep|SoundGet|SoundGetWaveVolume|SoundPlay|SoundSet|SoundSetWaveVolume|SplashImage|SplashTextOff|SplashTextOn|SplitPath|StatusBarGetText|StatusBarWait|StringCaseSense|StringGetPos|StringLeft|StringLen|StringLower|StringMid|StringReplace|StringRight|StringSplit|StringTrimLeft|StringTrimRight|StringUpper|Suspend|SysGet|Thread|ToolTip|Transform|TrayTip|URLDownloadToFile|WinActivate|WinActivateBottom|WinClose|WinGet|WinGetActiveStats|WinGetActiveTitle|WinGetClass|WinGetPos|WinGetText|WinGetTitle|WinHide|WinKill|WinMaximize|WinMenuSelectItem|WinMinimize|WinMinimizeAll|WinMinimizeAllUndo|WinMove|WinRestore|WinSet|WinSetTitle|WinShow|WinWait|WinWaitActive|WinWaitClose|WinWaitNotActive)\b/i, diff --git a/components/prism-autohotkey.min.js b/components/prism-autohotkey.min.js index 4d00538940..c15fa0f54e 100644 --- a/components/prism-autohotkey.min.js +++ b/components/prism-autohotkey.min.js @@ -1 +1 @@ -Prism.languages.autohotkey={comment:{pattern:/(^[^";\n]*("[^"\n]*?"[^"\n]*?)*)(;.*$|^\s*\/\*[\s\S]*\n\*\/)/m,lookbehind:!0},string:/"(([^"\n\r]|"")*)"/m,"function":/[^\(\); \t,\n\+\*\-=\?>:\\\/<&%\[\]]+?(?=\()/m,tag:/^[ \t]*[^\s:]+?(?=:(?:[^:]|$))/m,variable:/%\w+%/,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,operator:/[\+\-\*\\\/:=\?&\|<>]/,punctuation:/[\{}[\]\(\):]/,"boolean":/\b(true|false)\b/,selector:/\b(AutoTrim|BlockInput|Break|Click|ClipWait|Continue|Control|ControlClick|ControlFocus|ControlGet|ControlGetFocus|ControlGetPos|ControlGetText|ControlMove|ControlSend|ControlSendRaw|ControlSetText|CoordMode|Critical|DetectHiddenText|DetectHiddenWindows|Drive|DriveGet|DriveSpaceFree|EnvAdd|EnvDiv|EnvGet|EnvMult|EnvSet|EnvSub|EnvUpdate|Exit|ExitApp|FileAppend|FileCopy|FileCopyDir|FileCreateDir|FileCreateShortcut|FileDelete|FileEncoding|FileGetAttrib|FileGetShortcut|FileGetSize|FileGetTime|FileGetVersion|FileInstall|FileMove|FileMoveDir|FileRead|FileReadLine|FileRecycle|FileRecycleEmpty|FileRemoveDir|FileSelectFile|FileSelectFolder|FileSetAttrib|FileSetTime|FormatTime|GetKeyState|Gosub|Goto|GroupActivate|GroupAdd|GroupClose|GroupDeactivate|Gui|GuiControl|GuiControlGet|Hotkey|ImageSearch|IniDelete|IniRead|IniWrite|Input|InputBox|KeyWait|ListHotkeys|ListLines|ListVars|Loop|Menu|MouseClick|MouseClickDrag|MouseGetPos|MouseMove|MsgBox|OnExit|OutputDebug|Pause|PixelGetColor|PixelSearch|PostMessage|Process|Progress|Random|RegDelete|RegRead|RegWrite|Reload|Repeat|Return|Run|RunAs|RunWait|Send|SendEvent|SendInput|SendMessage|SendMode|SendPlay|SendRaw|SetBatchLines|SetCapslockState|SetControlDelay|SetDefaultMouseSpeed|SetEnv|SetFormat|SetKeyDelay|SetMouseDelay|SetNumlockState|SetScrollLockState|SetStoreCapslockMode|SetTimer|SetTitleMatchMode|SetWinDelay|SetWorkingDir|Shutdown|Sleep|Sort|SoundBeep|SoundGet|SoundGetWaveVolume|SoundPlay|SoundSet|SoundSetWaveVolume|SplashImage|SplashTextOff|SplashTextOn|SplitPath|StatusBarGetText|StatusBarWait|StringCaseSense|StringGetPos|StringLeft|StringLen|StringLower|StringMid|StringReplace|StringRight|StringSplit|StringTrimLeft|StringTrimRight|StringUpper|Suspend|SysGet|Thread|ToolTip|Transform|TrayTip|URLDownloadToFile|WinActivate|WinActivateBottom|WinClose|WinGet|WinGetActiveStats|WinGetActiveTitle|WinGetClass|WinGetPos|WinGetText|WinGetTitle|WinHide|WinKill|WinMaximize|WinMenuSelectItem|WinMinimize|WinMinimizeAll|WinMinimizeAllUndo|WinMove|WinRestore|WinSet|WinSetTitle|WinShow|WinWait|WinWaitActive|WinWaitClose|WinWaitNotActive)\b/i,constant:/\b(a_ahkpath|a_ahkversion|a_appdata|a_appdatacommon|a_autotrim|a_batchlines|a_caretx|a_carety|a_computername|a_controldelay|a_cursor|a_dd|a_ddd|a_dddd|a_defaultmousespeed|a_desktop|a_desktopcommon|a_detecthiddentext|a_detecthiddenwindows|a_endchar|a_eventinfo|a_exitreason|a_formatfloat|a_formatinteger|a_gui|a_guievent|a_guicontrol|a_guicontrolevent|a_guiheight|a_guiwidth|a_guix|a_guiy|a_hour|a_iconfile|a_iconhidden|a_iconnumber|a_icontip|a_index|a_ipaddress1|a_ipaddress2|a_ipaddress3|a_ipaddress4|a_isadmin|a_iscompiled|a_iscritical|a_ispaused|a_issuspended|a_isunicode|a_keydelay|a_language|a_lasterror|a_linefile|a_linenumber|a_loopfield|a_loopfileattrib|a_loopfiledir|a_loopfileext|a_loopfilefullpath|a_loopfilelongpath|a_loopfilename|a_loopfileshortname|a_loopfileshortpath|a_loopfilesize|a_loopfilesizekb|a_loopfilesizemb|a_loopfiletimeaccessed|a_loopfiletimecreated|a_loopfiletimemodified|a_loopreadline|a_loopregkey|a_loopregname|a_loopregsubkey|a_loopregtimemodified|a_loopregtype|a_mday|a_min|a_mm|a_mmm|a_mmmm|a_mon|a_mousedelay|a_msec|a_mydocuments|a_now|a_nowutc|a_numbatchlines|a_ostype|a_osversion|a_priorhotkey|programfiles|a_programfiles|a_programs|a_programscommon|a_screenheight|a_screenwidth|a_scriptdir|a_scriptfullpath|a_scriptname|a_sec|a_space|a_startmenu|a_startmenucommon|a_startup|a_startupcommon|a_stringcasesense|a_tab|a_temp|a_thisfunc|a_thishotkey|a_thislabel|a_thismenu|a_thismenuitem|a_thismenuitempos|a_tickcount|a_timeidle|a_timeidlephysical|a_timesincepriorhotkey|a_timesincethishotkey|a_titlematchmode|a_titlematchmodespeed|a_username|a_wday|a_windelay|a_windir|a_workingdir|a_yday|a_year|a_yweek|a_yyyy|clipboard|clipboardall|comspec|errorlevel)\b/i,builtin:/\b(abs|acos|asc|asin|atan|ceil|chr|class|cos|dllcall|exp|fileexist|Fileopen|floor|getkeystate|il_add|il_create|il_destroy|instr|substr|isfunc|islabel|IsObject|ln|log|lv_add|lv_delete|lv_deletecol|lv_getcount|lv_getnext|lv_gettext|lv_insert|lv_insertcol|lv_modify|lv_modifycol|lv_setimagelist|mod|onmessage|numget|numput|registercallback|regexmatch|regexreplace|round|sin|tan|sqrt|strlen|sb_seticon|sb_setparts|sb_settext|strsplit|tv_add|tv_delete|tv_getchild|tv_getcount|tv_getnext|tv_get|tv_getparent|tv_getprev|tv_getselection|tv_gettext|tv_modify|varsetcapacity|winactive|winexist|__New|__Call|__Get|__Set)\b/i,symbol:/\b(alt|altdown|altup|appskey|backspace|browser_back|browser_favorites|browser_forward|browser_home|browser_refresh|browser_search|browser_stop|bs|capslock|control|ctrl|ctrlbreak|ctrldown|ctrlup|del|delete|down|end|enter|esc|escape|f1|f10|f11|f12|f13|f14|f15|f16|f17|f18|f19|f2|f20|f21|f22|f23|f24|f3|f4|f5|f6|f7|f8|f9|home|ins|insert|joy1|joy10|joy11|joy12|joy13|joy14|joy15|joy16|joy17|joy18|joy19|joy2|joy20|joy21|joy22|joy23|joy24|joy25|joy26|joy27|joy28|joy29|joy3|joy30|joy31|joy32|joy4|joy5|joy6|joy7|joy8|joy9|joyaxes|joybuttons|joyinfo|joyname|joypov|joyr|joyu|joyv|joyx|joyy|joyz|lalt|launch_app1|launch_app2|launch_mail|launch_media|lbutton|lcontrol|lctrl|left|lshift|lwin|lwindown|lwinup|mbutton|media_next|media_play_pause|media_prev|media_stop|numlock|numpad0|numpad1|numpad2|numpad3|numpad4|numpad5|numpad6|numpad7|numpad8|numpad9|numpadadd|numpadclear|numpaddel|numpaddiv|numpaddot|numpaddown|numpadend|numpadenter|numpadhome|numpadins|numpadleft|numpadmult|numpadpgdn|numpadpgup|numpadright|numpadsub|numpadup|pause|pgdn|pgup|printscreen|ralt|rbutton|rcontrol|rctrl|right|rshift|rwin|rwindown|rwinup|scrolllock|shift|shiftdown|shiftup|space|tab|up|volume_down|volume_mute|volume_up|wheeldown|wheelleft|wheelright|wheelup|xbutton1|xbutton2)\b/i,important:/#\b(AllowSameLineComments|ClipboardTimeout|CommentFlag|ErrorStdOut|EscapeChar|HotkeyInterval|HotkeyModifierTimeout|Hotstring|IfWinActive|IfWinExist|IfWinNotActive|IfWinNotExist|Include|IncludeAgain|InstallKeybdHook|InstallMouseHook|KeyHistory|LTrim|MaxHotkeysPerInterval|MaxMem|MaxThreads|MaxThreadsBuffer|MaxThreadsPerHotkey|NoEnv|NoTrayIcon|Persistent|SingleInstance|UseHook|WinActivateForce)\b/i,keyword:/\b(Abort|AboveNormal|Add|ahk_class|ahk_group|ahk_id|ahk_pid|All|Alnum|Alpha|AltSubmit|AltTab|AltTabAndMenu|AltTabMenu|AltTabMenuDismiss|AlwaysOnTop|AutoSize|Background|BackgroundTrans|BelowNormal|between|BitAnd|BitNot|BitOr|BitShiftLeft|BitShiftRight|BitXOr|Bold|Border|Button|ByRef|Checkbox|Checked|CheckedGray|Choose|ChooseString|Click|Close|Color|ComboBox|Contains|ControlList|Count|Date|DateTime|Days|DDL|Default|Delete|DeleteAll|Delimiter|Deref|Destroy|Digit|Disable|Disabled|DropDownList|Edit|Eject|Else|Enable|Enabled|Error|Exist|Exp|Expand|ExStyle|FileSystem|First|Flash|Float|FloatFast|Focus|Font|for|global|Grid|Group|GroupBox|GuiClose|GuiContextMenu|GuiDropFiles|GuiEscape|GuiSize|Hdr|Hidden|Hide|High|HKCC|HKCR|HKCU|HKEY_CLASSES_ROOT|HKEY_CURRENT_CONFIG|HKEY_CURRENT_USER|HKEY_LOCAL_MACHINE|HKEY_USERS|HKLM|HKU|Hours|HScroll|Icon|IconSmall|ID|IDLast|If|IfEqual|IfExist|IfGreater|IfGreaterOrEqual|IfInString|IfLess|IfLessOrEqual|IfMsgBox|IfNotEqual|IfNotExist|IfNotInString|IfWinActive|IfWinExist|IfWinNotActive|IfWinNotExist|Ignore|ImageList|in|Integer|IntegerFast|Interrupt|is|italic|Join|Label|LastFound|LastFoundExist|Limit|Lines|List|ListBox|ListView|Ln|local|Lock|Logoff|Low|Lower|Lowercase|MainWindow|Margin|Maximize|MaximizeBox|MaxSize|Minimize|MinimizeBox|MinMax|MinSize|Minutes|MonthCal|Mouse|Move|Multi|NA|No|NoActivate|NoDefault|NoHide|NoIcon|NoMainWindow|norm|Normal|NoSort|NoSortHdr|NoStandard|Not|NoTab|NoTimers|Number|Off|Ok|On|OwnDialogs|Owner|Parse|Password|Picture|Pixel|Pos|Pow|Priority|ProcessName|Radio|Range|Read|ReadOnly|Realtime|Redraw|REG_BINARY|REG_DWORD|REG_EXPAND_SZ|REG_MULTI_SZ|REG_SZ|Region|Relative|Rename|Report|Resize|Restore|Retry|RGB|Right|Screen|Seconds|Section|Serial|SetLabel|ShiftAltTab|Show|Single|Slider|SortDesc|Standard|static|Status|StatusBar|StatusCD|strike|Style|Submit|SysMenu|Tab|Tab2|TabStop|Text|Theme|Tile|ToggleCheck|ToggleEnable|ToolWindow|Top|Topmost|TransColor|Transparent|Tray|TreeView|TryAgain|Type|UnCheck|underline|Unicode|Unlock|UpDown|Upper|Uppercase|UseErrorLevel|Vis|VisFirst|Visible|VScroll|Wait|WaitClose|WantCtrlA|WantF2|WantReturn|While|Wrap|Xdigit|xm|xp|xs|Yes|ym|yp|ys)\b/i}; \ No newline at end of file +Prism.languages.autohotkey={comment:{pattern:/(^[^";\n]*("[^"\n]*?"[^"\n]*?)*)(;.*$|^\s*\/\*[\s\S]*\n\*\/)/m,lookbehind:!0},string:/"(([^"\n\r]|"")*)"/m,"function":/[^\(\); \t,\n\+\*\-=\?>:\\\/<&%\[\]]+?(?=\()/m,tag:/^[ \t]*[^\s:]+?(?=:(?:[^:]|$))/m,variable:/%\w+%/,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,operator:/\?|\/\/?=?|:=|\|[=|]?|&[=&]?|\+[=+]?|-[=-]?|\*[=*]?|<(?:<=?|>|=)?|>>?=?|[.^!=~]=?|\b(?:AND|NOT|OR)\b/,punctuation:/[\{}[\]\(\):,]/,"boolean":/\b(true|false)\b/,selector:/\b(AutoTrim|BlockInput|Break|Click|ClipWait|Continue|Control|ControlClick|ControlFocus|ControlGet|ControlGetFocus|ControlGetPos|ControlGetText|ControlMove|ControlSend|ControlSendRaw|ControlSetText|CoordMode|Critical|DetectHiddenText|DetectHiddenWindows|Drive|DriveGet|DriveSpaceFree|EnvAdd|EnvDiv|EnvGet|EnvMult|EnvSet|EnvSub|EnvUpdate|Exit|ExitApp|FileAppend|FileCopy|FileCopyDir|FileCreateDir|FileCreateShortcut|FileDelete|FileEncoding|FileGetAttrib|FileGetShortcut|FileGetSize|FileGetTime|FileGetVersion|FileInstall|FileMove|FileMoveDir|FileRead|FileReadLine|FileRecycle|FileRecycleEmpty|FileRemoveDir|FileSelectFile|FileSelectFolder|FileSetAttrib|FileSetTime|FormatTime|GetKeyState|Gosub|Goto|GroupActivate|GroupAdd|GroupClose|GroupDeactivate|Gui|GuiControl|GuiControlGet|Hotkey|ImageSearch|IniDelete|IniRead|IniWrite|Input|InputBox|KeyWait|ListHotkeys|ListLines|ListVars|Loop|Menu|MouseClick|MouseClickDrag|MouseGetPos|MouseMove|MsgBox|OnExit|OutputDebug|Pause|PixelGetColor|PixelSearch|PostMessage|Process|Progress|Random|RegDelete|RegRead|RegWrite|Reload|Repeat|Return|Run|RunAs|RunWait|Send|SendEvent|SendInput|SendMessage|SendMode|SendPlay|SendRaw|SetBatchLines|SetCapslockState|SetControlDelay|SetDefaultMouseSpeed|SetEnv|SetFormat|SetKeyDelay|SetMouseDelay|SetNumlockState|SetScrollLockState|SetStoreCapslockMode|SetTimer|SetTitleMatchMode|SetWinDelay|SetWorkingDir|Shutdown|Sleep|Sort|SoundBeep|SoundGet|SoundGetWaveVolume|SoundPlay|SoundSet|SoundSetWaveVolume|SplashImage|SplashTextOff|SplashTextOn|SplitPath|StatusBarGetText|StatusBarWait|StringCaseSense|StringGetPos|StringLeft|StringLen|StringLower|StringMid|StringReplace|StringRight|StringSplit|StringTrimLeft|StringTrimRight|StringUpper|Suspend|SysGet|Thread|ToolTip|Transform|TrayTip|URLDownloadToFile|WinActivate|WinActivateBottom|WinClose|WinGet|WinGetActiveStats|WinGetActiveTitle|WinGetClass|WinGetPos|WinGetText|WinGetTitle|WinHide|WinKill|WinMaximize|WinMenuSelectItem|WinMinimize|WinMinimizeAll|WinMinimizeAllUndo|WinMove|WinRestore|WinSet|WinSetTitle|WinShow|WinWait|WinWaitActive|WinWaitClose|WinWaitNotActive)\b/i,constant:/\b(a_ahkpath|a_ahkversion|a_appdata|a_appdatacommon|a_autotrim|a_batchlines|a_caretx|a_carety|a_computername|a_controldelay|a_cursor|a_dd|a_ddd|a_dddd|a_defaultmousespeed|a_desktop|a_desktopcommon|a_detecthiddentext|a_detecthiddenwindows|a_endchar|a_eventinfo|a_exitreason|a_formatfloat|a_formatinteger|a_gui|a_guievent|a_guicontrol|a_guicontrolevent|a_guiheight|a_guiwidth|a_guix|a_guiy|a_hour|a_iconfile|a_iconhidden|a_iconnumber|a_icontip|a_index|a_ipaddress1|a_ipaddress2|a_ipaddress3|a_ipaddress4|a_isadmin|a_iscompiled|a_iscritical|a_ispaused|a_issuspended|a_isunicode|a_keydelay|a_language|a_lasterror|a_linefile|a_linenumber|a_loopfield|a_loopfileattrib|a_loopfiledir|a_loopfileext|a_loopfilefullpath|a_loopfilelongpath|a_loopfilename|a_loopfileshortname|a_loopfileshortpath|a_loopfilesize|a_loopfilesizekb|a_loopfilesizemb|a_loopfiletimeaccessed|a_loopfiletimecreated|a_loopfiletimemodified|a_loopreadline|a_loopregkey|a_loopregname|a_loopregsubkey|a_loopregtimemodified|a_loopregtype|a_mday|a_min|a_mm|a_mmm|a_mmmm|a_mon|a_mousedelay|a_msec|a_mydocuments|a_now|a_nowutc|a_numbatchlines|a_ostype|a_osversion|a_priorhotkey|programfiles|a_programfiles|a_programs|a_programscommon|a_screenheight|a_screenwidth|a_scriptdir|a_scriptfullpath|a_scriptname|a_sec|a_space|a_startmenu|a_startmenucommon|a_startup|a_startupcommon|a_stringcasesense|a_tab|a_temp|a_thisfunc|a_thishotkey|a_thislabel|a_thismenu|a_thismenuitem|a_thismenuitempos|a_tickcount|a_timeidle|a_timeidlephysical|a_timesincepriorhotkey|a_timesincethishotkey|a_titlematchmode|a_titlematchmodespeed|a_username|a_wday|a_windelay|a_windir|a_workingdir|a_yday|a_year|a_yweek|a_yyyy|clipboard|clipboardall|comspec|errorlevel)\b/i,builtin:/\b(abs|acos|asc|asin|atan|ceil|chr|class|cos|dllcall|exp|fileexist|Fileopen|floor|getkeystate|il_add|il_create|il_destroy|instr|substr|isfunc|islabel|IsObject|ln|log|lv_add|lv_delete|lv_deletecol|lv_getcount|lv_getnext|lv_gettext|lv_insert|lv_insertcol|lv_modify|lv_modifycol|lv_setimagelist|mod|onmessage|numget|numput|registercallback|regexmatch|regexreplace|round|sin|tan|sqrt|strlen|sb_seticon|sb_setparts|sb_settext|strsplit|tv_add|tv_delete|tv_getchild|tv_getcount|tv_getnext|tv_get|tv_getparent|tv_getprev|tv_getselection|tv_gettext|tv_modify|varsetcapacity|winactive|winexist|__New|__Call|__Get|__Set)\b/i,symbol:/\b(alt|altdown|altup|appskey|backspace|browser_back|browser_favorites|browser_forward|browser_home|browser_refresh|browser_search|browser_stop|bs|capslock|control|ctrl|ctrlbreak|ctrldown|ctrlup|del|delete|down|end|enter|esc|escape|f1|f10|f11|f12|f13|f14|f15|f16|f17|f18|f19|f2|f20|f21|f22|f23|f24|f3|f4|f5|f6|f7|f8|f9|home|ins|insert|joy1|joy10|joy11|joy12|joy13|joy14|joy15|joy16|joy17|joy18|joy19|joy2|joy20|joy21|joy22|joy23|joy24|joy25|joy26|joy27|joy28|joy29|joy3|joy30|joy31|joy32|joy4|joy5|joy6|joy7|joy8|joy9|joyaxes|joybuttons|joyinfo|joyname|joypov|joyr|joyu|joyv|joyx|joyy|joyz|lalt|launch_app1|launch_app2|launch_mail|launch_media|lbutton|lcontrol|lctrl|left|lshift|lwin|lwindown|lwinup|mbutton|media_next|media_play_pause|media_prev|media_stop|numlock|numpad0|numpad1|numpad2|numpad3|numpad4|numpad5|numpad6|numpad7|numpad8|numpad9|numpadadd|numpadclear|numpaddel|numpaddiv|numpaddot|numpaddown|numpadend|numpadenter|numpadhome|numpadins|numpadleft|numpadmult|numpadpgdn|numpadpgup|numpadright|numpadsub|numpadup|pause|pgdn|pgup|printscreen|ralt|rbutton|rcontrol|rctrl|right|rshift|rwin|rwindown|rwinup|scrolllock|shift|shiftdown|shiftup|space|tab|up|volume_down|volume_mute|volume_up|wheeldown|wheelleft|wheelright|wheelup|xbutton1|xbutton2)\b/i,important:/#\b(AllowSameLineComments|ClipboardTimeout|CommentFlag|ErrorStdOut|EscapeChar|HotkeyInterval|HotkeyModifierTimeout|Hotstring|IfWinActive|IfWinExist|IfWinNotActive|IfWinNotExist|Include|IncludeAgain|InstallKeybdHook|InstallMouseHook|KeyHistory|LTrim|MaxHotkeysPerInterval|MaxMem|MaxThreads|MaxThreadsBuffer|MaxThreadsPerHotkey|NoEnv|NoTrayIcon|Persistent|SingleInstance|UseHook|WinActivateForce)\b/i,keyword:/\b(Abort|AboveNormal|Add|ahk_class|ahk_group|ahk_id|ahk_pid|All|Alnum|Alpha|AltSubmit|AltTab|AltTabAndMenu|AltTabMenu|AltTabMenuDismiss|AlwaysOnTop|AutoSize|Background|BackgroundTrans|BelowNormal|between|BitAnd|BitNot|BitOr|BitShiftLeft|BitShiftRight|BitXOr|Bold|Border|Button|ByRef|Checkbox|Checked|CheckedGray|Choose|ChooseString|Click|Close|Color|ComboBox|Contains|ControlList|Count|Date|DateTime|Days|DDL|Default|Delete|DeleteAll|Delimiter|Deref|Destroy|Digit|Disable|Disabled|DropDownList|Edit|Eject|Else|Enable|Enabled|Error|Exist|Exp|Expand|ExStyle|FileSystem|First|Flash|Float|FloatFast|Focus|Font|for|global|Grid|Group|GroupBox|GuiClose|GuiContextMenu|GuiDropFiles|GuiEscape|GuiSize|Hdr|Hidden|Hide|High|HKCC|HKCR|HKCU|HKEY_CLASSES_ROOT|HKEY_CURRENT_CONFIG|HKEY_CURRENT_USER|HKEY_LOCAL_MACHINE|HKEY_USERS|HKLM|HKU|Hours|HScroll|Icon|IconSmall|ID|IDLast|If|IfEqual|IfExist|IfGreater|IfGreaterOrEqual|IfInString|IfLess|IfLessOrEqual|IfMsgBox|IfNotEqual|IfNotExist|IfNotInString|IfWinActive|IfWinExist|IfWinNotActive|IfWinNotExist|Ignore|ImageList|in|Integer|IntegerFast|Interrupt|is|italic|Join|Label|LastFound|LastFoundExist|Limit|Lines|List|ListBox|ListView|Ln|local|Lock|Logoff|Low|Lower|Lowercase|MainWindow|Margin|Maximize|MaximizeBox|MaxSize|Minimize|MinimizeBox|MinMax|MinSize|Minutes|MonthCal|Mouse|Move|Multi|NA|No|NoActivate|NoDefault|NoHide|NoIcon|NoMainWindow|norm|Normal|NoSort|NoSortHdr|NoStandard|Not|NoTab|NoTimers|Number|Off|Ok|On|OwnDialogs|Owner|Parse|Password|Picture|Pixel|Pos|Pow|Priority|ProcessName|Radio|Range|Read|ReadOnly|Realtime|Redraw|REG_BINARY|REG_DWORD|REG_EXPAND_SZ|REG_MULTI_SZ|REG_SZ|Region|Relative|Rename|Report|Resize|Restore|Retry|RGB|Right|Screen|Seconds|Section|Serial|SetLabel|ShiftAltTab|Show|Single|Slider|SortDesc|Standard|static|Status|StatusBar|StatusCD|strike|Style|Submit|SysMenu|Tab|Tab2|TabStop|Text|Theme|Tile|ToggleCheck|ToggleEnable|ToolWindow|Top|Topmost|TransColor|Transparent|Tray|TreeView|TryAgain|Type|UnCheck|underline|Unicode|Unlock|UpDown|Upper|Uppercase|UseErrorLevel|Vis|VisFirst|Visible|VScroll|Wait|WaitClose|WantCtrlA|WantF2|WantReturn|While|Wrap|Xdigit|xm|xp|xs|Yes|ym|yp|ys)\b/i}; \ No newline at end of file From fe0a068a6198a823b3286da374237a2e9e0ec662 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sat, 11 Jul 2015 20:02:03 +0200 Subject: [PATCH 103/310] AutoHotkey: removed duplicates in keywords lists --- components/prism-autohotkey.js | 6 +++--- components/prism-autohotkey.min.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/prism-autohotkey.js b/components/prism-autohotkey.js index 223309527f..69491eada8 100644 --- a/components/prism-autohotkey.js +++ b/components/prism-autohotkey.js @@ -17,11 +17,11 @@ Prism.languages.autohotkey= { 'constant': /\b(a_ahkpath|a_ahkversion|a_appdata|a_appdatacommon|a_autotrim|a_batchlines|a_caretx|a_carety|a_computername|a_controldelay|a_cursor|a_dd|a_ddd|a_dddd|a_defaultmousespeed|a_desktop|a_desktopcommon|a_detecthiddentext|a_detecthiddenwindows|a_endchar|a_eventinfo|a_exitreason|a_formatfloat|a_formatinteger|a_gui|a_guievent|a_guicontrol|a_guicontrolevent|a_guiheight|a_guiwidth|a_guix|a_guiy|a_hour|a_iconfile|a_iconhidden|a_iconnumber|a_icontip|a_index|a_ipaddress1|a_ipaddress2|a_ipaddress3|a_ipaddress4|a_isadmin|a_iscompiled|a_iscritical|a_ispaused|a_issuspended|a_isunicode|a_keydelay|a_language|a_lasterror|a_linefile|a_linenumber|a_loopfield|a_loopfileattrib|a_loopfiledir|a_loopfileext|a_loopfilefullpath|a_loopfilelongpath|a_loopfilename|a_loopfileshortname|a_loopfileshortpath|a_loopfilesize|a_loopfilesizekb|a_loopfilesizemb|a_loopfiletimeaccessed|a_loopfiletimecreated|a_loopfiletimemodified|a_loopreadline|a_loopregkey|a_loopregname|a_loopregsubkey|a_loopregtimemodified|a_loopregtype|a_mday|a_min|a_mm|a_mmm|a_mmmm|a_mon|a_mousedelay|a_msec|a_mydocuments|a_now|a_nowutc|a_numbatchlines|a_ostype|a_osversion|a_priorhotkey|programfiles|a_programfiles|a_programs|a_programscommon|a_screenheight|a_screenwidth|a_scriptdir|a_scriptfullpath|a_scriptname|a_sec|a_space|a_startmenu|a_startmenucommon|a_startup|a_startupcommon|a_stringcasesense|a_tab|a_temp|a_thisfunc|a_thishotkey|a_thislabel|a_thismenu|a_thismenuitem|a_thismenuitempos|a_tickcount|a_timeidle|a_timeidlephysical|a_timesincepriorhotkey|a_timesincethishotkey|a_titlematchmode|a_titlematchmodespeed|a_username|a_wday|a_windelay|a_windir|a_workingdir|a_yday|a_year|a_yweek|a_yyyy|clipboard|clipboardall|comspec|errorlevel)\b/i, - 'builtin': /\b(abs|acos|asc|asin|atan|ceil|chr|class|cos|dllcall|exp|fileexist|Fileopen|floor|getkeystate|il_add|il_create|il_destroy|instr|substr|isfunc|islabel|IsObject|ln|log|lv_add|lv_delete|lv_deletecol|lv_getcount|lv_getnext|lv_gettext|lv_insert|lv_insertcol|lv_modify|lv_modifycol|lv_setimagelist|mod|onmessage|numget|numput|registercallback|regexmatch|regexreplace|round|sin|tan|sqrt|strlen|sb_seticon|sb_setparts|sb_settext|strsplit|tv_add|tv_delete|tv_getchild|tv_getcount|tv_getnext|tv_get|tv_getparent|tv_getprev|tv_getselection|tv_gettext|tv_modify|varsetcapacity|winactive|winexist|__New|__Call|__Get|__Set)\b/i, + 'builtin': /\b(abs|acos|asc|asin|atan|ceil|chr|class|cos|dllcall|exp|fileexist|Fileopen|floor|il_add|il_create|il_destroy|instr|substr|isfunc|islabel|IsObject|ln|log|lv_add|lv_delete|lv_deletecol|lv_getcount|lv_getnext|lv_gettext|lv_insert|lv_insertcol|lv_modify|lv_modifycol|lv_setimagelist|mod|onmessage|numget|numput|registercallback|regexmatch|regexreplace|round|sin|tan|sqrt|strlen|sb_seticon|sb_setparts|sb_settext|strsplit|tv_add|tv_delete|tv_getchild|tv_getcount|tv_getnext|tv_get|tv_getparent|tv_getprev|tv_getselection|tv_gettext|tv_modify|varsetcapacity|winactive|winexist|__New|__Call|__Get|__Set)\b/i, - 'symbol': /\b(alt|altdown|altup|appskey|backspace|browser_back|browser_favorites|browser_forward|browser_home|browser_refresh|browser_search|browser_stop|bs|capslock|control|ctrl|ctrlbreak|ctrldown|ctrlup|del|delete|down|end|enter|esc|escape|f1|f10|f11|f12|f13|f14|f15|f16|f17|f18|f19|f2|f20|f21|f22|f23|f24|f3|f4|f5|f6|f7|f8|f9|home|ins|insert|joy1|joy10|joy11|joy12|joy13|joy14|joy15|joy16|joy17|joy18|joy19|joy2|joy20|joy21|joy22|joy23|joy24|joy25|joy26|joy27|joy28|joy29|joy3|joy30|joy31|joy32|joy4|joy5|joy6|joy7|joy8|joy9|joyaxes|joybuttons|joyinfo|joyname|joypov|joyr|joyu|joyv|joyx|joyy|joyz|lalt|launch_app1|launch_app2|launch_mail|launch_media|lbutton|lcontrol|lctrl|left|lshift|lwin|lwindown|lwinup|mbutton|media_next|media_play_pause|media_prev|media_stop|numlock|numpad0|numpad1|numpad2|numpad3|numpad4|numpad5|numpad6|numpad7|numpad8|numpad9|numpadadd|numpadclear|numpaddel|numpaddiv|numpaddot|numpaddown|numpadend|numpadenter|numpadhome|numpadins|numpadleft|numpadmult|numpadpgdn|numpadpgup|numpadright|numpadsub|numpadup|pause|pgdn|pgup|printscreen|ralt|rbutton|rcontrol|rctrl|right|rshift|rwin|rwindown|rwinup|scrolllock|shift|shiftdown|shiftup|space|tab|up|volume_down|volume_mute|volume_up|wheeldown|wheelleft|wheelright|wheelup|xbutton1|xbutton2)\b/i, + 'symbol': /\b(alt|altdown|altup|appskey|backspace|browser_back|browser_favorites|browser_forward|browser_home|browser_refresh|browser_search|browser_stop|bs|capslock|ctrl|ctrlbreak|ctrldown|ctrlup|del|delete|down|end|enter|esc|escape|f1|f10|f11|f12|f13|f14|f15|f16|f17|f18|f19|f2|f20|f21|f22|f23|f24|f3|f4|f5|f6|f7|f8|f9|home|ins|insert|joy1|joy10|joy11|joy12|joy13|joy14|joy15|joy16|joy17|joy18|joy19|joy2|joy20|joy21|joy22|joy23|joy24|joy25|joy26|joy27|joy28|joy29|joy3|joy30|joy31|joy32|joy4|joy5|joy6|joy7|joy8|joy9|joyaxes|joybuttons|joyinfo|joyname|joypov|joyr|joyu|joyv|joyx|joyy|joyz|lalt|launch_app1|launch_app2|launch_mail|launch_media|lbutton|lcontrol|lctrl|left|lshift|lwin|lwindown|lwinup|mbutton|media_next|media_play_pause|media_prev|media_stop|numlock|numpad0|numpad1|numpad2|numpad3|numpad4|numpad5|numpad6|numpad7|numpad8|numpad9|numpadadd|numpadclear|numpaddel|numpaddiv|numpaddot|numpaddown|numpadend|numpadenter|numpadhome|numpadins|numpadleft|numpadmult|numpadpgdn|numpadpgup|numpadright|numpadsub|numpadup|pgdn|pgup|printscreen|ralt|rbutton|rcontrol|rctrl|right|rshift|rwin|rwindown|rwinup|scrolllock|shift|shiftdown|shiftup|space|tab|up|volume_down|volume_mute|volume_up|wheeldown|wheelleft|wheelright|wheelup|xbutton1|xbutton2)\b/i, 'important': /#\b(AllowSameLineComments|ClipboardTimeout|CommentFlag|ErrorStdOut|EscapeChar|HotkeyInterval|HotkeyModifierTimeout|Hotstring|IfWinActive|IfWinExist|IfWinNotActive|IfWinNotExist|Include|IncludeAgain|InstallKeybdHook|InstallMouseHook|KeyHistory|LTrim|MaxHotkeysPerInterval|MaxMem|MaxThreads|MaxThreadsBuffer|MaxThreadsPerHotkey|NoEnv|NoTrayIcon|Persistent|SingleInstance|UseHook|WinActivateForce)\b/i, - 'keyword': /\b(Abort|AboveNormal|Add|ahk_class|ahk_group|ahk_id|ahk_pid|All|Alnum|Alpha|AltSubmit|AltTab|AltTabAndMenu|AltTabMenu|AltTabMenuDismiss|AlwaysOnTop|AutoSize|Background|BackgroundTrans|BelowNormal|between|BitAnd|BitNot|BitOr|BitShiftLeft|BitShiftRight|BitXOr|Bold|Border|Button|ByRef|Checkbox|Checked|CheckedGray|Choose|ChooseString|Click|Close|Color|ComboBox|Contains|ControlList|Count|Date|DateTime|Days|DDL|Default|Delete|DeleteAll|Delimiter|Deref|Destroy|Digit|Disable|Disabled|DropDownList|Edit|Eject|Else|Enable|Enabled|Error|Exist|Exp|Expand|ExStyle|FileSystem|First|Flash|Float|FloatFast|Focus|Font|for|global|Grid|Group|GroupBox|GuiClose|GuiContextMenu|GuiDropFiles|GuiEscape|GuiSize|Hdr|Hidden|Hide|High|HKCC|HKCR|HKCU|HKEY_CLASSES_ROOT|HKEY_CURRENT_CONFIG|HKEY_CURRENT_USER|HKEY_LOCAL_MACHINE|HKEY_USERS|HKLM|HKU|Hours|HScroll|Icon|IconSmall|ID|IDLast|If|IfEqual|IfExist|IfGreater|IfGreaterOrEqual|IfInString|IfLess|IfLessOrEqual|IfMsgBox|IfNotEqual|IfNotExist|IfNotInString|IfWinActive|IfWinExist|IfWinNotActive|IfWinNotExist|Ignore|ImageList|in|Integer|IntegerFast|Interrupt|is|italic|Join|Label|LastFound|LastFoundExist|Limit|Lines|List|ListBox|ListView|Ln|local|Lock|Logoff|Low|Lower|Lowercase|MainWindow|Margin|Maximize|MaximizeBox|MaxSize|Minimize|MinimizeBox|MinMax|MinSize|Minutes|MonthCal|Mouse|Move|Multi|NA|No|NoActivate|NoDefault|NoHide|NoIcon|NoMainWindow|norm|Normal|NoSort|NoSortHdr|NoStandard|Not|NoTab|NoTimers|Number|Off|Ok|On|OwnDialogs|Owner|Parse|Password|Picture|Pixel|Pos|Pow|Priority|ProcessName|Radio|Range|Read|ReadOnly|Realtime|Redraw|REG_BINARY|REG_DWORD|REG_EXPAND_SZ|REG_MULTI_SZ|REG_SZ|Region|Relative|Rename|Report|Resize|Restore|Retry|RGB|Right|Screen|Seconds|Section|Serial|SetLabel|ShiftAltTab|Show|Single|Slider|SortDesc|Standard|static|Status|StatusBar|StatusCD|strike|Style|Submit|SysMenu|Tab|Tab2|TabStop|Text|Theme|Tile|ToggleCheck|ToggleEnable|ToolWindow|Top|Topmost|TransColor|Transparent|Tray|TreeView|TryAgain|Type|UnCheck|underline|Unicode|Unlock|UpDown|Upper|Uppercase|UseErrorLevel|Vis|VisFirst|Visible|VScroll|Wait|WaitClose|WantCtrlA|WantF2|WantReturn|While|Wrap|Xdigit|xm|xp|xs|Yes|ym|yp|ys)\b/i + 'keyword': /\b(Abort|AboveNormal|Add|ahk_class|ahk_group|ahk_id|ahk_pid|All|Alnum|Alpha|AltSubmit|AltTab|AltTabAndMenu|AltTabMenu|AltTabMenuDismiss|AlwaysOnTop|AutoSize|Background|BackgroundTrans|BelowNormal|between|BitAnd|BitNot|BitOr|BitShiftLeft|BitShiftRight|BitXOr|Bold|Border|Button|ByRef|Checkbox|Checked|CheckedGray|Choose|ChooseString|Close|Color|ComboBox|Contains|ControlList|Count|Date|DateTime|Days|DDL|Default|DeleteAll|Delimiter|Deref|Destroy|Digit|Disable|Disabled|DropDownList|Edit|Eject|Else|Enable|Enabled|Error|Exist|Expand|ExStyle|FileSystem|First|Flash|Float|FloatFast|Focus|Font|for|global|Grid|Group|GroupBox|GuiClose|GuiContextMenu|GuiDropFiles|GuiEscape|GuiSize|Hdr|Hidden|Hide|High|HKCC|HKCR|HKCU|HKEY_CLASSES_ROOT|HKEY_CURRENT_CONFIG|HKEY_CURRENT_USER|HKEY_LOCAL_MACHINE|HKEY_USERS|HKLM|HKU|Hours|HScroll|Icon|IconSmall|ID|IDLast|If|IfEqual|IfExist|IfGreater|IfGreaterOrEqual|IfInString|IfLess|IfLessOrEqual|IfMsgBox|IfNotEqual|IfNotExist|IfNotInString|IfWinActive|IfWinExist|IfWinNotActive|IfWinNotExist|Ignore|ImageList|in|Integer|IntegerFast|Interrupt|is|italic|Join|Label|LastFound|LastFoundExist|Limit|Lines|List|ListBox|ListView|local|Lock|Logoff|Low|Lower|Lowercase|MainWindow|Margin|Maximize|MaximizeBox|MaxSize|Minimize|MinimizeBox|MinMax|MinSize|Minutes|MonthCal|Mouse|Move|Multi|NA|No|NoActivate|NoDefault|NoHide|NoIcon|NoMainWindow|norm|Normal|NoSort|NoSortHdr|NoStandard|Not|NoTab|NoTimers|Number|Off|Ok|On|OwnDialogs|Owner|Parse|Password|Picture|Pixel|Pos|Pow|Priority|ProcessName|Radio|Range|Read|ReadOnly|Realtime|Redraw|REG_BINARY|REG_DWORD|REG_EXPAND_SZ|REG_MULTI_SZ|REG_SZ|Region|Relative|Rename|Report|Resize|Restore|Retry|RGB|Screen|Seconds|Section|Serial|SetLabel|ShiftAltTab|Show|Single|Slider|SortDesc|Standard|static|Status|StatusBar|StatusCD|strike|Style|Submit|SysMenu|Tab2|TabStop|Text|Theme|Tile|ToggleCheck|ToggleEnable|ToolWindow|Top|Topmost|TransColor|Transparent|Tray|TreeView|TryAgain|Type|UnCheck|underline|Unicode|Unlock|UpDown|Upper|Uppercase|UseErrorLevel|Vis|VisFirst|Visible|VScroll|Wait|WaitClose|WantCtrlA|WantF2|WantReturn|While|Wrap|Xdigit|xm|xp|xs|Yes|ym|yp|ys)\b/i }; \ No newline at end of file diff --git a/components/prism-autohotkey.min.js b/components/prism-autohotkey.min.js index c15fa0f54e..d4d9685b8b 100644 --- a/components/prism-autohotkey.min.js +++ b/components/prism-autohotkey.min.js @@ -1 +1 @@ -Prism.languages.autohotkey={comment:{pattern:/(^[^";\n]*("[^"\n]*?"[^"\n]*?)*)(;.*$|^\s*\/\*[\s\S]*\n\*\/)/m,lookbehind:!0},string:/"(([^"\n\r]|"")*)"/m,"function":/[^\(\); \t,\n\+\*\-=\?>:\\\/<&%\[\]]+?(?=\()/m,tag:/^[ \t]*[^\s:]+?(?=:(?:[^:]|$))/m,variable:/%\w+%/,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,operator:/\?|\/\/?=?|:=|\|[=|]?|&[=&]?|\+[=+]?|-[=-]?|\*[=*]?|<(?:<=?|>|=)?|>>?=?|[.^!=~]=?|\b(?:AND|NOT|OR)\b/,punctuation:/[\{}[\]\(\):,]/,"boolean":/\b(true|false)\b/,selector:/\b(AutoTrim|BlockInput|Break|Click|ClipWait|Continue|Control|ControlClick|ControlFocus|ControlGet|ControlGetFocus|ControlGetPos|ControlGetText|ControlMove|ControlSend|ControlSendRaw|ControlSetText|CoordMode|Critical|DetectHiddenText|DetectHiddenWindows|Drive|DriveGet|DriveSpaceFree|EnvAdd|EnvDiv|EnvGet|EnvMult|EnvSet|EnvSub|EnvUpdate|Exit|ExitApp|FileAppend|FileCopy|FileCopyDir|FileCreateDir|FileCreateShortcut|FileDelete|FileEncoding|FileGetAttrib|FileGetShortcut|FileGetSize|FileGetTime|FileGetVersion|FileInstall|FileMove|FileMoveDir|FileRead|FileReadLine|FileRecycle|FileRecycleEmpty|FileRemoveDir|FileSelectFile|FileSelectFolder|FileSetAttrib|FileSetTime|FormatTime|GetKeyState|Gosub|Goto|GroupActivate|GroupAdd|GroupClose|GroupDeactivate|Gui|GuiControl|GuiControlGet|Hotkey|ImageSearch|IniDelete|IniRead|IniWrite|Input|InputBox|KeyWait|ListHotkeys|ListLines|ListVars|Loop|Menu|MouseClick|MouseClickDrag|MouseGetPos|MouseMove|MsgBox|OnExit|OutputDebug|Pause|PixelGetColor|PixelSearch|PostMessage|Process|Progress|Random|RegDelete|RegRead|RegWrite|Reload|Repeat|Return|Run|RunAs|RunWait|Send|SendEvent|SendInput|SendMessage|SendMode|SendPlay|SendRaw|SetBatchLines|SetCapslockState|SetControlDelay|SetDefaultMouseSpeed|SetEnv|SetFormat|SetKeyDelay|SetMouseDelay|SetNumlockState|SetScrollLockState|SetStoreCapslockMode|SetTimer|SetTitleMatchMode|SetWinDelay|SetWorkingDir|Shutdown|Sleep|Sort|SoundBeep|SoundGet|SoundGetWaveVolume|SoundPlay|SoundSet|SoundSetWaveVolume|SplashImage|SplashTextOff|SplashTextOn|SplitPath|StatusBarGetText|StatusBarWait|StringCaseSense|StringGetPos|StringLeft|StringLen|StringLower|StringMid|StringReplace|StringRight|StringSplit|StringTrimLeft|StringTrimRight|StringUpper|Suspend|SysGet|Thread|ToolTip|Transform|TrayTip|URLDownloadToFile|WinActivate|WinActivateBottom|WinClose|WinGet|WinGetActiveStats|WinGetActiveTitle|WinGetClass|WinGetPos|WinGetText|WinGetTitle|WinHide|WinKill|WinMaximize|WinMenuSelectItem|WinMinimize|WinMinimizeAll|WinMinimizeAllUndo|WinMove|WinRestore|WinSet|WinSetTitle|WinShow|WinWait|WinWaitActive|WinWaitClose|WinWaitNotActive)\b/i,constant:/\b(a_ahkpath|a_ahkversion|a_appdata|a_appdatacommon|a_autotrim|a_batchlines|a_caretx|a_carety|a_computername|a_controldelay|a_cursor|a_dd|a_ddd|a_dddd|a_defaultmousespeed|a_desktop|a_desktopcommon|a_detecthiddentext|a_detecthiddenwindows|a_endchar|a_eventinfo|a_exitreason|a_formatfloat|a_formatinteger|a_gui|a_guievent|a_guicontrol|a_guicontrolevent|a_guiheight|a_guiwidth|a_guix|a_guiy|a_hour|a_iconfile|a_iconhidden|a_iconnumber|a_icontip|a_index|a_ipaddress1|a_ipaddress2|a_ipaddress3|a_ipaddress4|a_isadmin|a_iscompiled|a_iscritical|a_ispaused|a_issuspended|a_isunicode|a_keydelay|a_language|a_lasterror|a_linefile|a_linenumber|a_loopfield|a_loopfileattrib|a_loopfiledir|a_loopfileext|a_loopfilefullpath|a_loopfilelongpath|a_loopfilename|a_loopfileshortname|a_loopfileshortpath|a_loopfilesize|a_loopfilesizekb|a_loopfilesizemb|a_loopfiletimeaccessed|a_loopfiletimecreated|a_loopfiletimemodified|a_loopreadline|a_loopregkey|a_loopregname|a_loopregsubkey|a_loopregtimemodified|a_loopregtype|a_mday|a_min|a_mm|a_mmm|a_mmmm|a_mon|a_mousedelay|a_msec|a_mydocuments|a_now|a_nowutc|a_numbatchlines|a_ostype|a_osversion|a_priorhotkey|programfiles|a_programfiles|a_programs|a_programscommon|a_screenheight|a_screenwidth|a_scriptdir|a_scriptfullpath|a_scriptname|a_sec|a_space|a_startmenu|a_startmenucommon|a_startup|a_startupcommon|a_stringcasesense|a_tab|a_temp|a_thisfunc|a_thishotkey|a_thislabel|a_thismenu|a_thismenuitem|a_thismenuitempos|a_tickcount|a_timeidle|a_timeidlephysical|a_timesincepriorhotkey|a_timesincethishotkey|a_titlematchmode|a_titlematchmodespeed|a_username|a_wday|a_windelay|a_windir|a_workingdir|a_yday|a_year|a_yweek|a_yyyy|clipboard|clipboardall|comspec|errorlevel)\b/i,builtin:/\b(abs|acos|asc|asin|atan|ceil|chr|class|cos|dllcall|exp|fileexist|Fileopen|floor|getkeystate|il_add|il_create|il_destroy|instr|substr|isfunc|islabel|IsObject|ln|log|lv_add|lv_delete|lv_deletecol|lv_getcount|lv_getnext|lv_gettext|lv_insert|lv_insertcol|lv_modify|lv_modifycol|lv_setimagelist|mod|onmessage|numget|numput|registercallback|regexmatch|regexreplace|round|sin|tan|sqrt|strlen|sb_seticon|sb_setparts|sb_settext|strsplit|tv_add|tv_delete|tv_getchild|tv_getcount|tv_getnext|tv_get|tv_getparent|tv_getprev|tv_getselection|tv_gettext|tv_modify|varsetcapacity|winactive|winexist|__New|__Call|__Get|__Set)\b/i,symbol:/\b(alt|altdown|altup|appskey|backspace|browser_back|browser_favorites|browser_forward|browser_home|browser_refresh|browser_search|browser_stop|bs|capslock|control|ctrl|ctrlbreak|ctrldown|ctrlup|del|delete|down|end|enter|esc|escape|f1|f10|f11|f12|f13|f14|f15|f16|f17|f18|f19|f2|f20|f21|f22|f23|f24|f3|f4|f5|f6|f7|f8|f9|home|ins|insert|joy1|joy10|joy11|joy12|joy13|joy14|joy15|joy16|joy17|joy18|joy19|joy2|joy20|joy21|joy22|joy23|joy24|joy25|joy26|joy27|joy28|joy29|joy3|joy30|joy31|joy32|joy4|joy5|joy6|joy7|joy8|joy9|joyaxes|joybuttons|joyinfo|joyname|joypov|joyr|joyu|joyv|joyx|joyy|joyz|lalt|launch_app1|launch_app2|launch_mail|launch_media|lbutton|lcontrol|lctrl|left|lshift|lwin|lwindown|lwinup|mbutton|media_next|media_play_pause|media_prev|media_stop|numlock|numpad0|numpad1|numpad2|numpad3|numpad4|numpad5|numpad6|numpad7|numpad8|numpad9|numpadadd|numpadclear|numpaddel|numpaddiv|numpaddot|numpaddown|numpadend|numpadenter|numpadhome|numpadins|numpadleft|numpadmult|numpadpgdn|numpadpgup|numpadright|numpadsub|numpadup|pause|pgdn|pgup|printscreen|ralt|rbutton|rcontrol|rctrl|right|rshift|rwin|rwindown|rwinup|scrolllock|shift|shiftdown|shiftup|space|tab|up|volume_down|volume_mute|volume_up|wheeldown|wheelleft|wheelright|wheelup|xbutton1|xbutton2)\b/i,important:/#\b(AllowSameLineComments|ClipboardTimeout|CommentFlag|ErrorStdOut|EscapeChar|HotkeyInterval|HotkeyModifierTimeout|Hotstring|IfWinActive|IfWinExist|IfWinNotActive|IfWinNotExist|Include|IncludeAgain|InstallKeybdHook|InstallMouseHook|KeyHistory|LTrim|MaxHotkeysPerInterval|MaxMem|MaxThreads|MaxThreadsBuffer|MaxThreadsPerHotkey|NoEnv|NoTrayIcon|Persistent|SingleInstance|UseHook|WinActivateForce)\b/i,keyword:/\b(Abort|AboveNormal|Add|ahk_class|ahk_group|ahk_id|ahk_pid|All|Alnum|Alpha|AltSubmit|AltTab|AltTabAndMenu|AltTabMenu|AltTabMenuDismiss|AlwaysOnTop|AutoSize|Background|BackgroundTrans|BelowNormal|between|BitAnd|BitNot|BitOr|BitShiftLeft|BitShiftRight|BitXOr|Bold|Border|Button|ByRef|Checkbox|Checked|CheckedGray|Choose|ChooseString|Click|Close|Color|ComboBox|Contains|ControlList|Count|Date|DateTime|Days|DDL|Default|Delete|DeleteAll|Delimiter|Deref|Destroy|Digit|Disable|Disabled|DropDownList|Edit|Eject|Else|Enable|Enabled|Error|Exist|Exp|Expand|ExStyle|FileSystem|First|Flash|Float|FloatFast|Focus|Font|for|global|Grid|Group|GroupBox|GuiClose|GuiContextMenu|GuiDropFiles|GuiEscape|GuiSize|Hdr|Hidden|Hide|High|HKCC|HKCR|HKCU|HKEY_CLASSES_ROOT|HKEY_CURRENT_CONFIG|HKEY_CURRENT_USER|HKEY_LOCAL_MACHINE|HKEY_USERS|HKLM|HKU|Hours|HScroll|Icon|IconSmall|ID|IDLast|If|IfEqual|IfExist|IfGreater|IfGreaterOrEqual|IfInString|IfLess|IfLessOrEqual|IfMsgBox|IfNotEqual|IfNotExist|IfNotInString|IfWinActive|IfWinExist|IfWinNotActive|IfWinNotExist|Ignore|ImageList|in|Integer|IntegerFast|Interrupt|is|italic|Join|Label|LastFound|LastFoundExist|Limit|Lines|List|ListBox|ListView|Ln|local|Lock|Logoff|Low|Lower|Lowercase|MainWindow|Margin|Maximize|MaximizeBox|MaxSize|Minimize|MinimizeBox|MinMax|MinSize|Minutes|MonthCal|Mouse|Move|Multi|NA|No|NoActivate|NoDefault|NoHide|NoIcon|NoMainWindow|norm|Normal|NoSort|NoSortHdr|NoStandard|Not|NoTab|NoTimers|Number|Off|Ok|On|OwnDialogs|Owner|Parse|Password|Picture|Pixel|Pos|Pow|Priority|ProcessName|Radio|Range|Read|ReadOnly|Realtime|Redraw|REG_BINARY|REG_DWORD|REG_EXPAND_SZ|REG_MULTI_SZ|REG_SZ|Region|Relative|Rename|Report|Resize|Restore|Retry|RGB|Right|Screen|Seconds|Section|Serial|SetLabel|ShiftAltTab|Show|Single|Slider|SortDesc|Standard|static|Status|StatusBar|StatusCD|strike|Style|Submit|SysMenu|Tab|Tab2|TabStop|Text|Theme|Tile|ToggleCheck|ToggleEnable|ToolWindow|Top|Topmost|TransColor|Transparent|Tray|TreeView|TryAgain|Type|UnCheck|underline|Unicode|Unlock|UpDown|Upper|Uppercase|UseErrorLevel|Vis|VisFirst|Visible|VScroll|Wait|WaitClose|WantCtrlA|WantF2|WantReturn|While|Wrap|Xdigit|xm|xp|xs|Yes|ym|yp|ys)\b/i}; \ No newline at end of file +Prism.languages.autohotkey={comment:{pattern:/(^[^";\n]*("[^"\n]*?"[^"\n]*?)*)(;.*$|^\s*\/\*[\s\S]*\n\*\/)/m,lookbehind:!0},string:/"(([^"\n\r]|"")*)"/m,"function":/[^\(\); \t,\n\+\*\-=\?>:\\\/<&%\[\]]+?(?=\()/m,tag:/^[ \t]*[^\s:]+?(?=:(?:[^:]|$))/m,variable:/%\w+%/,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,operator:/\?|\/\/?=?|:=|\|[=|]?|&[=&]?|\+[=+]?|-[=-]?|\*[=*]?|<(?:<=?|>|=)?|>>?=?|[.^!=~]=?|\b(?:AND|NOT|OR)\b/,punctuation:/[\{}[\]\(\):,]/,"boolean":/\b(true|false)\b/,selector:/\b(AutoTrim|BlockInput|Break|Click|ClipWait|Continue|Control|ControlClick|ControlFocus|ControlGet|ControlGetFocus|ControlGetPos|ControlGetText|ControlMove|ControlSend|ControlSendRaw|ControlSetText|CoordMode|Critical|DetectHiddenText|DetectHiddenWindows|Drive|DriveGet|DriveSpaceFree|EnvAdd|EnvDiv|EnvGet|EnvMult|EnvSet|EnvSub|EnvUpdate|Exit|ExitApp|FileAppend|FileCopy|FileCopyDir|FileCreateDir|FileCreateShortcut|FileDelete|FileEncoding|FileGetAttrib|FileGetShortcut|FileGetSize|FileGetTime|FileGetVersion|FileInstall|FileMove|FileMoveDir|FileRead|FileReadLine|FileRecycle|FileRecycleEmpty|FileRemoveDir|FileSelectFile|FileSelectFolder|FileSetAttrib|FileSetTime|FormatTime|GetKeyState|Gosub|Goto|GroupActivate|GroupAdd|GroupClose|GroupDeactivate|Gui|GuiControl|GuiControlGet|Hotkey|ImageSearch|IniDelete|IniRead|IniWrite|Input|InputBox|KeyWait|ListHotkeys|ListLines|ListVars|Loop|Menu|MouseClick|MouseClickDrag|MouseGetPos|MouseMove|MsgBox|OnExit|OutputDebug|Pause|PixelGetColor|PixelSearch|PostMessage|Process|Progress|Random|RegDelete|RegRead|RegWrite|Reload|Repeat|Return|Run|RunAs|RunWait|Send|SendEvent|SendInput|SendMessage|SendMode|SendPlay|SendRaw|SetBatchLines|SetCapslockState|SetControlDelay|SetDefaultMouseSpeed|SetEnv|SetFormat|SetKeyDelay|SetMouseDelay|SetNumlockState|SetScrollLockState|SetStoreCapslockMode|SetTimer|SetTitleMatchMode|SetWinDelay|SetWorkingDir|Shutdown|Sleep|Sort|SoundBeep|SoundGet|SoundGetWaveVolume|SoundPlay|SoundSet|SoundSetWaveVolume|SplashImage|SplashTextOff|SplashTextOn|SplitPath|StatusBarGetText|StatusBarWait|StringCaseSense|StringGetPos|StringLeft|StringLen|StringLower|StringMid|StringReplace|StringRight|StringSplit|StringTrimLeft|StringTrimRight|StringUpper|Suspend|SysGet|Thread|ToolTip|Transform|TrayTip|URLDownloadToFile|WinActivate|WinActivateBottom|WinClose|WinGet|WinGetActiveStats|WinGetActiveTitle|WinGetClass|WinGetPos|WinGetText|WinGetTitle|WinHide|WinKill|WinMaximize|WinMenuSelectItem|WinMinimize|WinMinimizeAll|WinMinimizeAllUndo|WinMove|WinRestore|WinSet|WinSetTitle|WinShow|WinWait|WinWaitActive|WinWaitClose|WinWaitNotActive)\b/i,constant:/\b(a_ahkpath|a_ahkversion|a_appdata|a_appdatacommon|a_autotrim|a_batchlines|a_caretx|a_carety|a_computername|a_controldelay|a_cursor|a_dd|a_ddd|a_dddd|a_defaultmousespeed|a_desktop|a_desktopcommon|a_detecthiddentext|a_detecthiddenwindows|a_endchar|a_eventinfo|a_exitreason|a_formatfloat|a_formatinteger|a_gui|a_guievent|a_guicontrol|a_guicontrolevent|a_guiheight|a_guiwidth|a_guix|a_guiy|a_hour|a_iconfile|a_iconhidden|a_iconnumber|a_icontip|a_index|a_ipaddress1|a_ipaddress2|a_ipaddress3|a_ipaddress4|a_isadmin|a_iscompiled|a_iscritical|a_ispaused|a_issuspended|a_isunicode|a_keydelay|a_language|a_lasterror|a_linefile|a_linenumber|a_loopfield|a_loopfileattrib|a_loopfiledir|a_loopfileext|a_loopfilefullpath|a_loopfilelongpath|a_loopfilename|a_loopfileshortname|a_loopfileshortpath|a_loopfilesize|a_loopfilesizekb|a_loopfilesizemb|a_loopfiletimeaccessed|a_loopfiletimecreated|a_loopfiletimemodified|a_loopreadline|a_loopregkey|a_loopregname|a_loopregsubkey|a_loopregtimemodified|a_loopregtype|a_mday|a_min|a_mm|a_mmm|a_mmmm|a_mon|a_mousedelay|a_msec|a_mydocuments|a_now|a_nowutc|a_numbatchlines|a_ostype|a_osversion|a_priorhotkey|programfiles|a_programfiles|a_programs|a_programscommon|a_screenheight|a_screenwidth|a_scriptdir|a_scriptfullpath|a_scriptname|a_sec|a_space|a_startmenu|a_startmenucommon|a_startup|a_startupcommon|a_stringcasesense|a_tab|a_temp|a_thisfunc|a_thishotkey|a_thislabel|a_thismenu|a_thismenuitem|a_thismenuitempos|a_tickcount|a_timeidle|a_timeidlephysical|a_timesincepriorhotkey|a_timesincethishotkey|a_titlematchmode|a_titlematchmodespeed|a_username|a_wday|a_windelay|a_windir|a_workingdir|a_yday|a_year|a_yweek|a_yyyy|clipboard|clipboardall|comspec|errorlevel)\b/i,builtin:/\b(abs|acos|asc|asin|atan|ceil|chr|class|cos|dllcall|exp|fileexist|Fileopen|floor|il_add|il_create|il_destroy|instr|substr|isfunc|islabel|IsObject|ln|log|lv_add|lv_delete|lv_deletecol|lv_getcount|lv_getnext|lv_gettext|lv_insert|lv_insertcol|lv_modify|lv_modifycol|lv_setimagelist|mod|onmessage|numget|numput|registercallback|regexmatch|regexreplace|round|sin|tan|sqrt|strlen|sb_seticon|sb_setparts|sb_settext|strsplit|tv_add|tv_delete|tv_getchild|tv_getcount|tv_getnext|tv_get|tv_getparent|tv_getprev|tv_getselection|tv_gettext|tv_modify|varsetcapacity|winactive|winexist|__New|__Call|__Get|__Set)\b/i,symbol:/\b(alt|altdown|altup|appskey|backspace|browser_back|browser_favorites|browser_forward|browser_home|browser_refresh|browser_search|browser_stop|bs|capslock|ctrl|ctrlbreak|ctrldown|ctrlup|del|delete|down|end|enter|esc|escape|f1|f10|f11|f12|f13|f14|f15|f16|f17|f18|f19|f2|f20|f21|f22|f23|f24|f3|f4|f5|f6|f7|f8|f9|home|ins|insert|joy1|joy10|joy11|joy12|joy13|joy14|joy15|joy16|joy17|joy18|joy19|joy2|joy20|joy21|joy22|joy23|joy24|joy25|joy26|joy27|joy28|joy29|joy3|joy30|joy31|joy32|joy4|joy5|joy6|joy7|joy8|joy9|joyaxes|joybuttons|joyinfo|joyname|joypov|joyr|joyu|joyv|joyx|joyy|joyz|lalt|launch_app1|launch_app2|launch_mail|launch_media|lbutton|lcontrol|lctrl|left|lshift|lwin|lwindown|lwinup|mbutton|media_next|media_play_pause|media_prev|media_stop|numlock|numpad0|numpad1|numpad2|numpad3|numpad4|numpad5|numpad6|numpad7|numpad8|numpad9|numpadadd|numpadclear|numpaddel|numpaddiv|numpaddot|numpaddown|numpadend|numpadenter|numpadhome|numpadins|numpadleft|numpadmult|numpadpgdn|numpadpgup|numpadright|numpadsub|numpadup|pgdn|pgup|printscreen|ralt|rbutton|rcontrol|rctrl|right|rshift|rwin|rwindown|rwinup|scrolllock|shift|shiftdown|shiftup|space|tab|up|volume_down|volume_mute|volume_up|wheeldown|wheelleft|wheelright|wheelup|xbutton1|xbutton2)\b/i,important:/#\b(AllowSameLineComments|ClipboardTimeout|CommentFlag|ErrorStdOut|EscapeChar|HotkeyInterval|HotkeyModifierTimeout|Hotstring|IfWinActive|IfWinExist|IfWinNotActive|IfWinNotExist|Include|IncludeAgain|InstallKeybdHook|InstallMouseHook|KeyHistory|LTrim|MaxHotkeysPerInterval|MaxMem|MaxThreads|MaxThreadsBuffer|MaxThreadsPerHotkey|NoEnv|NoTrayIcon|Persistent|SingleInstance|UseHook|WinActivateForce)\b/i,keyword:/\b(Abort|AboveNormal|Add|ahk_class|ahk_group|ahk_id|ahk_pid|All|Alnum|Alpha|AltSubmit|AltTab|AltTabAndMenu|AltTabMenu|AltTabMenuDismiss|AlwaysOnTop|AutoSize|Background|BackgroundTrans|BelowNormal|between|BitAnd|BitNot|BitOr|BitShiftLeft|BitShiftRight|BitXOr|Bold|Border|Button|ByRef|Checkbox|Checked|CheckedGray|Choose|ChooseString|Close|Color|ComboBox|Contains|ControlList|Count|Date|DateTime|Days|DDL|Default|DeleteAll|Delimiter|Deref|Destroy|Digit|Disable|Disabled|DropDownList|Edit|Eject|Else|Enable|Enabled|Error|Exist|Expand|ExStyle|FileSystem|First|Flash|Float|FloatFast|Focus|Font|for|global|Grid|Group|GroupBox|GuiClose|GuiContextMenu|GuiDropFiles|GuiEscape|GuiSize|Hdr|Hidden|Hide|High|HKCC|HKCR|HKCU|HKEY_CLASSES_ROOT|HKEY_CURRENT_CONFIG|HKEY_CURRENT_USER|HKEY_LOCAL_MACHINE|HKEY_USERS|HKLM|HKU|Hours|HScroll|Icon|IconSmall|ID|IDLast|If|IfEqual|IfExist|IfGreater|IfGreaterOrEqual|IfInString|IfLess|IfLessOrEqual|IfMsgBox|IfNotEqual|IfNotExist|IfNotInString|IfWinActive|IfWinExist|IfWinNotActive|IfWinNotExist|Ignore|ImageList|in|Integer|IntegerFast|Interrupt|is|italic|Join|Label|LastFound|LastFoundExist|Limit|Lines|List|ListBox|ListView|local|Lock|Logoff|Low|Lower|Lowercase|MainWindow|Margin|Maximize|MaximizeBox|MaxSize|Minimize|MinimizeBox|MinMax|MinSize|Minutes|MonthCal|Mouse|Move|Multi|NA|No|NoActivate|NoDefault|NoHide|NoIcon|NoMainWindow|norm|Normal|NoSort|NoSortHdr|NoStandard|Not|NoTab|NoTimers|Number|Off|Ok|On|OwnDialogs|Owner|Parse|Password|Picture|Pixel|Pos|Pow|Priority|ProcessName|Radio|Range|Read|ReadOnly|Realtime|Redraw|REG_BINARY|REG_DWORD|REG_EXPAND_SZ|REG_MULTI_SZ|REG_SZ|Region|Relative|Rename|Report|Resize|Restore|Retry|RGB|Screen|Seconds|Section|Serial|SetLabel|ShiftAltTab|Show|Single|Slider|SortDesc|Standard|static|Status|StatusBar|StatusCD|strike|Style|Submit|SysMenu|Tab2|TabStop|Text|Theme|Tile|ToggleCheck|ToggleEnable|ToolWindow|Top|Topmost|TransColor|Transparent|Tray|TreeView|TryAgain|Type|UnCheck|underline|Unicode|Unlock|UpDown|Upper|Uppercase|UseErrorLevel|Vis|VisFirst|Visible|VScroll|Wait|WaitClose|WantCtrlA|WantF2|WantReturn|While|Wrap|Xdigit|xm|xp|xs|Yes|ym|yp|ys)\b/i}; \ No newline at end of file From 27009818641cb3c08529feebaec8639072c40293 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sun, 12 Jul 2015 07:59:33 +0200 Subject: [PATCH 104/310] Bash: simplify comment regex --- components/prism-bash.js | 2 +- components/prism-bash.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/prism-bash.js b/components/prism-bash.js index 5ca19ead88..8b52cf32c2 100644 --- a/components/prism-bash.js +++ b/components/prism-bash.js @@ -1,6 +1,6 @@ Prism.languages.bash = Prism.languages.extend('clike', { 'comment': { - pattern: /(^|[^"{\\])(#.*?(\r?\n|$))/, + pattern: /(^|[^"{\\])#.*/, lookbehind: true }, 'string': { diff --git a/components/prism-bash.min.js b/components/prism-bash.min.js index 1571eec822..46564c2028 100644 --- a/components/prism-bash.min.js +++ b/components/prism-bash.min.js @@ -1 +1 @@ -Prism.languages.bash=Prism.languages.extend("clike",{comment:{pattern:/(^|[^"{\\])(#.*?(\r?\n|$))/,lookbehind:!0},string:{pattern:/("|')(\\?[\s\S])*?\1/,inside:{property:/\$([a-zA-Z0-9_#\?\-\*!@]+|\{[^\}]+\})/}},number:{pattern:/([^\w\.])-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,lookbehind:!0},"function":/\b(?:alias|apropos|apt-get|aptitude|aspell|awk|basename|bash|bc|bg|builtin|bzip2|cal|cat|cd|cfdisk|chgrp|chmod|chown|chroot|chkconfig|cksum|clear|cmp|comm|command|cp|cron|crontab|csplit|cut|date|dc|dd|ddrescue|declare|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|echo|egrep|eject|enable|env|ethtool|eval|exec|exit|expand|expect|export|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|getopts|git|grep|groupadd|groupdel|groupmod|groups|gzip|hash|head|help|hg|history|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|jobs|join|kill|killall|less|link|ln|locate|logname|logout|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|make|man|mkdir|mkfifo|mkisofs|mknod|more|most|mount|mtools|mtr|mv|mmv|nano|netstat|nice|nl|nohup|notify-send|nslookup|open|op|passwd|paste|pathchk|ping|pkill|popd|pr|printcap|printenv|printf|ps|pushd|pv|pwd|quota|quotacheck|quotactl|ram|rar|rcp|read|readarray|readonly|reboot|rename|renice|remsync|rev|rm|rmdir|rsync|screen|scp|sdiff|sed|select|seq|service|sftp|shift|shopt|shutdown|sleep|slocate|sort|source|split|ssh|stat|strace|su|sudo|sum|suspend|sync|tail|tar|tee|test|time|timeout|times|touch|top|traceroute|trap|tr|tsort|tty|type|ulimit|umask|umount|unalias|uname|unexpand|uniq|units|unrar|unshar|until|uptime|useradd|userdel|usermod|users|uuencode|uudecode|v|vdir|vi|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yes|zip)\b/,keyword:/\b(if|then|else|elif|fi|for|break|continue|while|in|case|function|select|do|done|until|echo|exit|return|set|declare)\b/}),Prism.languages.insertBefore("bash","keyword",{property:/\$([a-zA-Z0-9_#\?\-\*!@]+|\{[^}]+\})/}),Prism.languages.insertBefore("bash","comment",{important:/(^#!\s*\/bin\/bash)|(^#!\s*\/bin\/sh)/}); \ No newline at end of file +Prism.languages.bash=Prism.languages.extend("clike",{comment:{pattern:/(^|[^"{\\])#.*/,lookbehind:!0},string:{pattern:/("|')(\\?[\s\S])*?\1/,inside:{property:/\$([a-zA-Z0-9_#\?\-\*!@]+|\{[^\}]+\})/}},number:{pattern:/([^\w\.])-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,lookbehind:!0},"function":/\b(?:alias|apropos|apt-get|aptitude|aspell|awk|basename|bash|bc|bg|builtin|bzip2|cal|cat|cd|cfdisk|chgrp|chmod|chown|chroot|chkconfig|cksum|clear|cmp|comm|command|cp|cron|crontab|csplit|cut|date|dc|dd|ddrescue|declare|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|echo|egrep|eject|enable|env|ethtool|eval|exec|exit|expand|expect|export|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|getopts|git|grep|groupadd|groupdel|groupmod|groups|gzip|hash|head|help|hg|history|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|jobs|join|kill|killall|less|link|ln|locate|logname|logout|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|make|man|mkdir|mkfifo|mkisofs|mknod|more|most|mount|mtools|mtr|mv|mmv|nano|netstat|nice|nl|nohup|notify-send|nslookup|open|op|passwd|paste|pathchk|ping|pkill|popd|pr|printcap|printenv|printf|ps|pushd|pv|pwd|quota|quotacheck|quotactl|ram|rar|rcp|read|readarray|readonly|reboot|rename|renice|remsync|rev|rm|rmdir|rsync|screen|scp|sdiff|sed|select|seq|service|sftp|shift|shopt|shutdown|sleep|slocate|sort|source|split|ssh|stat|strace|su|sudo|sum|suspend|sync|tail|tar|tee|test|time|timeout|times|touch|top|traceroute|trap|tr|tsort|tty|type|ulimit|umask|umount|unalias|uname|unexpand|uniq|units|unrar|unshar|until|uptime|useradd|userdel|usermod|users|uuencode|uudecode|v|vdir|vi|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yes|zip)\b/,keyword:/\b(if|then|else|elif|fi|for|break|continue|while|in|case|function|select|do|done|until|echo|exit|return|set|declare)\b/}),Prism.languages.insertBefore("bash","keyword",{property:/\$([a-zA-Z0-9_#\?\-\*!@]+|\{[^}]+\})/}),Prism.languages.insertBefore("bash","comment",{important:/(^#!\s*\/bin\/bash)|(^#!\s*\/bin\/sh)/}); \ No newline at end of file From 903b8a42c363b0d6ca27e19c54f962d21f34e405 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sun, 12 Jul 2015 08:11:33 +0200 Subject: [PATCH 105/310] Bash: removed duplicates in keywords + removed unneeded parentheses --- components/prism-bash.js | 4 ++-- components/prism-bash.min.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/prism-bash.js b/components/prism-bash.js index 8b52cf32c2..5b6486d619 100644 --- a/components/prism-bash.js +++ b/components/prism-bash.js @@ -17,7 +17,7 @@ Prism.languages.bash = Prism.languages.extend('clike', { lookbehind: true }, // Originally based on http://ss64.com/bash/ - 'function': /\b(?:alias|apropos|apt-get|aptitude|aspell|awk|basename|bash|bc|bg|builtin|bzip2|cal|cat|cd|cfdisk|chgrp|chmod|chown|chroot|chkconfig|cksum|clear|cmp|comm|command|cp|cron|crontab|csplit|cut|date|dc|dd|ddrescue|declare|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|echo|egrep|eject|enable|env|ethtool|eval|exec|exit|expand|expect|export|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|getopts|git|grep|groupadd|groupdel|groupmod|groups|gzip|hash|head|help|hg|history|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|jobs|join|kill|killall|less|link|ln|locate|logname|logout|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|make|man|mkdir|mkfifo|mkisofs|mknod|more|most|mount|mtools|mtr|mv|mmv|nano|netstat|nice|nl|nohup|notify-send|nslookup|open|op|passwd|paste|pathchk|ping|pkill|popd|pr|printcap|printenv|printf|ps|pushd|pv|pwd|quota|quotacheck|quotactl|ram|rar|rcp|read|readarray|readonly|reboot|rename|renice|remsync|rev|rm|rmdir|rsync|screen|scp|sdiff|sed|select|seq|service|sftp|shift|shopt|shutdown|sleep|slocate|sort|source|split|ssh|stat|strace|su|sudo|sum|suspend|sync|tail|tar|tee|test|time|timeout|times|touch|top|traceroute|trap|tr|tsort|tty|type|ulimit|umask|umount|unalias|uname|unexpand|uniq|units|unrar|unshar|until|uptime|useradd|userdel|usermod|users|uuencode|uudecode|v|vdir|vi|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yes|zip)\b/, + 'function': /\b(?:alias|apropos|apt-get|aptitude|aspell|awk|basename|bash|bc|bg|builtin|bzip2|cal|cat|cd|cfdisk|chgrp|chmod|chown|chroot|chkconfig|cksum|clear|cmp|comm|command|cp|cron|crontab|csplit|cut|date|dc|dd|ddrescue|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|enable|env|ethtool|eval|exec|expand|expect|export|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|getopts|git|grep|groupadd|groupdel|groupmod|groups|gzip|hash|head|help|hg|history|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|jobs|join|kill|killall|less|link|ln|locate|logname|logout|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|make|man|mkdir|mkfifo|mkisofs|mknod|more|most|mount|mtools|mtr|mv|mmv|nano|netstat|nice|nl|nohup|notify-send|nslookup|open|op|passwd|paste|pathchk|ping|pkill|popd|pr|printcap|printenv|printf|ps|pushd|pv|pwd|quota|quotacheck|quotactl|ram|rar|rcp|read|readarray|readonly|reboot|rename|renice|remsync|rev|rm|rmdir|rsync|screen|scp|sdiff|sed|seq|service|sftp|shift|shopt|shutdown|sleep|slocate|sort|source|split|ssh|stat|strace|su|sudo|sum|suspend|sync|tail|tar|tee|test|time|timeout|times|touch|top|traceroute|trap|tr|tsort|tty|type|ulimit|umask|umount|unalias|uname|unexpand|uniq|units|unrar|unshar|uptime|useradd|userdel|usermod|users|uuencode|uudecode|v|vdir|vi|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yes|zip)\b/, 'keyword': /\b(if|then|else|elif|fi|for|break|continue|while|in|case|function|select|do|done|until|echo|exit|return|set|declare)\b/ }); @@ -27,5 +27,5 @@ Prism.languages.insertBefore('bash', 'keyword', { }); Prism.languages.insertBefore('bash', 'comment', { //shebang must be before comment, 'important' class from css reused - 'important': /(^#!\s*\/bin\/bash)|(^#!\s*\/bin\/sh)/ + 'important': /^#!\s*\/bin\/bash|^#!\s*\/bin\/sh/ }); diff --git a/components/prism-bash.min.js b/components/prism-bash.min.js index 46564c2028..21bc732884 100644 --- a/components/prism-bash.min.js +++ b/components/prism-bash.min.js @@ -1 +1 @@ -Prism.languages.bash=Prism.languages.extend("clike",{comment:{pattern:/(^|[^"{\\])#.*/,lookbehind:!0},string:{pattern:/("|')(\\?[\s\S])*?\1/,inside:{property:/\$([a-zA-Z0-9_#\?\-\*!@]+|\{[^\}]+\})/}},number:{pattern:/([^\w\.])-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,lookbehind:!0},"function":/\b(?:alias|apropos|apt-get|aptitude|aspell|awk|basename|bash|bc|bg|builtin|bzip2|cal|cat|cd|cfdisk|chgrp|chmod|chown|chroot|chkconfig|cksum|clear|cmp|comm|command|cp|cron|crontab|csplit|cut|date|dc|dd|ddrescue|declare|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|echo|egrep|eject|enable|env|ethtool|eval|exec|exit|expand|expect|export|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|getopts|git|grep|groupadd|groupdel|groupmod|groups|gzip|hash|head|help|hg|history|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|jobs|join|kill|killall|less|link|ln|locate|logname|logout|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|make|man|mkdir|mkfifo|mkisofs|mknod|more|most|mount|mtools|mtr|mv|mmv|nano|netstat|nice|nl|nohup|notify-send|nslookup|open|op|passwd|paste|pathchk|ping|pkill|popd|pr|printcap|printenv|printf|ps|pushd|pv|pwd|quota|quotacheck|quotactl|ram|rar|rcp|read|readarray|readonly|reboot|rename|renice|remsync|rev|rm|rmdir|rsync|screen|scp|sdiff|sed|select|seq|service|sftp|shift|shopt|shutdown|sleep|slocate|sort|source|split|ssh|stat|strace|su|sudo|sum|suspend|sync|tail|tar|tee|test|time|timeout|times|touch|top|traceroute|trap|tr|tsort|tty|type|ulimit|umask|umount|unalias|uname|unexpand|uniq|units|unrar|unshar|until|uptime|useradd|userdel|usermod|users|uuencode|uudecode|v|vdir|vi|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yes|zip)\b/,keyword:/\b(if|then|else|elif|fi|for|break|continue|while|in|case|function|select|do|done|until|echo|exit|return|set|declare)\b/}),Prism.languages.insertBefore("bash","keyword",{property:/\$([a-zA-Z0-9_#\?\-\*!@]+|\{[^}]+\})/}),Prism.languages.insertBefore("bash","comment",{important:/(^#!\s*\/bin\/bash)|(^#!\s*\/bin\/sh)/}); \ No newline at end of file +Prism.languages.bash=Prism.languages.extend("clike",{comment:{pattern:/(^|[^"{\\])#.*/,lookbehind:!0},string:{pattern:/("|')(\\?[\s\S])*?\1/,inside:{property:/\$([a-zA-Z0-9_#\?\-\*!@]+|\{[^\}]+\})/}},number:{pattern:/([^\w\.])-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,lookbehind:!0},"function":/\b(?:alias|apropos|apt-get|aptitude|aspell|awk|basename|bash|bc|bg|builtin|bzip2|cal|cat|cd|cfdisk|chgrp|chmod|chown|chroot|chkconfig|cksum|clear|cmp|comm|command|cp|cron|crontab|csplit|cut|date|dc|dd|ddrescue|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|enable|env|ethtool|eval|exec|expand|expect|export|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|getopts|git|grep|groupadd|groupdel|groupmod|groups|gzip|hash|head|help|hg|history|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|jobs|join|kill|killall|less|link|ln|locate|logname|logout|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|make|man|mkdir|mkfifo|mkisofs|mknod|more|most|mount|mtools|mtr|mv|mmv|nano|netstat|nice|nl|nohup|notify-send|nslookup|open|op|passwd|paste|pathchk|ping|pkill|popd|pr|printcap|printenv|printf|ps|pushd|pv|pwd|quota|quotacheck|quotactl|ram|rar|rcp|read|readarray|readonly|reboot|rename|renice|remsync|rev|rm|rmdir|rsync|screen|scp|sdiff|sed|seq|service|sftp|shift|shopt|shutdown|sleep|slocate|sort|source|split|ssh|stat|strace|su|sudo|sum|suspend|sync|tail|tar|tee|test|time|timeout|times|touch|top|traceroute|trap|tr|tsort|tty|type|ulimit|umask|umount|unalias|uname|unexpand|uniq|units|unrar|unshar|uptime|useradd|userdel|usermod|users|uuencode|uudecode|v|vdir|vi|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yes|zip)\b/,keyword:/\b(if|then|else|elif|fi|for|break|continue|while|in|case|function|select|do|done|until|echo|exit|return|set|declare)\b/}),Prism.languages.insertBefore("bash","keyword",{property:/\$([a-zA-Z0-9_#\?\-\*!@]+|\{[^}]+\})/}),Prism.languages.insertBefore("bash","comment",{important:/^#!\s*\/bin\/bash|^#!\s*\/bin\/sh/}); \ No newline at end of file From dcce1a788b2ed1671e0b77ec859a0d29cecc0f40 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sun, 12 Jul 2015 08:21:31 +0200 Subject: [PATCH 106/310] C: Removed string pattern (now that C-like supports escaped new lines) + simplified operators regexp --- components/prism-c.js | 4 +--- components/prism-c.min.js | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/components/prism-c.js b/components/prism-c.js index e9a01909f4..6deb79b2f3 100644 --- a/components/prism-c.js +++ b/components/prism-c.js @@ -1,8 +1,6 @@ Prism.languages.c = Prism.languages.extend('clike', { - // allow for c multiline strings - 'string': /("|')([^\n\\\1]|\\.|\\\r*\n)*?\1/, 'keyword': /\b(asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/, - 'operator': /[-+]{1,2}|!=?|<{1,2}=?|>{1,2}=?|\->|={1,2}|\^|~|%|&{1,2}|\|?\||\?|\*|\// + 'operator': /\-[>-]?|\+\+?|!=?|<>?=?|==?|&&?|\|?\||[~^%?*\/]/ }); Prism.languages.insertBefore('c', 'string', { diff --git a/components/prism-c.min.js b/components/prism-c.min.js index a90b67d6a5..c0e3c8d2e8 100644 --- a/components/prism-c.min.js +++ b/components/prism-c.min.js @@ -1 +1 @@ -Prism.languages.c=Prism.languages.extend("clike",{string:/("|')([^\n\\\1]|\\.|\\\r*\n)*?\1/,keyword:/\b(asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/,operator:/[-+]{1,2}|!=?|<{1,2}=?|>{1,2}=?|\->|={1,2}|\^|~|%|&{1,2}|\|?\||\?|\*|\//}),Prism.languages.insertBefore("c","string",{property:{pattern:/((^|\n)\s*)#\s*[a-z]+([^\n\\]|\\.|\\\r*\n)*/i,lookbehind:!0,inside:{string:{pattern:/(#\s*include\s*)(<.+?>|("|')(\\?.)+?\3)/,lookbehind:!0}}}}),delete Prism.languages.c["class-name"],delete Prism.languages.c["boolean"]; \ No newline at end of file +Prism.languages.c=Prism.languages.extend("clike",{keyword:/\b(asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/,operator:/\-[>-]?|\+\+?|!=?|<>?=?|==?|&&?|\|?\||[~^%?*\/]/}),Prism.languages.insertBefore("c","string",{property:{pattern:/((^|\n)\s*)#\s*[a-z]+([^\n\\]|\\.|\\\r*\n)*/i,lookbehind:!0,inside:{string:{pattern:/(#\s*include\s*)(<.+?>|("|')(\\?.)+?\3)/,lookbehind:!0}}}}),delete Prism.languages.c["class-name"],delete Prism.languages.c["boolean"]; \ No newline at end of file From 48686353c6229d5f0a1ddac95a17616e212c7d88 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sun, 12 Jul 2015 08:30:48 +0200 Subject: [PATCH 107/310] C: Used property as an alias for macro statements + added support for \r in macros --- components/prism-c.js | 6 +++--- components/prism-c.min.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/prism-c.js b/components/prism-c.js index 6deb79b2f3..eb5f115be0 100644 --- a/components/prism-c.js +++ b/components/prism-c.js @@ -4,12 +4,12 @@ Prism.languages.c = Prism.languages.extend('clike', { }); Prism.languages.insertBefore('c', 'string', { - // property class reused for macro statements - 'property': { + 'macro': { // allow for multiline macro definitions // spaces after the # character compile fine with gcc - pattern: /((^|\n)\s*)#\s*[a-z]+([^\n\\]|\\.|\\\r*\n)*/i, + pattern: /(^\s*)#\s*[a-z]+([^\r\n\\]|\\.|\\(?:\r\n?|\n))*/im, lookbehind: true, + alias: 'property', inside: { // highlight the path of the include statement as a string 'string': { diff --git a/components/prism-c.min.js b/components/prism-c.min.js index c0e3c8d2e8..0cbfbf7a93 100644 --- a/components/prism-c.min.js +++ b/components/prism-c.min.js @@ -1 +1 @@ -Prism.languages.c=Prism.languages.extend("clike",{keyword:/\b(asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/,operator:/\-[>-]?|\+\+?|!=?|<>?=?|==?|&&?|\|?\||[~^%?*\/]/}),Prism.languages.insertBefore("c","string",{property:{pattern:/((^|\n)\s*)#\s*[a-z]+([^\n\\]|\\.|\\\r*\n)*/i,lookbehind:!0,inside:{string:{pattern:/(#\s*include\s*)(<.+?>|("|')(\\?.)+?\3)/,lookbehind:!0}}}}),delete Prism.languages.c["class-name"],delete Prism.languages.c["boolean"]; \ No newline at end of file +Prism.languages.c=Prism.languages.extend("clike",{keyword:/\b(asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/,operator:/\-[>-]?|\+\+?|!=?|<>?=?|==?|&&?|\|?\||[~^%?*\/]/}),Prism.languages.insertBefore("c","string",{macro:{pattern:/(^\s*)#\s*[a-z]+([^\r\n\\]|\\.|\\(?:\r\n?|\n))*/im,lookbehind:!0,alias:"property",inside:{string:{pattern:/(#\s*include\s*)(<.+?>|("|')(\\?.)+?\3)/,lookbehind:!0}}}}),delete Prism.languages.c["class-name"],delete Prism.languages.c["boolean"]; \ No newline at end of file From cb6b824254eae66c441bb434ccf89935d5cfc9d8 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sun, 12 Jul 2015 08:38:38 +0200 Subject: [PATCH 108/310] CoffeeScript: prevent strings from ending with a backslash. --- components/prism-coffeescript.js | 4 ++-- components/prism-coffeescript.min.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/prism-coffeescript.js b/components/prism-coffeescript.js index da31f6b329..6e9bdeb66c 100644 --- a/components/prism-coffeescript.js +++ b/components/prism-coffeescript.js @@ -12,11 +12,11 @@ Prism.languages.coffeescript = Prism.languages.extend('javascript', { 'string': [ // Strings are multiline - /'(?:\\?[\s\S])*?'/, + /'(?:\\?[^\\])*?'/, { // Strings are multiline - pattern: /"(?:\\?[\s\S])*?"/, + pattern: /"(?:\\?[^\\])*?"/, inside: { 'interpolation': interpolation } diff --git a/components/prism-coffeescript.min.js b/components/prism-coffeescript.min.js index 7819039b99..a0ec71e0da 100644 --- a/components/prism-coffeescript.min.js +++ b/components/prism-coffeescript.min.js @@ -1 +1 @@ -!function(e){var n=/#(?!\{).+/,t={pattern:/#\{[^}]+\}/,alias:"variable"};e.languages.coffeescript=e.languages.extend("javascript",{comment:n,string:[/'(?:\\?[\s\S])*?'/,{pattern:/"(?:\\?[\s\S])*?"/,inside:{interpolation:t}}],keyword:/\b(and|break|by|catch|class|continue|debugger|delete|do|each|else|extend|extends|false|finally|for|if|in|instanceof|is|isnt|let|loop|namespace|new|no|not|null|of|off|on|or|own|return|super|switch|then|this|throw|true|try|typeof|undefined|unless|until|when|while|window|with|yes|yield)\b/,"class-member":{pattern:/@(?!\d)\w+/,alias:"variable"}}),e.languages.insertBefore("coffeescript","comment",{"multiline-comment":{pattern:/###[\s\S]+?###/,alias:"comment"},"block-regex":{pattern:/\/{3}[\s\S]*?\/{3}/,alias:"regex",inside:{comment:n,interpolation:t}}}),e.languages.insertBefore("coffeescript","string",{"inline-javascript":{pattern:/`(?:\\?[\s\S])*?`/,inside:{delimiter:{pattern:/^`|`$/,alias:"punctuation"},rest:e.languages.javascript}},"multiline-string":[{pattern:/'''[\s\S]*?'''/,alias:"string"},{pattern:/"""[\s\S]*?"""/,alias:"string",inside:{interpolation:t}}]}),e.languages.insertBefore("coffeescript","keyword",{property:/(?!\d)\w+(?=\s*:(?!:))/})}(Prism); \ No newline at end of file +!function(e){var n=/#(?!\{).+/,t={pattern:/#\{[^}]+\}/,alias:"variable"};e.languages.coffeescript=e.languages.extend("javascript",{comment:n,string:[/'(?:\\?[^\\])*?'/,{pattern:/"(?:\\?[^\\])*?"/,inside:{interpolation:t}}],keyword:/\b(and|break|by|catch|class|continue|debugger|delete|do|each|else|extend|extends|false|finally|for|if|in|instanceof|is|isnt|let|loop|namespace|new|no|not|null|of|off|on|or|own|return|super|switch|then|this|throw|true|try|typeof|undefined|unless|until|when|while|window|with|yes|yield)\b/,"class-member":{pattern:/@(?!\d)\w+/,alias:"variable"}}),e.languages.insertBefore("coffeescript","comment",{"multiline-comment":{pattern:/###[\s\S]+?###/,alias:"comment"},"block-regex":{pattern:/\/{3}[\s\S]*?\/{3}/,alias:"regex",inside:{comment:n,interpolation:t}}}),e.languages.insertBefore("coffeescript","string",{"inline-javascript":{pattern:/`(?:\\?[\s\S])*?`/,inside:{delimiter:{pattern:/^`|`$/,alias:"punctuation"},rest:e.languages.javascript}},"multiline-string":[{pattern:/'''[\s\S]*?'''/,alias:"string"},{pattern:/"""[\s\S]*?"""/,alias:"string",inside:{interpolation:t}}]}),e.languages.insertBefore("coffeescript","keyword",{property:/(?!\d)\w+(?=\s*:(?!:))/})}(Prism); \ No newline at end of file From 42fbeef51b668373fe41b0b42ffa6df7ec31e098 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sun, 12 Jul 2015 09:10:18 +0200 Subject: [PATCH 109/310] C++: Removed delete[] and new[] broken keywords. They'll be highlighted as keyword+punctuation. --- components/prism-cpp.js | 2 +- components/prism-cpp.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/prism-cpp.js b/components/prism-cpp.js index ba0707c94a..8ce28f628e 100644 --- a/components/prism-cpp.js +++ b/components/prism-cpp.js @@ -1,5 +1,5 @@ Prism.languages.cpp = Prism.languages.extend('c', { - 'keyword': /\b(alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype|default|delete|delete\[\]|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|long|mutable|namespace|new|new\[\]|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/, + 'keyword': /\b(alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/, 'boolean': /\b(true|false)\b/, 'operator': /[-+]{1,2}|!=?|<{1,2}=?|>{1,2}=?|\->|:{1,2}|={1,2}|\^|~|%|&{1,2}|\|?\||\?|\*|\/|\b(and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/ }); diff --git a/components/prism-cpp.min.js b/components/prism-cpp.min.js index 3d02e12825..44b49fb8e0 100644 --- a/components/prism-cpp.min.js +++ b/components/prism-cpp.min.js @@ -1 +1 @@ -Prism.languages.cpp=Prism.languages.extend("c",{keyword:/\b(alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype|default|delete|delete\[\]|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|long|mutable|namespace|new|new\[\]|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,"boolean":/\b(true|false)\b/,operator:/[-+]{1,2}|!=?|<{1,2}=?|>{1,2}=?|\->|:{1,2}|={1,2}|\^|~|%|&{1,2}|\|?\||\?|\*|\/|\b(and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/}),Prism.languages.insertBefore("cpp","keyword",{"class-name":{pattern:/(class\s+)[a-z0-9_]+/i,lookbehind:!0}}); \ No newline at end of file +Prism.languages.cpp=Prism.languages.extend("c",{keyword:/\b(alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,"boolean":/\b(true|false)\b/,operator:/[-+]{1,2}|!=?|<{1,2}=?|>{1,2}=?|\->|:{1,2}|={1,2}|\^|~|%|&{1,2}|\|?\||\?|\*|\/|\b(and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/}),Prism.languages.insertBefore("cpp","keyword",{"class-name":{pattern:/(class\s+)[a-z0-9_]+/i,lookbehind:!0}}); \ No newline at end of file From 9619d4cb37dda40f1553c156a7b2658f1c1117e1 Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Tue, 14 Jul 2015 10:46:57 +0200 Subject: [PATCH 110/310] Implement support for simplifying nested token streams --- tests/helper/test-case.js | 39 ++++++++++++++++++++------- tests/languages/apacheconf/test2.test | 6 +++++ 2 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 tests/languages/apacheconf/test2.test diff --git a/tests/helper/test-case.js b/tests/helper/test-case.js index 095cba0eda..92a9951508 100644 --- a/tests/helper/test-case.js +++ b/tests/helper/test-case.js @@ -55,7 +55,7 @@ module.exports = { var languages = languageIdentifier.split("+"); if (null === testCase) { - throw new Error("Test case file has invalid format, please read the docs."); + throw new Error("Test case file has invalid format (or the provided token stream is invalid JSON), please read the docs."); } var Prism = PrismLoader.createInstance(languages); @@ -72,20 +72,41 @@ module.exports = { * Simplifies the token stream to ease the matching with the expected token stream * * @param {string} tokenStream - * @returns {Array.} + * @returns {Array.} */ transformCompiledTokenStream: function (tokenStream) { + // First filter all top-level non-objects as non-objects are not-identified tokens + // + // we don't want to filter them in the lower levels as we want to support nested content-structures return tokenStream.filter( function (token) { - // only support objects return (typeof token === "object"); } - ).map( - function (entry) - { - return [entry.type, entry.content]; - } - ); + ).map(this.transformCompiledRecursivelyTokenStream.bind(this)); + }, + + + /** + * Walks the token stream and recursively simplifies it + * + * @private + * @param {Array|{type: string, content: *}|string} token + * @returns {Array|string} + */ + transformCompiledRecursivelyTokenStream: function (token) + { + if (Array.isArray(token)) + { + return token.map(this.transformCompiledRecursivelyTokenStream.bind(this)); + } + else if (typeof token === "object") + { + return [token.type, this.transformCompiledRecursivelyTokenStream(token.content)]; + } + else + { + return token; + } }, diff --git a/tests/languages/apacheconf/test2.test b/tests/languages/apacheconf/test2.test new file mode 100644 index 0000000000..fbc0728b0b --- /dev/null +++ b/tests/languages/apacheconf/test2.test @@ -0,0 +1,6 @@ +"foo bar" +'foo bar' +"%{REMOTE_HOST}" + +----- +[] From 9ce5838a4f8812462d2f664ee7b68d32c01ebe1b Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Tue, 14 Jul 2015 10:51:35 +0200 Subject: [PATCH 111/310] Catch JSON parse error to provide a unified error reporting in the test runner --- tests/helper/test-case.js | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/tests/helper/test-case.js b/tests/helper/test-case.js index 92a9951508..240599e06b 100644 --- a/tests/helper/test-case.js +++ b/tests/helper/test-case.js @@ -121,23 +121,25 @@ module.exports = { var testCaseSource = fs.readFileSync(filePath, "utf8"); var testCaseParts = testCaseSource.split(/^----*\w*$/m); - // No expected token stream found - if (2 > testCaseParts.length) { - return null; - } - - var testCase = { - testSource: testCaseParts[0].trim(), - expectedTokenStream: JSON.parse(testCaseParts[1]), - comment: null - }; + try { + var testCase = { + testSource: testCaseParts[0].trim(), + expectedTokenStream: JSON.parse(testCaseParts[1]), + comment: null + }; + + // if there are three parts, the third one is the comment + // explaining the test case + if (testCaseParts[2]) { + testCase.comment = testCaseParts[2].trim(); + } - // if there are three parts, the third one is the comment - // explaining the test case - if (testCaseParts[2]) { - testCase.comment = testCaseParts[2].trim(); + return testCase; + } + catch (e) + { + // the JSON can't be parsed (e.g. it could be empty) + return null; } - - return testCase; } }; From ea2349349b677b5f07822bbf1161533348aeb486 Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Tue, 14 Jul 2015 10:51:56 +0200 Subject: [PATCH 112/310] Fully defined Apacheconf test case --- tests/languages/apacheconf/test2.test | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/languages/apacheconf/test2.test b/tests/languages/apacheconf/test2.test index fbc0728b0b..a136917c03 100644 --- a/tests/languages/apacheconf/test2.test +++ b/tests/languages/apacheconf/test2.test @@ -3,4 +3,14 @@ "%{REMOTE_HOST}" ----- -[] +[ + ["string", ["\"foo bar\""]], + ["string", ["'foo bar'"]], + [ + "string", [ + "\"", + ["variable", "%{REMOTE_HOST}"], + "\"" + ] + ] +] From 5c2f9e0a500661473fc9ca068b90e3afa2eb5c77 Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Wed, 15 Jul 2015 19:29:27 +0200 Subject: [PATCH 113/310] Use consistent quote style --- tests/helper/components.js | 2 +- tests/helper/prism-loader.js | 2 +- tests/helper/test-discovery.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/helper/components.js b/tests/helper/components.js index 274ad146f7..09dd6aa957 100644 --- a/tests/helper/components.js +++ b/tests/helper/components.js @@ -1,7 +1,7 @@ "use strict"; var fs = require("fs"); -var vm = require('vm'); +var vm = require("vm"); var fileContent = fs.readFileSync(__dirname + "/../../components.js", "utf8"); var context = {}; diff --git a/tests/helper/prism-loader.js b/tests/helper/prism-loader.js index 87739fd2e9..ea82c0bc47 100644 --- a/tests/helper/prism-loader.js +++ b/tests/helper/prism-loader.js @@ -1,7 +1,7 @@ "use strict"; var fs = require("fs"); -var vm = require('vm'); +var vm = require("vm"); var components = require("./components"); var languagesCatalog = components.languages; diff --git a/tests/helper/test-discovery.js b/tests/helper/test-discovery.js index 7cbaef8193..741dc7591b 100644 --- a/tests/helper/test-discovery.js +++ b/tests/helper/test-discovery.js @@ -1,7 +1,7 @@ "use strict"; var fs = require("fs"); -var path = require('path'); +var path = require("path"); module.exports = { From 3a3cd26838a2c8181c050dfc437d24d8cd4e153c Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Wed, 15 Jul 2015 19:35:07 +0200 Subject: [PATCH 114/310] Extract simplification of token stream Pull the token stream transformation out of the test case into its own component. --- tests/helper/test-case.js | 44 ++--------------------- tests/helper/token-stream-transformer.js | 45 ++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 42 deletions(-) create mode 100644 tests/helper/token-stream-transformer.js diff --git a/tests/helper/test-case.js b/tests/helper/test-case.js index 240599e06b..b62d230da9 100644 --- a/tests/helper/test-case.js +++ b/tests/helper/test-case.js @@ -3,6 +3,7 @@ var fs = require("fs"); var assert = require("chai").assert; var PrismLoader = require("./prism-loader"); +var TokenStreamTransformer = require("./token-stream-transformer"); /** * Handles parsing of a test case file. @@ -62,53 +63,12 @@ module.exports = { // the first language is the main language to highlight var mainLanguageGrammar = Prism.languages[languages[0]]; var compiledTokenStream = Prism.tokenize(testCase.testSource, mainLanguageGrammar); - var simplifiedTokenStream = this.transformCompiledTokenStream(compiledTokenStream); + var simplifiedTokenStream = TokenStreamTransformer.simplify(compiledTokenStream); assert.deepEqual(simplifiedTokenStream, testCase.expectedTokenStream, testCase.comment); }, - /** - * Simplifies the token stream to ease the matching with the expected token stream - * - * @param {string} tokenStream - * @returns {Array.} - */ - transformCompiledTokenStream: function (tokenStream) { - // First filter all top-level non-objects as non-objects are not-identified tokens - // - // we don't want to filter them in the lower levels as we want to support nested content-structures - return tokenStream.filter( - function (token) { - return (typeof token === "object"); - } - ).map(this.transformCompiledRecursivelyTokenStream.bind(this)); - }, - - - /** - * Walks the token stream and recursively simplifies it - * - * @private - * @param {Array|{type: string, content: *}|string} token - * @returns {Array|string} - */ - transformCompiledRecursivelyTokenStream: function (token) - { - if (Array.isArray(token)) - { - return token.map(this.transformCompiledRecursivelyTokenStream.bind(this)); - } - else if (typeof token === "object") - { - return [token.type, this.transformCompiledRecursivelyTokenStream(token.content)]; - } - else - { - return token; - } - }, - /** * Parses the test case from the given test case file diff --git a/tests/helper/token-stream-transformer.js b/tests/helper/token-stream-transformer.js new file mode 100644 index 0000000000..fdc635bf5d --- /dev/null +++ b/tests/helper/token-stream-transformer.js @@ -0,0 +1,45 @@ +"use strict"; + + +module.exports = { + /** + * Simplifies the token stream to ease the matching with the expected token stream + * + * @param {string} tokenStream + * @returns {Array.} + */ + simplify: function (tokenStream) { + // First filter all top-level non-objects as non-objects are not-identified tokens + // + // we don't want to filter them in the lower levels as we want to support nested content-structures + return tokenStream.filter( + function (token) { + return (typeof token === "object"); + } + ).map(this.simplifyRecursively.bind(this)); + }, + + + /** + * Walks the token stream and recursively simplifies it + * + * @private + * @param {Array|{type: string, content: *}|string} token + * @returns {Array|string} + */ + simplifyRecursively: function (token) + { + if (Array.isArray(token)) + { + return token.map(this.simplifyRecursively.bind(this)); + } + else if (typeof token === "object") + { + return [token.type, this.simplifyRecursively(token.content)]; + } + else + { + return token; + } + } +}; From f05e0797648e816d38c86edaead9095c71cfdbf7 Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Wed, 15 Jul 2015 20:01:39 +0200 Subject: [PATCH 115/310] Updated simplification of token stream It now strips empty values --- tests/helper/token-stream-transformer.js | 45 ++++++++++-------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/tests/helper/token-stream-transformer.js b/tests/helper/token-stream-transformer.js index fdc635bf5d..38aa77ca24 100644 --- a/tests/helper/token-stream-transformer.js +++ b/tests/helper/token-stream-transformer.js @@ -3,43 +3,34 @@ module.exports = { /** - * Simplifies the token stream to ease the matching with the expected token stream + * Simplifies the token stream to ease the matching with the expected token stream. * - * @param {string} tokenStream + * * Strings are kept as-is + * * In arrays each value is transformed individually + * * Values that are empty (empty arrays or strings only containing whitespace) + * + * + * @param {Array} tokenStream * @returns {Array.} */ simplify: function (tokenStream) { - // First filter all top-level non-objects as non-objects are not-identified tokens - // - // we don't want to filter them in the lower levels as we want to support nested content-structures - return tokenStream.filter( - function (token) { - return (typeof token === "object"); - } - ).map(this.simplifyRecursively.bind(this)); - }, - - - /** - * Walks the token stream and recursively simplifies it - * - * @private - * @param {Array|{type: string, content: *}|string} token - * @returns {Array|string} - */ - simplifyRecursively: function (token) - { - if (Array.isArray(token)) + if (Array.isArray(tokenStream)) { - return token.map(this.simplifyRecursively.bind(this)); + return tokenStream + .map(this.simplify.bind(this)) + .filter(function(value) + { + return !(Array.isArray(value) && !value.length) && !(typeof value === "string" && !value.trim().length); + } + ); } - else if (typeof token === "object") + else if (typeof tokenStream === "object") { - return [token.type, this.simplifyRecursively(token.content)]; + return [tokenStream.type, this.simplify(tokenStream.content)]; } else { - return token; + return tokenStream; } } }; From 8bdf4c87d899692e6ce4422309531ecae25cc9a4 Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Wed, 15 Jul 2015 20:02:49 +0200 Subject: [PATCH 116/310] Test the test runner itself We are at a point where we probably should test the test runner (especially the token stream transformer) itself. --- package.json | 2 +- tests/testrunner-tests.js | 91 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 tests/testrunner-tests.js diff --git a/package.json b/package.json index e254ad770a..2f8af95a5f 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Lightweight, robust, elegant syntax highlighting. A spin-off project from Dabblet.", "main": "prism.js", "scripts": { - "test": "mocha tests/run.js" + "test": "mocha tests/testrunner-tests.js && mocha tests/run.js" }, "repository": { "type": "git", diff --git a/tests/testrunner-tests.js b/tests/testrunner-tests.js new file mode 100644 index 0000000000..f414e8b808 --- /dev/null +++ b/tests/testrunner-tests.js @@ -0,0 +1,91 @@ +"use strict"; + +var assert = require("chai").assert; +var TokenStreamTransformer = require("./helper/token-stream-transformer"); + +describe("The token stream transformer", + function () + { + it("should handle all kinds of simple transformations", + function () + { + var tokens = [ + {type: "type", content: "content"}, + "string" + ]; + + var expected = [ + ["type", "content"], + "string" + ]; + + assert.deepEqual(TokenStreamTransformer.simplify(tokens), expected); + } + ); + + + it("should handle nested structures", + function () + { + var tokens = [ + {type: "type", content: [ + {type: "insideType", content: [ + {type: "insideInsideType", content: "content"} + ]} + ]} + ]; + + var expected = [ + ["type", [ + ["insideType", [ + ["insideInsideType", "content"] + ]] + ]] + ]; + + assert.deepEqual(TokenStreamTransformer.simplify(tokens), expected); + } + ); + + + it("should strip empty tokens", + function () + { + var tokenStream = [ + "", + "\r\n", + "\t", + " " + ]; + + var expectedSimplified = []; + + assert.deepEqual(TokenStreamTransformer.simplify(tokenStream), expectedSimplified); + } + ); + + + it("should strip empty token tree branches", + function () + { + var tokenStream = [ + {type: "type", content: [ + ["", ""], + "", + {type: "nested", content: [""]} + ]}, + [[[[[[[""]]]]]]] + ]; + + var expectedSimplified = [ + ["type", [ + ["nested", []] + ]] + ]; + + assert.deepEqual(TokenStreamTransformer.simplify(tokenStream), expectedSimplified); + } + ); + } +); + From b8d92aa75ca1560aba65e0d08bf672c4baf2cf4b Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Wed, 15 Jul 2015 20:06:21 +0200 Subject: [PATCH 117/310] Verify that the token stream transfomer ignores all token properties except type and content --- tests/testrunner-tests.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/testrunner-tests.js b/tests/testrunner-tests.js index f414e8b808..b9f79dc88e 100644 --- a/tests/testrunner-tests.js +++ b/tests/testrunner-tests.js @@ -86,6 +86,23 @@ describe("The token stream transformer", assert.deepEqual(TokenStreamTransformer.simplify(tokenStream), expectedSimplified); } ); + + + it("should ignore all properties in tokens except value and content", + function () + { + + var tokenStream = [ + {type: "type", content: "content", alias: "alias"} + ]; + + var expectedSimplified = [ + ["type", "content"] + ]; + + assert.deepEqual(TokenStreamTransformer.simplify(tokenStream), expectedSimplified); + } + ); } ); From 86311f5e9ef1fbfcf016ea3fe6e3ca1c7d869dc3 Mon Sep 17 00:00:00 2001 From: Golmote Date: Thu, 16 Jul 2015 08:06:25 +0200 Subject: [PATCH 118/310] C#: Fix preprocessor pattern --- components/prism-csharp.js | 8 +++++++- components/prism-csharp.min.js | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/components/prism-csharp.js b/components/prism-csharp.js index 50ee493ee1..e6f83d3cc1 100644 --- a/components/prism-csharp.js +++ b/components/prism-csharp.js @@ -4,6 +4,12 @@ Prism.languages.csharp = Prism.languages.extend('clike', { /@("|')(\1\1|\\\1|\\?(?!\1)[\s\S])*\1/, /("|')(\\?.)*?\1/ ], - 'preprocessor': /^\s*#.*/m, 'number': /\b-?(0x[\da-f]+|\d*\.?\d+)\b/i }); + +Prism.languages.insertBefore('csharp', 'keyword', { + 'preprocessor': { + pattern: /(^\s*)#.*/m, + lookbehind: true + } +}); diff --git a/components/prism-csharp.min.js b/components/prism-csharp.min.js index abde3d03c6..f9b3c9bd2f 100644 --- a/components/prism-csharp.min.js +++ b/components/prism-csharp.min.js @@ -1 +1 @@ -Prism.languages.csharp=Prism.languages.extend("clike",{keyword:/\b(abstract|as|async|await|base|bool|break|byte|case|catch|char|checked|class|const|continue|decimal|default|delegate|do|double|else|enum|event|explicit|extern|false|finally|fixed|float|for|foreach|goto|if|implicit|in|int|interface|internal|is|lock|long|namespace|new|null|object|operator|out|override|params|private|protected|public|readonly|ref|return|sbyte|sealed|short|sizeof|stackalloc|static|string|struct|switch|this|throw|true|try|typeof|uint|ulong|unchecked|unsafe|ushort|using|virtual|void|volatile|while|add|alias|ascending|async|await|descending|dynamic|from|get|global|group|into|join|let|orderby|partial|remove|select|set|value|var|where|yield)\b/,string:[/@("|')(\1\1|\\\1|\\?(?!\1)[\s\S])*\1/,/("|')(\\?.)*?\1/],preprocessor:/^\s*#.*/m,number:/\b-?(0x[\da-f]+|\d*\.?\d+)\b/i}); \ No newline at end of file +Prism.languages.csharp=Prism.languages.extend("clike",{keyword:/\b(abstract|as|async|await|base|bool|break|byte|case|catch|char|checked|class|const|continue|decimal|default|delegate|do|double|else|enum|event|explicit|extern|false|finally|fixed|float|for|foreach|goto|if|implicit|in|int|interface|internal|is|lock|long|namespace|new|null|object|operator|out|override|params|private|protected|public|readonly|ref|return|sbyte|sealed|short|sizeof|stackalloc|static|string|struct|switch|this|throw|true|try|typeof|uint|ulong|unchecked|unsafe|ushort|using|virtual|void|volatile|while|add|alias|ascending|async|await|descending|dynamic|from|get|global|group|into|join|let|orderby|partial|remove|select|set|value|var|where|yield)\b/,string:[/@("|')(\1\1|\\\1|\\?(?!\1)[\s\S])*\1/,/("|')(\\?.)*?\1/],number:/\b-?(0x[\da-f]+|\d*\.?\d+)\b/i}),Prism.languages.insertBefore("csharp","keyword",{preprocessor:{pattern:/(^\s*)#.*/m,lookbehind:!0}}); \ No newline at end of file From 5f133c800fdd178f6899c1ffa8a38ffbdc7a746f Mon Sep 17 00:00:00 2001 From: Golmote Date: Thu, 16 Jul 2015 21:09:40 +0200 Subject: [PATCH 119/310] Fixed prism-core and prism-file-highlight to prevent errors in IE8. Used local variable _self instead of overwriting self. Closes #468. --- components/prism-core.js | 25 ++--- components/prism-core.min.js | 2 +- .../file-highlight/prism-file-highlight.js | 76 +++++++------- .../prism-file-highlight.min.js | 2 +- prism.js | 99 ++++++++++--------- 5 files changed, 105 insertions(+), 99 deletions(-) diff --git a/components/prism-core.js b/components/prism-core.js index b9a0ac61a8..542464e084 100644 --- a/components/prism-core.js +++ b/components/prism-core.js @@ -1,4 +1,4 @@ -self = (typeof window !== 'undefined') +var _self = (typeof window !== 'undefined') ? window // if in browser : ( (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) @@ -17,7 +17,7 @@ var Prism = (function(){ // Private helper vars var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i; -var _ = self.Prism = { +var _ = _self.Prism = { util: { encode: function (tokens) { if (tokens instanceof Token) { @@ -50,7 +50,8 @@ var _ = self.Prism = { return clone; case 'Array': - return o.map(function(v) { return _.util.clone(v); }); + // Check for existence for IE8 + return o.map && o.map(function(v) { return _.util.clone(v); }); } return o; @@ -192,7 +193,7 @@ var _ = self.Prism = { _.hooks.run('before-highlight', env); - if (async && self.Worker) { + if (async && _self.Worker) { var worker = new Worker(_.filename); worker.onmessage = function(evt) { @@ -386,22 +387,22 @@ Token.stringify = function(o, language, parent) { }; -if (!self.document) { - if (!self.addEventListener) { +if (!_self.document) { + if (!_self.addEventListener) { // in Node.js - return self.Prism; + return _self.Prism; } // In worker - self.addEventListener('message', function(evt) { + _self.addEventListener('message', function(evt) { var message = JSON.parse(evt.data), lang = message.language, code = message.code; - self.postMessage(JSON.stringify(_.util.encode(_.tokenize(code, _.languages[lang])))); - self.close(); + _self.postMessage(JSON.stringify(_.util.encode(_.tokenize(code, _.languages[lang])))); + _self.close(); }, false); - return self.Prism; + return _self.Prism; } // Get current script and highlight @@ -417,7 +418,7 @@ if (script) { } } -return self.Prism; +return _self.Prism; })(); diff --git a/components/prism-core.min.js b/components/prism-core.min.js index df4ccd4c43..5f781e29fe 100644 --- a/components/prism-core.min.js +++ b/components/prism-core.min.js @@ -1 +1 @@ -self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{};var Prism=function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=self.Prism={util:{encode:function(e){return e instanceof n?new n(e.type,t.util.encode(e.content),e.alias):"Array"===t.util.type(e)?e.map(t.util.encode):e.replace(/&/g,"&").replace(/e.length)break e;if(!(d instanceof a)){u.lastIndex=0;var m=u.exec(d);if(m){c&&(f=m[1].length);var y=m.index-1+f,m=m[0].slice(f),v=m.length,k=y+v,b=d.slice(0,y+1),w=d.slice(k+1),N=[p,1];b&&N.push(b);var O=new a(l,g?t.tokenize(m,g):m,h);N.push(O),w&&N.push(w),Array.prototype.splice.apply(r,N)}}}}}return r},hooks:{all:{},add:function(e,n){var a=t.hooks.all;a[e]=a[e]||[],a[e].push(n)},run:function(e,n){var a=t.hooks.all[e];if(a&&a.length)for(var r,i=0;r=a[i++];)r(n)}}},n=t.Token=function(e,t,n){this.type=e,this.content=t,this.alias=n};if(n.stringify=function(e,a,r){if("string"==typeof e)return e;if("Array"===t.util.type(e))return e.map(function(t){return n.stringify(t,a,e)}).join("");var i={type:e.type,content:n.stringify(e.content,a,r),tag:"span",classes:["token",e.type],attributes:{},language:a,parent:r};if("comment"==i.type&&(i.attributes.spellcheck="true"),e.alias){var l="Array"===t.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(i.classes,l)}t.hooks.run("wrap",i);var s="";for(var o in i.attributes)s+=o+'="'+(i.attributes[o]||"")+'"';return"<"+i.tag+' class="'+i.classes.join(" ")+'" '+s+">"+i.content+""},!self.document)return self.addEventListener?(self.addEventListener("message",function(e){var n=JSON.parse(e.data),a=n.language,r=n.code;self.postMessage(JSON.stringify(t.util.encode(t.tokenize(r,t.languages[a])))),self.close()},!1),self.Prism):self.Prism;var a=document.getElementsByTagName("script");return a=a[a.length-1],a&&(t.filename=a.src,document.addEventListener&&!a.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)),self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism); \ No newline at end of file +var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=_self.Prism={util:{encode:function(e){return e instanceof n?new n(e.type,t.util.encode(e.content),e.alias):"Array"===t.util.type(e)?e.map(t.util.encode):e.replace(/&/g,"&").replace(/e.length)break e;if(!(d instanceof a)){u.lastIndex=0;var m=u.exec(d);if(m){c&&(f=m[1].length);var y=m.index-1+f,m=m[0].slice(f),v=m.length,k=y+v,b=d.slice(0,y+1),w=d.slice(k+1),N=[p,1];b&&N.push(b);var O=new a(l,g?t.tokenize(m,g):m,h);N.push(O),w&&N.push(w),Array.prototype.splice.apply(r,N)}}}}}return r},hooks:{all:{},add:function(e,n){var a=t.hooks.all;a[e]=a[e]||[],a[e].push(n)},run:function(e,n){var a=t.hooks.all[e];if(a&&a.length)for(var r,i=0;r=a[i++];)r(n)}}},n=t.Token=function(e,t,n){this.type=e,this.content=t,this.alias=n};if(n.stringify=function(e,a,r){if("string"==typeof e)return e;if("Array"===t.util.type(e))return e.map(function(t){return n.stringify(t,a,e)}).join("");var i={type:e.type,content:n.stringify(e.content,a,r),tag:"span",classes:["token",e.type],attributes:{},language:a,parent:r};if("comment"==i.type&&(i.attributes.spellcheck="true"),e.alias){var l="Array"===t.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(i.classes,l)}t.hooks.run("wrap",i);var s="";for(var o in i.attributes)s+=o+'="'+(i.attributes[o]||"")+'"';return"<"+i.tag+' class="'+i.classes.join(" ")+'" '+s+">"+i.content+""},!_self.document)return _self.addEventListener?(_self.addEventListener("message",function(e){var n=JSON.parse(e.data),a=n.language,r=n.code;_self.postMessage(JSON.stringify(t.util.encode(t.tokenize(r,t.languages[a])))),_self.close()},!1),_self.Prism):_self.Prism;var a=document.getElementsByTagName("script");return a=a[a.length-1],a&&(t.filename=a.src,document.addEventListener&&!a.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)),_self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism); \ No newline at end of file diff --git a/plugins/file-highlight/prism-file-highlight.js b/plugins/file-highlight/prism-file-highlight.js index 5fea85abf0..1a49254f27 100644 --- a/plugins/file-highlight/prism-file-highlight.js +++ b/plugins/file-highlight/prism-file-highlight.js @@ -16,56 +16,58 @@ 'psm1': 'powershell' }; - Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function(pre) { - var src = pre.getAttribute('data-src'); - - var language, parent = pre; - var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i; - while (parent && !lang.test(parent.className)) { - parent = parent.parentNode; - } + if(Array.prototype.forEach) { // Check to prevent error in IE8 + Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) { + var src = pre.getAttribute('data-src'); + + var language, parent = pre; + var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i; + while (parent && !lang.test(parent.className)) { + parent = parent.parentNode; + } - if (parent) { - language = (pre.className.match(lang) || [,''])[1]; - } + if (parent) { + language = (pre.className.match(lang) || [, ''])[1]; + } - if (!language) { - var extension = (src.match(/\.(\w+)$/) || [, ''])[1]; - language = Extensions[extension] || extension; - } + if (!language) { + var extension = (src.match(/\.(\w+)$/) || [, ''])[1]; + language = Extensions[extension] || extension; + } - var code = document.createElement('code'); - code.className = 'language-' + language; + var code = document.createElement('code'); + code.className = 'language-' + language; - pre.textContent = ''; + pre.textContent = ''; - code.textContent = 'Loading…'; + code.textContent = 'Loading…'; - pre.appendChild(code); + pre.appendChild(code); - var xhr = new XMLHttpRequest(); + var xhr = new XMLHttpRequest(); - xhr.open('GET', src, true); + xhr.open('GET', src, true); - xhr.onreadystatechange = function() { - if (xhr.readyState == 4) { + xhr.onreadystatechange = function () { + if (xhr.readyState == 4) { - if (xhr.status < 400 && xhr.responseText) { - code.textContent = xhr.responseText; + if (xhr.status < 400 && xhr.responseText) { + code.textContent = xhr.responseText; - Prism.highlightElement(code); + Prism.highlightElement(code); + } + else if (xhr.status >= 400) { + code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText; + } + else { + code.textContent = '✖ Error: File does not exist or is empty'; + } } - else if (xhr.status >= 400) { - code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText; - } - else { - code.textContent = '✖ Error: File does not exist or is empty'; - } - } - }; + }; - xhr.send(null); - }); + xhr.send(null); + }); + } }; diff --git a/plugins/file-highlight/prism-file-highlight.min.js b/plugins/file-highlight/prism-file-highlight.min.js index 42889f90b6..2d75007f66 100644 --- a/plugins/file-highlight/prism-file-highlight.min.js +++ b/plugins/file-highlight/prism-file-highlight.min.js @@ -1 +1 @@ -!function(){self.Prism&&self.document&&document.querySelector&&(self.Prism.fileHighlight=function(){var e={js:"javascript",html:"markup",svg:"markup",xml:"markup",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell"};Array.prototype.slice.call(document.querySelectorAll("pre[data-src]")).forEach(function(t){for(var r,s=t.getAttribute("data-src"),a=t,n=/\blang(?:uage)?-(?!\*)(\w+)\b/i;a&&!n.test(a.className);)a=a.parentNode;if(a&&(r=(t.className.match(n)||[,""])[1]),!r){var l=(s.match(/\.(\w+)$/)||[,""])[1];r=e[l]||l}var o=document.createElement("code");o.className="language-"+r,t.textContent="",o.textContent="Loading…",t.appendChild(o);var i=new XMLHttpRequest;i.open("GET",s,!0),i.onreadystatechange=function(){4==i.readyState&&(i.status<400&&i.responseText?(o.textContent=i.responseText,Prism.highlightElement(o)):o.textContent=i.status>=400?"✖ Error "+i.status+" while fetching file: "+i.statusText:"✖ Error: File does not exist or is empty")},i.send(null)})},self.Prism.fileHighlight())}(); \ No newline at end of file +!function(){self.Prism&&self.document&&document.querySelector&&(self.Prism.fileHighlight=function(){var e={js:"javascript",html:"markup",svg:"markup",xml:"markup",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell"};Array.prototype.forEach&&Array.prototype.slice.call(document.querySelectorAll("pre[data-src]")).forEach(function(t){for(var r,a=t.getAttribute("data-src"),s=t,n=/\blang(?:uage)?-(?!\*)(\w+)\b/i;s&&!n.test(s.className);)s=s.parentNode;if(s&&(r=(t.className.match(n)||[,""])[1]),!r){var o=(a.match(/\.(\w+)$/)||[,""])[1];r=e[o]||o}var l=document.createElement("code");l.className="language-"+r,t.textContent="",l.textContent="Loading…",t.appendChild(l);var i=new XMLHttpRequest;i.open("GET",a,!0),i.onreadystatechange=function(){4==i.readyState&&(i.status<400&&i.responseText?(l.textContent=i.responseText,Prism.highlightElement(l)):l.textContent=i.status>=400?"✖ Error "+i.status+" while fetching file: "+i.statusText:"✖ Error: File does not exist or is empty")},i.send(null)})},self.Prism.fileHighlight())}(); \ No newline at end of file diff --git a/prism.js b/prism.js index 91fa896622..8282b57193 100644 --- a/prism.js +++ b/prism.js @@ -3,7 +3,7 @@ Begin prism-core.js ********************************************** */ -self = (typeof window !== 'undefined') +var _self = (typeof window !== 'undefined') ? window // if in browser : ( (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) @@ -22,7 +22,7 @@ var Prism = (function(){ // Private helper vars var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i; -var _ = self.Prism = { +var _ = _self.Prism = { util: { encode: function (tokens) { if (tokens instanceof Token) { @@ -55,7 +55,8 @@ var _ = self.Prism = { return clone; case 'Array': - return o.map(function(v) { return _.util.clone(v); }); + // Check for existence for IE8 + return o.map && o.map(function(v) { return _.util.clone(v); }); } return o; @@ -197,7 +198,7 @@ var _ = self.Prism = { _.hooks.run('before-highlight', env); - if (async && self.Worker) { + if (async && _self.Worker) { var worker = new Worker(_.filename); worker.onmessage = function(evt) { @@ -391,22 +392,22 @@ Token.stringify = function(o, language, parent) { }; -if (!self.document) { - if (!self.addEventListener) { +if (!_self.document) { + if (!_self.addEventListener) { // in Node.js - return self.Prism; + return _self.Prism; } // In worker - self.addEventListener('message', function(evt) { + _self.addEventListener('message', function(evt) { var message = JSON.parse(evt.data), lang = message.language, code = message.code; - self.postMessage(JSON.stringify(_.util.encode(_.tokenize(code, _.languages[lang])))); - self.close(); + _self.postMessage(JSON.stringify(_.util.encode(_.tokenize(code, _.languages[lang])))); + _self.close(); }, false); - return self.Prism; + return _self.Prism; } // Get current script and highlight @@ -422,7 +423,7 @@ if (script) { } } -return self.Prism; +return _self.Prism; })(); @@ -643,56 +644,58 @@ if (Prism.languages.markup) { 'psm1': 'powershell' }; - Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function(pre) { - var src = pre.getAttribute('data-src'); + if(Array.prototype.forEach) { // Check to prevent error in IE8 + Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) { + var src = pre.getAttribute('data-src'); - var language, parent = pre; - var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i; - while (parent && !lang.test(parent.className)) { - parent = parent.parentNode; - } + var language, parent = pre; + var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i; + while (parent && !lang.test(parent.className)) { + parent = parent.parentNode; + } - if (parent) { - language = (pre.className.match(lang) || [,''])[1]; - } + if (parent) { + language = (pre.className.match(lang) || [, ''])[1]; + } - if (!language) { - var extension = (src.match(/\.(\w+)$/) || [, ''])[1]; - language = Extensions[extension] || extension; - } + if (!language) { + var extension = (src.match(/\.(\w+)$/) || [, ''])[1]; + language = Extensions[extension] || extension; + } - var code = document.createElement('code'); - code.className = 'language-' + language; + var code = document.createElement('code'); + code.className = 'language-' + language; - pre.textContent = ''; + pre.textContent = ''; - code.textContent = 'Loading…'; + code.textContent = 'Loading…'; - pre.appendChild(code); + pre.appendChild(code); - var xhr = new XMLHttpRequest(); + var xhr = new XMLHttpRequest(); - xhr.open('GET', src, true); + xhr.open('GET', src, true); - xhr.onreadystatechange = function() { - if (xhr.readyState == 4) { + xhr.onreadystatechange = function () { + if (xhr.readyState == 4) { - if (xhr.status < 400 && xhr.responseText) { - code.textContent = xhr.responseText; + if (xhr.status < 400 && xhr.responseText) { + code.textContent = xhr.responseText; - Prism.highlightElement(code); - } - else if (xhr.status >= 400) { - code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText; - } - else { - code.textContent = '✖ Error: File does not exist or is empty'; + Prism.highlightElement(code); + } + else if (xhr.status >= 400) { + code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText; + } + else { + code.textContent = '✖ Error: File does not exist or is empty'; + } } - } - }; + }; - xhr.send(null); - }); + xhr.send(null); + }); + } }; From 7d1b8d7ec8eadc17310b4bb79c37d6a253699bce Mon Sep 17 00:00:00 2001 From: Golmote Date: Fri, 17 Jul 2015 08:11:47 +0200 Subject: [PATCH 120/310] Eiffel: Fix string patterns order + fix /= operator --- components/prism-eiffel.js | 8 ++++---- components/prism-eiffel.min.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/prism-eiffel.js b/components/prism-eiffel.js index a6da3f68b3..cfdb6a5289 100644 --- a/components/prism-eiffel.js +++ b/components/prism-eiffel.js @@ -1,11 +1,11 @@ Prism.languages.eiffel = { 'string': [ - // Single-line string - /"(?:%\s+%|%"|.)*?"/, // Aligned-verbatim-strings /"([^[]*)\[[\s\S]+?\]\1"/, // Non-aligned-verbatim-strings - /"([^{]*)\{[\s\S]+?\}\1"/ + /"([^{]*)\{[\s\S]+?\}\1"/, + // Single-line string + /"(?:%\s+%|%"|.)*?"/ ], // (comments including quoted strings not supported) 'comment': /--.*/, @@ -20,5 +20,5 @@ Prism.languages.eiffel = { /(?:\d(?:_*\d)*)?\.(?:(?:\d(?:_*\d)*)?[eE][+-]?)?\d(?:_*\d)*|\d(?:_*\d)*\.?/ ], 'punctuation': /:=|<<|>>|\(\||\|\)|->|\.(?=\w)|[{}[\];(),:?]/, - 'operator': /\\\\|\|\.\.\||\.\.|\/[~\/]?|[><\/]=?|[-+*^=~]/ + 'operator': /\\\\|\|\.\.\||\.\.|\/[~\/=]?|[><]=?|[-+*^=~]/ }; diff --git a/components/prism-eiffel.min.js b/components/prism-eiffel.min.js index d9c8ab3e5b..af6d398979 100644 --- a/components/prism-eiffel.min.js +++ b/components/prism-eiffel.min.js @@ -1 +1 @@ -Prism.languages.eiffel={string:[/"(?:%\s+%|%"|.)*?"/,/"([^[]*)\[[\s\S]+?\]\1"/,/"([^{]*)\{[\s\S]+?\}\1"/],comment:/--.*/,"char":/'(?:%'|.)+?'/,keyword:/\b(?:across|agent|alias|all|and|attached|as|assign|attribute|check|class|convert|create|Current|debug|deferred|detachable|do|else|elseif|end|ensure|expanded|export|external|feature|from|frozen|if|implies|inherit|inspect|invariant|like|local|loop|not|note|obsolete|old|once|or|Precursor|redefine|rename|require|rescue|Result|retry|select|separate|some|then|undefine|until|variant|Void|when|xor)\b/i,"boolean":/\b(?:True|False)\b/i,number:[/\b0[xcb][\da-f](?:_*[\da-f])*\b/i,/(?:\d(?:_*\d)*)?\.(?:(?:\d(?:_*\d)*)?[eE][+-]?)?\d(?:_*\d)*|\d(?:_*\d)*\.?/],punctuation:/:=|<<|>>|\(\||\|\)|->|\.(?=\w)|[{}[\];(),:?]/,operator:/\\\\|\|\.\.\||\.\.|\/[~\/]?|[><\/]=?|[-+*^=~]/}; \ No newline at end of file +Prism.languages.eiffel={string:[/"([^[]*)\[[\s\S]+?\]\1"/,/"([^{]*)\{[\s\S]+?\}\1"/,/"(?:%\s+%|%"|.)*?"/],comment:/--.*/,"char":/'(?:%'|.)+?'/,keyword:/\b(?:across|agent|alias|all|and|attached|as|assign|attribute|check|class|convert|create|Current|debug|deferred|detachable|do|else|elseif|end|ensure|expanded|export|external|feature|from|frozen|if|implies|inherit|inspect|invariant|like|local|loop|not|note|obsolete|old|once|or|Precursor|redefine|rename|require|rescue|Result|retry|select|separate|some|then|undefine|until|variant|Void|when|xor)\b/i,"boolean":/\b(?:True|False)\b/i,number:[/\b0[xcb][\da-f](?:_*[\da-f])*\b/i,/(?:\d(?:_*\d)*)?\.(?:(?:\d(?:_*\d)*)?[eE][+-]?)?\d(?:_*\d)*|\d(?:_*\d)*\.?/],punctuation:/:=|<<|>>|\(\||\|\)|->|\.(?=\w)|[{}[\];(),:?]/,operator:/\\\\|\|\.\.\||\.\.|\/[~\/=]?|[><]=?|[-+*^=~]/}; \ No newline at end of file From fa286aa57f04c2e88370b9b717e5ea6d35c70334 Mon Sep 17 00:00:00 2001 From: Golmote Date: Fri, 17 Jul 2015 08:39:15 +0200 Subject: [PATCH 121/310] Erlang: Fixed quoted functions and quoted atoms. Fixed variables pattern so that it does not break atoms. Fixed operator <=. --- components/prism-erlang.js | 18 ++++++++++++------ components/prism-erlang.min.js | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/components/prism-erlang.js b/components/prism-erlang.js index deea6aa054..5baa9d77a4 100644 --- a/components/prism-erlang.js +++ b/components/prism-erlang.js @@ -2,11 +2,11 @@ Prism.languages.erlang = { 'comment': /%.+/, 'string': /"(?:\\?.)*?"/, 'quoted-function': { - pattern: /'[^']+'(?=\()/, + pattern: /'(?:\\.|[^'\\])+'(?=\()/, alias: 'function' }, 'quoted-atom': { - pattern: /'[^']+'/, + pattern: /'(?:\\.|[^'\\])+'/, alias: 'atom' }, 'boolean': /\b(?:true|false)\b/, @@ -17,15 +17,21 @@ Prism.languages.erlang = { /(?:\b|-)\d*\.?\d+([Ee][+-]?\d+)?\b/ ], 'function': /\b[a-z][\w@]*(?=\()/, - 'variable': /(?:\b|\?)[A-Z_][\w@]*/, + 'variable': { + // Look-behind is used to prevent wrong highlighting of atoms containing "@" + pattern: /(^|[^@])(?:\b|\?)[A-Z_][\w@]*/, + lookbehind: true + }, 'operator': [ - /[=\/>:]=|>=|=[:\/]=|\+\+?|--?|[=*\/!]|\b(?:bnot|div|rem|band|bor|bxor|bsl|bsr|not|and|or|xor|orelse|andalso)\b/, + /[=\/<>:]=|=[:\/]=|\+\+?|--?|[=*\/!]|\b(?:bnot|div|rem|band|bor|bxor|bsl|bsr|not|and|or|xor|orelse|andalso)\b/, { - pattern: /(^|(?!<).)<(?!<)/, + // We don't want to match << + pattern: /(^|[^<])<(?!<)/, lookbehind: true }, { - pattern: /(^|(?!>).)>(?!>)/, + // We don't want to match >> + pattern: /(^|[^>])>(?!>)/, lookbehind: true } ], diff --git a/components/prism-erlang.min.js b/components/prism-erlang.min.js index 6a072b6296..613f0f955c 100644 --- a/components/prism-erlang.min.js +++ b/components/prism-erlang.min.js @@ -1 +1 @@ -Prism.languages.erlang={comment:/%.+/,string:/"(?:\\?.)*?"/,"quoted-function":{pattern:/'[^']+'(?=\()/,alias:"function"},"quoted-atom":{pattern:/'[^']+'/,alias:"atom"},"boolean":/\b(?:true|false)\b/,keyword:/\b(?:fun|when|case|of|end|if|receive|after|try|catch)\b/,number:[/\$\\?./,/\d+#[a-z0-9]+/i,/(?:\b|-)\d*\.?\d+([Ee][+-]?\d+)?\b/],"function":/\b[a-z][\w@]*(?=\()/,variable:/(?:\b|\?)[A-Z_][\w@]*/,operator:[/[=\/>:]=|>=|=[:\/]=|\+\+?|--?|[=*\/!]|\b(?:bnot|div|rem|band|bor|bxor|bsl|bsr|not|and|or|xor|orelse|andalso)\b/,{pattern:/(^|(?!<).)<(?!<)/,lookbehind:!0},{pattern:/(^|(?!>).)>(?!>)/,lookbehind:!0}],atom:/\b[a-z][\w@]*/,punctuation:/[()[\]{}:;,.#|]|<<|>>/}; \ No newline at end of file +Prism.languages.erlang={comment:/%.+/,string:/"(?:\\?.)*?"/,"quoted-function":{pattern:/'(?:\\.|[^'\\])+'(?=\()/,alias:"function"},"quoted-atom":{pattern:/'(?:\\.|[^'\\])+'/,alias:"atom"},"boolean":/\b(?:true|false)\b/,keyword:/\b(?:fun|when|case|of|end|if|receive|after|try|catch)\b/,number:[/\$\\?./,/\d+#[a-z0-9]+/i,/(?:\b|-)\d*\.?\d+([Ee][+-]?\d+)?\b/],"function":/\b[a-z][\w@]*(?=\()/,variable:{pattern:/(^|[^@])(?:\b|\?)[A-Z_][\w@]*/,lookbehind:!0},operator:[/[=\/<>:]=|=[:\/]=|\+\+?|--?|[=*\/!]|\b(?:bnot|div|rem|band|bor|bxor|bsl|bsr|not|and|or|xor|orelse|andalso)\b/,{pattern:/(^|[^<])<(?!<)/,lookbehind:!0},{pattern:/(^|[^>])>(?!>)/,lookbehind:!0}],atom:/\b[a-z][\w@]*/,punctuation:/[()[\]{}:;,.#|]|<<|>>/}; \ No newline at end of file From 40ae21533f9a5c5f69d1da60a6a114fa500b1a30 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sat, 18 Jul 2015 18:01:32 +0200 Subject: [PATCH 122/310] Fortran: more bullet-proof pattern for comments inside strings. --- components/prism-fortran.js | 7 +++++-- components/prism-fortran.min.js | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/components/prism-fortran.js b/components/prism-fortran.js index 6448dad2e2..0d5e83ca35 100644 --- a/components/prism-fortran.js +++ b/components/prism-fortran.js @@ -4,9 +4,12 @@ Prism.languages.fortran = { alias: 'number' }, 'string': { - pattern: /(?:\w+_)?(['"])(?:\1\1|&\n(?:\s*!.+\n)?|(?!\1).)*(?:\1|&)/, + pattern: /(?:\w+_)?(['"])(?:\1\1|&(?:\r\n?|\n)(?:\s*!.+(?:\r\n?|\n))?|(?!\1).)*(?:\1|&)/, inside: { - 'comment': /!.*/ + 'comment': { + pattern: /(&(?:\r\n?|\n)\s*)!.*/, + lookbehind: true + } } }, 'comment': /!.*/, diff --git a/components/prism-fortran.min.js b/components/prism-fortran.min.js index 407cc9603c..ac54b0f513 100644 --- a/components/prism-fortran.min.js +++ b/components/prism-fortran.min.js @@ -1 +1 @@ -Prism.languages.fortran={"quoted-number":{pattern:/[BOZ](['"])[A-F0-9]+\1/i,alias:"number"},string:{pattern:/(?:\w+_)?(['"])(?:\1\1|&\n(?:\s*!.+\n)?|(?!\1).)*(?:\1|&)/,inside:{comment:/!.*/}},comment:/!.*/,"boolean":/\.(?:TRUE|FALSE)\.(?:_\w+)?/i,number:/(?:\b|[+-])(?:\d+(?:\.\d*)?|\.\d+)(?:[ED][+-]?\d+)?(?:_\w+)?/i,keyword:[/\b(?:INTEGER|REAL|DOUBLE ?PRECISION|COMPLEX|CHARACTER|LOGICAL)\b/i,/\b(?:ALLOCATABLE|ALLOCATE|BACKSPACE|CALL|CASE|CLOSE|COMMON|CONTAINS|CONTINUE|CYCLE|DATA|DEALLOCATE|DIMENSION|DO|END|EQUIVALENCE|EXIT|EXTERNAL|FORMAT|GO ?TO|IMPLICIT(?: NONE)?|INQUIRE|INTENT|INTRINSIC|MODULE PROCEDURE|NAMELIST|NULLIFY|OPEN|OPTIONAL|PARAMETER|POINTER|PRINT|PRIVATE|PUBLIC|READ|RETURN|REWIND|SAVE|SELECT|STOP|TARGET|WHILE|WRITE)\b/i,/\b(?:END ?)?(?:BLOCK ?DATA|DO|FILE|FORALL|FUNCTION|IF|INTERFACE|MODULE|PROGRAM|SELECT|SUBROUTINE|TYPE|WHERE)\b/i,/\b(?:ASSIGNMENT|DEFAULT|ELEMENTAL|ELSE|ELSEWHERE|ELSEIF|ENTRY|IN|INCLUDE|INOUT|KIND|NULL|ONLY|OPERATOR|OUT|PURE|RECURSIVE|RESULT|SEQUENCE|STAT|THEN|USE)\b/i],operator:[/\*\*|\/\/|=>|[=\/]=|[<>]=?|::|[+\-*=%]|\.(?:EQ|NE|LT|LE|GT|GE|NOT|AND|OR|EQV|NEQV)\.|\.[A-Z]+\./i,{pattern:/(^|(?!\().)\/(?!\))/,lookbehind:!0}],punctuation:/\(\/|\/\)|[(),;:&]/}; \ No newline at end of file +Prism.languages.fortran={"quoted-number":{pattern:/[BOZ](['"])[A-F0-9]+\1/i,alias:"number"},string:{pattern:/(?:\w+_)?(['"])(?:\1\1|&(?:\r\n?|\n)(?:\s*!.+(?:\r\n?|\n))?|(?!\1).)*(?:\1|&)/,inside:{comment:{pattern:/(&(?:\r\n?|\n)\s*)!.*/,lookbehind:!0}}},comment:/!.*/,"boolean":/\.(?:TRUE|FALSE)\.(?:_\w+)?/i,number:/(?:\b|[+-])(?:\d+(?:\.\d*)?|\.\d+)(?:[ED][+-]?\d+)?(?:_\w+)?/i,keyword:[/\b(?:INTEGER|REAL|DOUBLE ?PRECISION|COMPLEX|CHARACTER|LOGICAL)\b/i,/\b(?:ALLOCATABLE|ALLOCATE|BACKSPACE|CALL|CASE|CLOSE|COMMON|CONTAINS|CONTINUE|CYCLE|DATA|DEALLOCATE|DIMENSION|DO|END|EQUIVALENCE|EXIT|EXTERNAL|FORMAT|GO ?TO|IMPLICIT(?: NONE)?|INQUIRE|INTENT|INTRINSIC|MODULE PROCEDURE|NAMELIST|NULLIFY|OPEN|OPTIONAL|PARAMETER|POINTER|PRINT|PRIVATE|PUBLIC|READ|RETURN|REWIND|SAVE|SELECT|STOP|TARGET|WHILE|WRITE)\b/i,/\b(?:END ?)?(?:BLOCK ?DATA|DO|FILE|FORALL|FUNCTION|IF|INTERFACE|MODULE|PROGRAM|SELECT|SUBROUTINE|TYPE|WHERE)\b/i,/\b(?:ASSIGNMENT|DEFAULT|ELEMENTAL|ELSE|ELSEWHERE|ELSEIF|ENTRY|IN|INCLUDE|INOUT|KIND|NULL|ONLY|OPERATOR|OUT|PURE|RECURSIVE|RESULT|SEQUENCE|STAT|THEN|USE)\b/i],operator:[/\*\*|\/\/|=>|[=\/]=|[<>]=?|::|[+\-*=%]|\.(?:EQ|NE|LT|LE|GT|GE|NOT|AND|OR|EQV|NEQV)\.|\.[A-Z]+\./i,{pattern:/(^|(?!\().)\/(?!\))/,lookbehind:!0}],punctuation:/\(\/|\/\)|[(),;:&]/}; \ No newline at end of file From 8a6d32d356d34d0fba4a1f0212d417df3527dce7 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sat, 18 Jul 2015 18:18:14 +0200 Subject: [PATCH 123/310] Fortran: fix keyword patterns order --- components/prism-fortran.js | 4 ++-- components/prism-fortran.min.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/prism-fortran.js b/components/prism-fortran.js index 0d5e83ca35..7b417ce26e 100644 --- a/components/prism-fortran.js +++ b/components/prism-fortran.js @@ -18,10 +18,10 @@ Prism.languages.fortran = { 'keyword': [ // Types /\b(?:INTEGER|REAL|DOUBLE ?PRECISION|COMPLEX|CHARACTER|LOGICAL)\b/i, + // END statements + /\b(?:END ?)?(?:BLOCK ?DATA|DO|FILE|FORALL|FUNCTION|IF|INTERFACE|MODULE(?! PROCEDURE)|PROGRAM|SELECT|SUBROUTINE|TYPE|WHERE)\b/i, // Statements /\b(?:ALLOCATABLE|ALLOCATE|BACKSPACE|CALL|CASE|CLOSE|COMMON|CONTAINS|CONTINUE|CYCLE|DATA|DEALLOCATE|DIMENSION|DO|END|EQUIVALENCE|EXIT|EXTERNAL|FORMAT|GO ?TO|IMPLICIT(?: NONE)?|INQUIRE|INTENT|INTRINSIC|MODULE PROCEDURE|NAMELIST|NULLIFY|OPEN|OPTIONAL|PARAMETER|POINTER|PRINT|PRIVATE|PUBLIC|READ|RETURN|REWIND|SAVE|SELECT|STOP|TARGET|WHILE|WRITE)\b/i, - // END statements - /\b(?:END ?)?(?:BLOCK ?DATA|DO|FILE|FORALL|FUNCTION|IF|INTERFACE|MODULE|PROGRAM|SELECT|SUBROUTINE|TYPE|WHERE)\b/i, // Others /\b(?:ASSIGNMENT|DEFAULT|ELEMENTAL|ELSE|ELSEWHERE|ELSEIF|ENTRY|IN|INCLUDE|INOUT|KIND|NULL|ONLY|OPERATOR|OUT|PURE|RECURSIVE|RESULT|SEQUENCE|STAT|THEN|USE)\b/i ], diff --git a/components/prism-fortran.min.js b/components/prism-fortran.min.js index ac54b0f513..6801223cce 100644 --- a/components/prism-fortran.min.js +++ b/components/prism-fortran.min.js @@ -1 +1 @@ -Prism.languages.fortran={"quoted-number":{pattern:/[BOZ](['"])[A-F0-9]+\1/i,alias:"number"},string:{pattern:/(?:\w+_)?(['"])(?:\1\1|&(?:\r\n?|\n)(?:\s*!.+(?:\r\n?|\n))?|(?!\1).)*(?:\1|&)/,inside:{comment:{pattern:/(&(?:\r\n?|\n)\s*)!.*/,lookbehind:!0}}},comment:/!.*/,"boolean":/\.(?:TRUE|FALSE)\.(?:_\w+)?/i,number:/(?:\b|[+-])(?:\d+(?:\.\d*)?|\.\d+)(?:[ED][+-]?\d+)?(?:_\w+)?/i,keyword:[/\b(?:INTEGER|REAL|DOUBLE ?PRECISION|COMPLEX|CHARACTER|LOGICAL)\b/i,/\b(?:ALLOCATABLE|ALLOCATE|BACKSPACE|CALL|CASE|CLOSE|COMMON|CONTAINS|CONTINUE|CYCLE|DATA|DEALLOCATE|DIMENSION|DO|END|EQUIVALENCE|EXIT|EXTERNAL|FORMAT|GO ?TO|IMPLICIT(?: NONE)?|INQUIRE|INTENT|INTRINSIC|MODULE PROCEDURE|NAMELIST|NULLIFY|OPEN|OPTIONAL|PARAMETER|POINTER|PRINT|PRIVATE|PUBLIC|READ|RETURN|REWIND|SAVE|SELECT|STOP|TARGET|WHILE|WRITE)\b/i,/\b(?:END ?)?(?:BLOCK ?DATA|DO|FILE|FORALL|FUNCTION|IF|INTERFACE|MODULE|PROGRAM|SELECT|SUBROUTINE|TYPE|WHERE)\b/i,/\b(?:ASSIGNMENT|DEFAULT|ELEMENTAL|ELSE|ELSEWHERE|ELSEIF|ENTRY|IN|INCLUDE|INOUT|KIND|NULL|ONLY|OPERATOR|OUT|PURE|RECURSIVE|RESULT|SEQUENCE|STAT|THEN|USE)\b/i],operator:[/\*\*|\/\/|=>|[=\/]=|[<>]=?|::|[+\-*=%]|\.(?:EQ|NE|LT|LE|GT|GE|NOT|AND|OR|EQV|NEQV)\.|\.[A-Z]+\./i,{pattern:/(^|(?!\().)\/(?!\))/,lookbehind:!0}],punctuation:/\(\/|\/\)|[(),;:&]/}; \ No newline at end of file +Prism.languages.fortran={"quoted-number":{pattern:/[BOZ](['"])[A-F0-9]+\1/i,alias:"number"},string:{pattern:/(?:\w+_)?(['"])(?:\1\1|&(?:\r\n?|\n)(?:\s*!.+(?:\r\n?|\n))?|(?!\1).)*(?:\1|&)/,inside:{comment:{pattern:/(&(?:\r\n?|\n)\s*)!.*/,lookbehind:!0}}},comment:/!.*/,"boolean":/\.(?:TRUE|FALSE)\.(?:_\w+)?/i,number:/(?:\b|[+-])(?:\d+(?:\.\d*)?|\.\d+)(?:[ED][+-]?\d+)?(?:_\w+)?/i,keyword:[/\b(?:INTEGER|REAL|DOUBLE ?PRECISION|COMPLEX|CHARACTER|LOGICAL)\b/i,/\b(?:END ?)?(?:BLOCK ?DATA|DO|FILE|FORALL|FUNCTION|IF|INTERFACE|MODULE(?! PROCEDURE)|PROGRAM|SELECT|SUBROUTINE|TYPE|WHERE)\b/i,/\b(?:ALLOCATABLE|ALLOCATE|BACKSPACE|CALL|CASE|CLOSE|COMMON|CONTAINS|CONTINUE|CYCLE|DATA|DEALLOCATE|DIMENSION|DO|END|EQUIVALENCE|EXIT|EXTERNAL|FORMAT|GO ?TO|IMPLICIT(?: NONE)?|INQUIRE|INTENT|INTRINSIC|MODULE PROCEDURE|NAMELIST|NULLIFY|OPEN|OPTIONAL|PARAMETER|POINTER|PRINT|PRIVATE|PUBLIC|READ|RETURN|REWIND|SAVE|SELECT|STOP|TARGET|WHILE|WRITE)\b/i,/\b(?:ASSIGNMENT|DEFAULT|ELEMENTAL|ELSE|ELSEWHERE|ELSEIF|ENTRY|IN|INCLUDE|INOUT|KIND|NULL|ONLY|OPERATOR|OUT|PURE|RECURSIVE|RESULT|SEQUENCE|STAT|THEN|USE)\b/i],operator:[/\*\*|\/\/|=>|[=\/]=|[<>]=?|::|[+\-*=%]|\.(?:EQ|NE|LT|LE|GT|GE|NOT|AND|OR|EQV|NEQV)\.|\.[A-Z]+\./i,{pattern:/(^|(?!\().)\/(?!\))/,lookbehind:!0}],punctuation:/\(\/|\/\)|[(),;:&]/}; \ No newline at end of file From 58f6fe1fc48c633ee879f6db4b62d79d98a0f80d Mon Sep 17 00:00:00 2001 From: Golmote Date: Sun, 26 Jul 2015 11:24:40 +0200 Subject: [PATCH 124/310] Revert 5b29a673c468920ac68c3af6e769f72c2b895434 for now. --- themes/prism-coy.css | 4 ++-- themes/prism-dark.css | 2 +- themes/prism-funky.css | 2 +- themes/prism-okaidia.css | 2 +- themes/prism-tomorrow.css | 2 +- themes/prism-twilight.css | 2 +- themes/prism.css | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/themes/prism-coy.css b/themes/prism-coy.css index 7a325d63a8..8db555e126 100644 --- a/themes/prism-coy.css +++ b/themes/prism-coy.css @@ -7,7 +7,7 @@ code[class*="language-"], pre[class*="language-"] { color: black; - font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; + font-family: Consolas, Monaco, 'Andale Mono', monospace; direction: ltr; text-align: left; white-space: pre; @@ -228,4 +228,4 @@ pre[data-line] code { } pre .line-highlight { margin-top: 0; -} +} \ No newline at end of file diff --git a/themes/prism-dark.css b/themes/prism-dark.css index 1c4daa2227..a8047fce6e 100644 --- a/themes/prism-dark.css +++ b/themes/prism-dark.css @@ -8,7 +8,7 @@ code[class*="language-"], pre[class*="language-"] { color: white; text-shadow: 0 -.1em .2em black; - font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; + font-family: Consolas, Monaco, 'Andale Mono', monospace; direction: ltr; text-align: left; white-space: pre; diff --git a/themes/prism-funky.css b/themes/prism-funky.css index 30135635ee..f2614d1573 100644 --- a/themes/prism-funky.css +++ b/themes/prism-funky.css @@ -6,7 +6,7 @@ code[class*="language-"], pre[class*="language-"] { - font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; + font-family: Consolas, Monaco, 'Andale Mono', monospace; direction: ltr; text-align: left; white-space: pre; diff --git a/themes/prism-okaidia.css b/themes/prism-okaidia.css index 0fac6828db..3ff2e3c772 100644 --- a/themes/prism-okaidia.css +++ b/themes/prism-okaidia.css @@ -8,7 +8,7 @@ code[class*="language-"], pre[class*="language-"] { color: #f8f8f2; text-shadow: 0 1px rgba(0, 0, 0, 0.3); - font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; + font-family: Consolas, Monaco, 'Andale Mono', monospace; direction: ltr; text-align: left; white-space: pre; diff --git a/themes/prism-tomorrow.css b/themes/prism-tomorrow.css index 44f0f7edd0..c998fb22cb 100644 --- a/themes/prism-tomorrow.css +++ b/themes/prism-tomorrow.css @@ -7,7 +7,7 @@ code[class*="language-"], pre[class*="language-"] { color: #ccc; - font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; + font-family: Consolas, Monaco, 'Andale Mono', monospace; direction: ltr; text-align: left; white-space: pre; diff --git a/themes/prism-twilight.css b/themes/prism-twilight.css index ab0813410e..89dbe848b4 100644 --- a/themes/prism-twilight.css +++ b/themes/prism-twilight.css @@ -7,7 +7,7 @@ code[class*="language-"], pre[class*="language-"] { color: white; direction: ltr; - font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; + font-family: Consolas, Monaco, 'Andale Mono', monospace; text-align: left; text-shadow: 0 -.1em .2em black; white-space: pre; diff --git a/themes/prism.css b/themes/prism.css index 3a57f8e817..a04c82c89c 100644 --- a/themes/prism.css +++ b/themes/prism.css @@ -8,7 +8,7 @@ code[class*="language-"], pre[class*="language-"] { color: black; text-shadow: 0 1px white; - font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; + font-family: Consolas, Monaco, 'Andale Mono', monospace; direction: ltr; text-align: left; white-space: pre; From ed9d7e354c20a95755af7641e3a2a0c77a713791 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sun, 26 Jul 2015 11:26:07 +0200 Subject: [PATCH 125/310] Add Ubuntu Mono font to font stack --- themes/prism-coy.css | 4 ++-- themes/prism-dark.css | 2 +- themes/prism-funky.css | 2 +- themes/prism-okaidia.css | 2 +- themes/prism-tomorrow.css | 2 +- themes/prism-twilight.css | 2 +- themes/prism.css | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/themes/prism-coy.css b/themes/prism-coy.css index 8db555e126..7a325d63a8 100644 --- a/themes/prism-coy.css +++ b/themes/prism-coy.css @@ -7,7 +7,7 @@ code[class*="language-"], pre[class*="language-"] { color: black; - font-family: Consolas, Monaco, 'Andale Mono', monospace; + font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; direction: ltr; text-align: left; white-space: pre; @@ -228,4 +228,4 @@ pre[data-line] code { } pre .line-highlight { margin-top: 0; -} \ No newline at end of file +} diff --git a/themes/prism-dark.css b/themes/prism-dark.css index a8047fce6e..1c4daa2227 100644 --- a/themes/prism-dark.css +++ b/themes/prism-dark.css @@ -8,7 +8,7 @@ code[class*="language-"], pre[class*="language-"] { color: white; text-shadow: 0 -.1em .2em black; - font-family: Consolas, Monaco, 'Andale Mono', monospace; + font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; direction: ltr; text-align: left; white-space: pre; diff --git a/themes/prism-funky.css b/themes/prism-funky.css index f2614d1573..30135635ee 100644 --- a/themes/prism-funky.css +++ b/themes/prism-funky.css @@ -6,7 +6,7 @@ code[class*="language-"], pre[class*="language-"] { - font-family: Consolas, Monaco, 'Andale Mono', monospace; + font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; direction: ltr; text-align: left; white-space: pre; diff --git a/themes/prism-okaidia.css b/themes/prism-okaidia.css index 3ff2e3c772..0fac6828db 100644 --- a/themes/prism-okaidia.css +++ b/themes/prism-okaidia.css @@ -8,7 +8,7 @@ code[class*="language-"], pre[class*="language-"] { color: #f8f8f2; text-shadow: 0 1px rgba(0, 0, 0, 0.3); - font-family: Consolas, Monaco, 'Andale Mono', monospace; + font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; direction: ltr; text-align: left; white-space: pre; diff --git a/themes/prism-tomorrow.css b/themes/prism-tomorrow.css index c998fb22cb..44f0f7edd0 100644 --- a/themes/prism-tomorrow.css +++ b/themes/prism-tomorrow.css @@ -7,7 +7,7 @@ code[class*="language-"], pre[class*="language-"] { color: #ccc; - font-family: Consolas, Monaco, 'Andale Mono', monospace; + font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; direction: ltr; text-align: left; white-space: pre; diff --git a/themes/prism-twilight.css b/themes/prism-twilight.css index 89dbe848b4..ab0813410e 100644 --- a/themes/prism-twilight.css +++ b/themes/prism-twilight.css @@ -7,7 +7,7 @@ code[class*="language-"], pre[class*="language-"] { color: white; direction: ltr; - font-family: Consolas, Monaco, 'Andale Mono', monospace; + font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; text-align: left; text-shadow: 0 -.1em .2em black; white-space: pre; diff --git a/themes/prism.css b/themes/prism.css index a04c82c89c..3a57f8e817 100644 --- a/themes/prism.css +++ b/themes/prism.css @@ -8,7 +8,7 @@ code[class*="language-"], pre[class*="language-"] { color: black; text-shadow: 0 1px white; - font-family: Consolas, Monaco, 'Andale Mono', monospace; + font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; direction: ltr; text-align: left; white-space: pre; From 1e0b8d9da944949e52bd7f2c5d38406e2d534f34 Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Sun, 26 Jul 2015 14:08:47 +0200 Subject: [PATCH 126/310] Fixed code style issues --- tests/helper/prism-loader.js | 6 +-- tests/helper/test-case.js | 4 +- tests/helper/token-stream-transformer.js | 12 ++---- tests/run.js | 5 +-- tests/testrunner-tests.js | 47 +++++++++++++----------- 5 files changed, 34 insertions(+), 40 deletions(-) diff --git a/tests/helper/prism-loader.js b/tests/helper/prism-loader.js index ea82c0bc47..9bc515b425 100644 --- a/tests/helper/prism-loader.js +++ b/tests/helper/prism-loader.js @@ -39,8 +39,7 @@ module.exports = { * @returns {{loadedLanguages: string[], Prism: Prism}} */ loadLanguage: function (language, context) { - if (!languagesCatalog[language]) - { + if (!languagesCatalog[language]) { throw new Error("Language '" + language + "' not found."); } @@ -50,8 +49,7 @@ module.exports = { } // if the language has a dependency -> load it first - if (languagesCatalog[language].require) - { + if (languagesCatalog[language].require) { context = this.loadLanguage(languagesCatalog[language].require, context); } diff --git a/tests/helper/test-case.js b/tests/helper/test-case.js index b62d230da9..ec9ae06d25 100644 --- a/tests/helper/test-case.js +++ b/tests/helper/test-case.js @@ -69,7 +69,6 @@ module.exports = { }, - /** * Parses the test case from the given test case file * @@ -96,8 +95,7 @@ module.exports = { return testCase; } - catch (e) - { + catch (e) { // the JSON can't be parsed (e.g. it could be empty) return null; } diff --git a/tests/helper/token-stream-transformer.js b/tests/helper/token-stream-transformer.js index 38aa77ca24..deb831c45b 100644 --- a/tests/helper/token-stream-transformer.js +++ b/tests/helper/token-stream-transformer.js @@ -14,22 +14,18 @@ module.exports = { * @returns {Array.} */ simplify: function (tokenStream) { - if (Array.isArray(tokenStream)) - { + if (Array.isArray(tokenStream)) { return tokenStream .map(this.simplify.bind(this)) - .filter(function(value) - { + .filter(function (value) { return !(Array.isArray(value) && !value.length) && !(typeof value === "string" && !value.trim().length); } ); } - else if (typeof tokenStream === "object") - { + else if (typeof tokenStream === "object") { return [tokenStream.type, this.simplify(tokenStream.content)]; } - else - { + else { return tokenStream; } } diff --git a/tests/run.js b/tests/run.js index 0f0475fa6e..5e0050487f 100644 --- a/tests/run.js +++ b/tests/run.js @@ -8,14 +8,13 @@ var path = require("path"); var testSuite = TestDiscovery.loadAllTests(__dirname + "/languages"); // define tests for all tests in all languages in the test suite -for (var language in testSuite) -{ +for (var language in testSuite) { if (!testSuite.hasOwnProperty(language)) { continue; } (function (language, testFiles) { - describe("Testing language '" + language + "'", function() { + describe("Testing language '" + language + "'", function () { testFiles.forEach( function (filePath) { var fileName = path.basename(filePath, path.extname(filePath)); diff --git a/tests/testrunner-tests.js b/tests/testrunner-tests.js index b9f79dc88e..23731078e4 100644 --- a/tests/testrunner-tests.js +++ b/tests/testrunner-tests.js @@ -4,11 +4,9 @@ var assert = require("chai").assert; var TokenStreamTransformer = require("./helper/token-stream-transformer"); describe("The token stream transformer", - function () - { + function () { it("should handle all kinds of simple transformations", - function () - { + function () { var tokens = [ {type: "type", content: "content"}, "string" @@ -25,14 +23,19 @@ describe("The token stream transformer", it("should handle nested structures", - function () - { + function () { var tokens = [ - {type: "type", content: [ - {type: "insideType", content: [ - {type: "insideInsideType", content: "content"} - ]} - ]} + { + type: "type", + content: [ + { + type: "insideType", content: + [ + {type: "insideInsideType", content: "content"} + ] + } + ] + } ]; var expected = [ @@ -49,8 +52,7 @@ describe("The token stream transformer", it("should strip empty tokens", - function () - { + function () { var tokenStream = [ "", "\r\n", @@ -66,14 +68,16 @@ describe("The token stream transformer", it("should strip empty token tree branches", - function () - { + function () { var tokenStream = [ - {type: "type", content: [ - ["", ""], - "", - {type: "nested", content: [""]} - ]}, + { + type: "type", + content: [ + ["", ""], + "", + {type: "nested", content: [""]} + ] + }, [[[[[[[""]]]]]]] ]; @@ -89,8 +93,7 @@ describe("The token stream transformer", it("should ignore all properties in tokens except value and content", - function () - { + function () { var tokenStream = [ {type: "type", content: "content", alias: "alias"} From 799570f9cbff3b68ef8a8873977d9a78d6a584ed Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Sun, 26 Jul 2015 14:25:30 +0200 Subject: [PATCH 127/310] Fixed javascript test case --- tests/languages/javascript/testcase1.test | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/languages/javascript/testcase1.test b/tests/languages/javascript/testcase1.test index e6cd4a59aa..78a197175a 100644 --- a/tests/languages/javascript/testcase1.test +++ b/tests/languages/javascript/testcase1.test @@ -4,6 +4,7 @@ var a = 5; [ ["keyword", "var"], + " a ", ["operator", "="], ["number", "5"], ["punctuation", ";"] @@ -11,4 +12,4 @@ var a = 5; ---------------------------------------------------- -This is a comment explaining this test case. \ No newline at end of file +This is a comment explaining this test case. From a13c87b9e3712233472814d536ffd45bec381c77 Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Sun, 26 Jul 2015 14:27:38 +0200 Subject: [PATCH 128/310] Added support for specifying the main language to load in test cases You can add an exclamation mark anywhere in the name to load it as main language. If you do not specify anything, the first entry is used as main language css+markup! --> markup is main language css+markup --> css is main language --- tests/helper/test-case.js | 48 +++++++++++++++++++++++++++++++--- tests/testrunner-tests.js | 55 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 3 deletions(-) diff --git a/tests/helper/test-case.js b/tests/helper/test-case.js index ec9ae06d25..34835a3326 100644 --- a/tests/helper/test-case.js +++ b/tests/helper/test-case.js @@ -53,15 +53,15 @@ module.exports = { */ runTestCase: function (languageIdentifier, filePath) { var testCase = this.parseTestCaseFile(filePath); - var languages = languageIdentifier.split("+"); + var usedLanguages = this.parseLanguageNames(languageIdentifier); if (null === testCase) { throw new Error("Test case file has invalid format (or the provided token stream is invalid JSON), please read the docs."); } - var Prism = PrismLoader.createInstance(languages); + var Prism = PrismLoader.createInstance(usedLanguages.languages); // the first language is the main language to highlight - var mainLanguageGrammar = Prism.languages[languages[0]]; + var mainLanguageGrammar = Prism.languages[usedLanguages.mainLanguage]; var compiledTokenStream = Prism.tokenize(testCase.testSource, mainLanguageGrammar); var simplifiedTokenStream = TokenStreamTransformer.simplify(compiledTokenStream); @@ -69,6 +69,48 @@ module.exports = { }, + /** + * Parses the language names and finds the main language. + * + * It is either the first language or the language followed by a exclamation mark “!”. + * There should only be one language with an exclamation mark. + * + * @param {string} languageIdentifier + * + * @returns {{languages: string[], mainLanguage: string}} + */ + parseLanguageNames: function (languageIdentifier) { + var languages = languageIdentifier.split("+"); + var mainLanguage = null; + + languages = languages.map( + function (language) { + var pos = language.indexOf("!"); + + if (-1 < pos) { + if (mainLanguage) { + throw "There are multiple main languages defined."; + } + + mainLanguage = language.replace("!", ""); + return mainLanguage; + } + + return language; + } + ); + + if (!mainLanguage) { + mainLanguage = languages[0]; + } + + return { + languages: languages, + mainLanguage: mainLanguage + }; + }, + + /** * Parses the test case from the given test case file * diff --git a/tests/testrunner-tests.js b/tests/testrunner-tests.js index 23731078e4..c4e0fd51f0 100644 --- a/tests/testrunner-tests.js +++ b/tests/testrunner-tests.js @@ -2,7 +2,10 @@ var assert = require("chai").assert; var TokenStreamTransformer = require("./helper/token-stream-transformer"); +var TestCase = require("./helper/test-case"); + +//region Token Stream Transformer describe("The token stream transformer", function () { it("should handle all kinds of simple transformations", @@ -108,4 +111,56 @@ describe("The token stream transformer", ); } ); +//endregion + + +//region Language name parsing +describe("The language name parsing", + function () { + it("should use the first language as the main language if no language is specified", + function () { + assert.deepEqual( + TestCase.parseLanguageNames("a"), + { + languages: ["a"], + mainLanguage: "a" + } + ); + + assert.deepEqual( + TestCase.parseLanguageNames("a+b+c"), + { + languages: ["a", "b", "c"], + mainLanguage: "a" + } + ); + } + ); + + it("should use the specified language as main language", + function () { + assert.deepEqual( + TestCase.parseLanguageNames("a+b!+c"), + { + languages: ["a", "b", "c"], + mainLanguage: "b" + } + ); + } + ); + + + it("should throw an error if there are multiple main languages", + function () { + assert.throw( + function () { + TestCase.parseLanguageNames("a+b!+c!"); + }, + "There are multiple main languages defined." + ); + } + ); + } +); +//endregion From 9e6703ada54ec98b6c90c1127c6c4104066e5ba0 Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Sun, 26 Jul 2015 14:32:00 +0200 Subject: [PATCH 129/310] Added travis.yml to run tests in travis --- .travis.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..68fbf6d87c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: node_js + +node_js: + - "0.10" + - "0.12" + +before_script: + - npm install -g gulp + - gulp + +script: npm test From 2bc551851c753b14a5cc5cd9293d4474c6656b3f Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Sun, 26 Jul 2015 14:34:41 +0200 Subject: [PATCH 130/310] Improve support of node 10.x --- tests/helper/components.js | 3 +-- tests/helper/prism-loader.js | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/helper/components.js b/tests/helper/components.js index 09dd6aa957..68cb7abe3a 100644 --- a/tests/helper/components.js +++ b/tests/helper/components.js @@ -5,7 +5,6 @@ var vm = require("vm"); var fileContent = fs.readFileSync(__dirname + "/../../components.js", "utf8"); var context = {}; -vm.createContext(context); -vm.runInContext(fileContent, context); +vm.runInNewContext(fileContent, context); module.exports = context.components; diff --git a/tests/helper/prism-loader.js b/tests/helper/prism-loader.js index 9bc515b425..31f3689d63 100644 --- a/tests/helper/prism-loader.js +++ b/tests/helper/prism-loader.js @@ -107,8 +107,7 @@ module.exports = { */ runFileWithContext: function (fileSource, context) { context = context || {}; - vm.createContext(context); - vm.runInContext(fileSource, context); + vm.runInNewContext(fileSource, context); return context; } }; From e8884a96ed6aa5fb53710078afe3aea68176ec44 Mon Sep 17 00:00:00 2001 From: Jannik Zschiesche Date: Sun, 26 Jul 2015 15:28:39 +0200 Subject: [PATCH 131/310] Added documentation about the test runner and test suite --- test-suite.html | 147 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 test-suite.html diff --git a/test-suite.html b/test-suite.html new file mode 100644 index 0000000000..accd149d92 --- /dev/null +++ b/test-suite.html @@ -0,0 +1,147 @@ + + + + + + +Running the test suite ▲ Prism + + + + + + + + + +
+
+ +

Running the test suite

+

Prism has a test suite, that ensures that the correct tokens are matched.

+
+ +
+

Running the test suite

+ +

Running the test suite is simple: just call npm test.

+

All test files are run in isolation. A new prism instance is created for each test case. This will slow the test runner a bit down, but we can be sure that nothing leaks into the next test case.

+
+ +
+

Writing tests

+ +

Thank you for writing tests! Tests are awesome! They ensure, that we can improve the codebase without breaking anything. Also, this way, we can ensure that upgrading Prism is as painless as possible for you.

+

You can add new tests by creating a new test case file (with the .test file extension) in the tests directory which is located at /tests/languages/${language}.

+ +
+

Language directories

+

All tests are sorted into directories in the tests/languages directory. Each directory name encodes, which language you are currently testing.

+

All language names must match the names from the definition in components.js.

+ +

Example 1: testing a language in isolation (default use case)

+

Just put your test file into the directory of the language you want to test.

+

So, if you want to test CSS, put your test file in /tests/languages/css to test CSS only. If you create a test case in this directory, the test runner will ensure that the css language definition including all required language definitions are correctly loaded.

+ +

Example 2: testing language injection

+

If you want to test language injection, you typically need to load two or more languages where one language is the “main” language that is being tested, with all other languages being injected into it.

+

You need to define multiple languages by separating them using a + sign: markup+php.

+

The languages are loaded in order, so first markup (+ dependencies) is loaded, then php (+ dependencies). The test loader ensures that no language is loaded more than once (for example if two languages have the same dependencies).

+

By default the first language is the main language: markup+php will have markup as main language. This is equal to putting your code in the following code block:

+
...
+<pre><code class="language-markup">
+	<!-- your code here -->
+</code><pre>
+...
+ +

If you need to load the languages in a given order, but you don't want to use the first language as main language, you can mark the main language with an exclamation mark: markup+php!. This will use php as main language. (You can only define one main language. The test runner will fail all tests in directories with more than one main language.)

+ +

Note: by loading multiple languages you can do integration tests (ensure that loading two or more languages together won't break anything).

+
+ +
+

Creating your test case file

+

At first you need to create a new file in the language directory, you want to test.

+

Use a proper name for your test case. Please use one case of the following conventions:

+
    +
  • issue{issueid}: reference a github issue id (example: issue588.test).
  • +
  • {featurename}_feature: group all tests to one feature in one file (example: string_interpolation_feature.test).
  • +
  • {language}_inclusion: test inclusion of one language into the other (example: markup/php_inclusion.test will test php inclusion into markup).
  • +
+

You can use all conventions as a prefix, so string_interpolation_feature_inline.test is possible. But please take a minute or two to think of a proper name of your test case file. You are writing code not only for the computers, but also for your fellow developers.

+
+ +
+

Writing your test

+

The structure of a test case file is as follows:

+

+... language snippet...
+----
+... the simplified token stream you expect ...
+ +

Your file is built up of two or three sections, separated by three or more dashes -, starting at the begin of the line:

+
    +
  1. Your language snippet. The code you want to compile using Prism. (required)
  2. +
  3. The simplified token stream you expect. Needs to be valid JSON. (required)
  4. +
  5. A comment explaining the test case. (optional)
  6. +
+

The easiest way would be to look at an existing test file:

+
var a = 5;
+
+----------------------------------------------------
+
+[
+	["keyword", "var"],
+	" a ",
+	["operator", "="],
+	["number", "5"],
+	["punctuation", ";"]
+]
+
+----------------------------------------------------
+
+This is a comment explaining this test case.
+
+ +
+

Explaining the simplified token stream

+

While compiling, Prism transforms your source code into a token stream. This is basically a tree of nested tokens (or arrays, or strings).

+

As these trees are hard to write by hand, the test runner uses a simplified version of it.

+

It uses the following rules:

+
    +
  • Token objects are transformed into an array: [token.type, token.content] (whereas token.content can be a nested structure).
  • +
  • All strings that are either empty or only contain whitespace, are removed from the token stream.
  • +
  • All empty structures are removed.
  • +
+

For further information: reading the tests of the test runner (tests/testrunner-tests.js) will help you understand the transformation.

+
+
+ + +
+

Test runner tests

+

The test runner itself is tested in a separate test case. You can find all “test core” related tests in tests/testrunner-tests.js.

+

You shouldn't need to touch this file ever, except you modify the test runner code.

+
+ +
+

Internal structure

+

The global test flow is at follows:

+
    +
  1. Run all internal tests (test the test runner).
  2. +
  3. Find all language tests.
  4. +
  5. Run all language tests individually.
  6. +
  7. Report the results.
  8. +
+
+ + +
+ + + + + + + + From 54cfe4fb1f437346936bc2a165df031162d4a3cb Mon Sep 17 00:00:00 2001 From: david peach Date: Mon, 27 Jul 2015 18:34:31 +0100 Subject: [PATCH 132/310] Change the link to my article to correct URL. My .htaccess in the old site has stopped working and so have manually edited the link here. --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index aa713a9654..407ede62fd 100644 --- a/index.html +++ b/index.html @@ -188,7 +188,7 @@

Third-party tutorials

  • Implement PrismJs Syntax Highlighting to your Blogger/BlogSpot
  • Beautify Source Codes In Your Posts With Prism Syntax Highlighter For Blogger
  • Extending and customizing Prism syntax highlighter
  • -
  • Prism JS Code Highlighter
  • +
  • Prism JS Code Highlighter
  • How To Re-Run Prism.js On AJAX Content
  • Highlight your code syntax with Prism.js
  • Jekyll Plugin: Syntax Highlighting With Prism
  • From 6fc4cf68a8f9c43ce22ec306d8d1aa26bdb3ec2c Mon Sep 17 00:00:00 2001 From: Loic Giraudel Date: Sun, 2 Aug 2015 23:55:37 +0200 Subject: [PATCH 133/310] More examples for git --- examples/prism-git.html | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/examples/prism-git.html b/examples/prism-git.html index c705c9d2ac..7d37d4b816 100644 --- a/examples/prism-git.html +++ b/examples/prism-git.html @@ -11,3 +11,32 @@

    Comments

    Inserted and deleted lines

    - Some deleted line
     + Some added line
    + +

    Diff

    +
    $ git diff
    +diff --git file.txt file.txt
    +index 6214953..1d54a52 100644
    +--- file.txt
    ++++ file.txt
    +@@ -1 +1,2 @@
    +-Here's my tetx file
    ++Here's my text file
    ++And this is the second line
    + +

    Logs

    +
    $ git log
    +commit a11a14ef7e26f2ca62d4b35eac455ce636d0dc09
    +Author: lgiraudel
    +Date:   Mon Feb 17 11:18:34 2014 +0100
    +
    +    Add of a new line
    +
    +commit 87edc4ad8c71b95f6e46f736eb98b742859abd95
    +Author: lgiraudel
    +Date:   Mon Feb 17 11:18:15 2014 +0100
    +
    +    Typo fix
    +
    +commit 3102416a90c431400d2e2a14e707fb7fd6d9e06d
    +Author: lgiraudel
    +Date:   Mon Feb 17 10:58:11 2014 +0100
    \ No newline at end of file From 3ded4f2c5356f6505e1ca0956b2954e465eb1e2c Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Thu, 6 Aug 2015 18:37:13 -0400 Subject: [PATCH 134/310] python: Add async/await and @ operator (introduced in 3.5) --- components/prism-python.js | 8 ++++---- components/prism-python.min.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/prism-python.js b/components/prism-python.js index b2e031f0a2..7ebc42a747 100644 --- a/components/prism-python.js +++ b/components/prism-python.js @@ -1,4 +1,4 @@ -Prism.languages.python= { +Prism.languages.python= { 'comment': { pattern: /(^|[^\\])#.*?(\r?\n|$)/, lookbehind: true @@ -8,9 +8,9 @@ Prism.languages.python= { pattern: /((^|\s)def[ \t]+)([a-zA-Z_][a-zA-Z0-9_]*(?=\())/g, lookbehind: true }, - 'keyword' : /\b(as|assert|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/, + 'keyword' : /\b(as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/, 'boolean' : /\b(True|False)\b/, 'number' : /\b-?(0[bo])?(?:(\d|0x[a-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i, - 'operator' : /[-+]|<=?|>=?|!|={1,2}|&{1,2}|\|?\||\?|\*|\/|~|\^|%|\b(or|and|not)\b/, + 'operator' : /[-+]|<=?|>=?|!|={1,2}|&{1,2}|\|?\||\?|\*|\/|@|~|\^|%|\b(or|and|not)\b/, 'punctuation' : /[{}[\];(),.:]/ -}; \ No newline at end of file +}; diff --git a/components/prism-python.min.js b/components/prism-python.min.js index 888e8a3fab..087ad0dd41 100644 --- a/components/prism-python.min.js +++ b/components/prism-python.min.js @@ -1 +1 @@ -Prism.languages.python={comment:{pattern:/(^|[^\\])#.*?(\r?\n|$)/,lookbehind:!0},string:/"""[\s\S]+?"""|'''[\s\S]+?'''|("|')(\\?.)*?\1/,"function":{pattern:/((^|\s)def[ \t]+)([a-zA-Z_][a-zA-Z0-9_]*(?=\())/g,lookbehind:!0},keyword:/\b(as|assert|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/,"boolean":/\b(True|False)\b/,number:/\b-?(0[bo])?(?:(\d|0x[a-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,operator:/[-+]|<=?|>=?|!|={1,2}|&{1,2}|\|?\||\?|\*|\/|~|\^|%|\b(or|and|not)\b/,punctuation:/[{}[\];(),.:]/}; \ No newline at end of file +Prism.languages.python={comment:{pattern:/(^|[^\\])#.*?(\r?\n|$)/,lookbehind:!0},string:/"""[\s\S]+?"""|'''[\s\S]+?'''|("|')(\\?.)*?\1/,"function":{pattern:/((^|\s)def[ \t]+)([a-zA-Z_][a-zA-Z0-9_]*(?=\())/g,lookbehind:!0},keyword:/\b(as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/,"boolean":/\b(True|False)\b/,number:/\b-?(0[bo])?(?:(\d|0x[a-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,operator:/[-+]|<=?|>=?|!|={1,2}|&{1,2}|\|?\||\?|\*|\/|@|~|\^|%|\b(or|and|not)\b/,punctuation:/[{}[\];(),.:]/}; \ No newline at end of file From 1c630b1d4e30bf6f33585870e1bb9dfbcf591524 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20San=20Juli=C3=A1n?= Date: Sun, 9 Aug 2015 00:05:14 +0200 Subject: [PATCH 135/310] complete hook added --- prism.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/prism.js b/prism.js index 8282b57193..e6a2273c4b 100644 --- a/prism.js +++ b/prism.js @@ -177,10 +177,6 @@ var _ = _self.Prism = { parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language; } - if (!grammar) { - return; - } - var code = element.textContent; if(!code) { @@ -196,6 +192,11 @@ var _ = _self.Prism = { code: code }; + if (!grammar) { + _.hooks.run('complete', env); + return; + } + _.hooks.run('before-highlight', env); if (async && _self.Worker) { @@ -228,6 +229,9 @@ var _ = _self.Prism = { _.hooks.run('after-highlight', env); } + + _.hooks.run('complete', env); + }, highlight: function (text, grammar, language) { From 3f4d9182a00bc48aa8d87377fc626ded418d0c69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20San=20Juli=C3=A1n?= Date: Sun, 9 Aug 2015 00:07:08 +0200 Subject: [PATCH 136/310] run line numbers plugin in complete hook --- plugins/line-numbers/prism-line-numbers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/line-numbers/prism-line-numbers.js b/plugins/line-numbers/prism-line-numbers.js index 9443deb7dc..73884cce64 100644 --- a/plugins/line-numbers/prism-line-numbers.js +++ b/plugins/line-numbers/prism-line-numbers.js @@ -1,4 +1,4 @@ -Prism.hooks.add('after-highlight', function (env) { +Prism.hooks.add('complete', function (env) { // works only for wrapped inside
     (not inline)
     	var pre = env.element.parentNode;
     	var clsReg = /\s*\bline-numbers\b\s*/;
    
    From f237e67b8301a4252b2dca1c90f73dfcd38d2e44 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Fernando=20San=20Juli=C3=A1n?= 
    Date: Sun, 9 Aug 2015 03:21:30 +0200
    Subject: [PATCH 137/310] run line highlight plugin in complete hook
    
    ---
     plugins/line-highlight/prism-line-highlight.js | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/plugins/line-highlight/prism-line-highlight.js b/plugins/line-highlight/prism-line-highlight.js
    index 577d142e98..8d5faa156c 100644
    --- a/plugins/line-highlight/prism-line-highlight.js
    +++ b/plugins/line-highlight/prism-line-highlight.js
    @@ -85,7 +85,7 @@ function applyHash() {
     
     var fakeTimer = 0; // Hack to limit the number of times applyHash() runs
     
    -Prism.hooks.add('after-highlight', function(env) {
    +Prism.hooks.add('complete', function(env) {
     	var pre = env.element.parentNode;
     	var lines = pre && pre.getAttribute('data-line');
     	
    
    From c89bbdb156c867b161e55c04964f10dae9a193c6 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Fernando=20San=20Juli=C3=A1n?= 
    Date: Sun, 9 Aug 2015 03:56:20 +0200
    Subject: [PATCH 138/310] no line numbers if already exists
    
    ---
     plugins/line-numbers/prism-line-numbers.js | 5 +++++
     1 file changed, 5 insertions(+)
    
    diff --git a/plugins/line-numbers/prism-line-numbers.js b/plugins/line-numbers/prism-line-numbers.js
    index 73884cce64..5b01dceeae 100644
    --- a/plugins/line-numbers/prism-line-numbers.js
    +++ b/plugins/line-numbers/prism-line-numbers.js
    @@ -10,6 +10,11 @@ Prism.hooks.add('complete', function (env) {
     		return;
     	}
     
    +	if ( env.element.querySelector(".line-numbers-rows") ) {
    +		// Abort if line numbers already exists
    +		return;
    +	}
    +
     	if (clsReg.test(env.element.className)) {
     		// Remove the class "line-numbers" from the 
     		env.element.className = env.element.className.replace(clsReg, '');
    
    From fd549959cd57d1c5de8be2f6d7600fe9bd050857 Mon Sep 17 00:00:00 2001
    From: Golmote 
    Date: Thu, 13 Aug 2015 08:33:48 +0200
    Subject: [PATCH 139/310] Fix complete hook behaviour + run gulp task
    
    ---
     components/prism-core.js                      | 21 ++++++++++---------
     components/prism-core.min.js                  |  2 +-
     .../prism-line-highlight.min.js               |  2 +-
     plugins/line-numbers/index.html               |  6 ++++++
     .../line-numbers/prism-line-numbers.min.js    |  2 +-
     prism.js                                      | 17 +++++++--------
     6 files changed, 27 insertions(+), 23 deletions(-)
    
    diff --git a/components/prism-core.js b/components/prism-core.js
    index 542464e084..6b5799350b 100644
    --- a/components/prism-core.js
    +++ b/components/prism-core.js
    @@ -172,18 +172,8 @@ var _ = _self.Prism = {
     			parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
     		}
     
    -		if (!grammar) {
    -			return;
    -		}
    -
     		var code = element.textContent;
     
    -		if(!code) {
    -			return;
    -		}
    -
    -		code = code.replace(/^(?:\r?\n|\r)/,'');
    -
     		var env = {
     			element: element,
     			language: language,
    @@ -191,6 +181,15 @@ var _ = _self.Prism = {
     			code: code
     		};
     
    +		if(code) {
    +			env.code = code.replace(/^(?:\r?\n|\r)/, '');
    +		}
    +
    +		if (!code || !grammar) {
    +			_.hooks.run('complete', env);
    +			return;
    +		}
    +
     		_.hooks.run('before-highlight', env);
     
     		if (async && _self.Worker) {
    @@ -205,6 +204,7 @@ var _ = _self.Prism = {
     
     				callback && callback.call(env.element);
     				_.hooks.run('after-highlight', env);
    +				_.hooks.run('complete', env);
     			};
     
     			worker.postMessage(JSON.stringify({
    @@ -222,6 +222,7 @@ var _ = _self.Prism = {
     			callback && callback.call(element);
     
     			_.hooks.run('after-highlight', env);
    +			_.hooks.run('complete', env);
     		}
     	},
     
    diff --git a/components/prism-core.min.js b/components/prism-core.min.js
    index 5f781e29fe..bf3d9c3096 100644
    --- a/components/prism-core.min.js
    +++ b/components/prism-core.min.js
    @@ -1 +1 @@
    -var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=_self.Prism={util:{encode:function(e){return e instanceof n?new n(e.type,t.util.encode(e.content),e.alias):"Array"===t.util.type(e)?e.map(t.util.encode):e.replace(/&/g,"&").replace(/e.length)break e;if(!(d instanceof a)){u.lastIndex=0;var m=u.exec(d);if(m){c&&(f=m[1].length);var y=m.index-1+f,m=m[0].slice(f),v=m.length,k=y+v,b=d.slice(0,y+1),w=d.slice(k+1),N=[p,1];b&&N.push(b);var O=new a(l,g?t.tokenize(m,g):m,h);N.push(O),w&&N.push(w),Array.prototype.splice.apply(r,N)}}}}}return r},hooks:{all:{},add:function(e,n){var a=t.hooks.all;a[e]=a[e]||[],a[e].push(n)},run:function(e,n){var a=t.hooks.all[e];if(a&&a.length)for(var r,i=0;r=a[i++];)r(n)}}},n=t.Token=function(e,t,n){this.type=e,this.content=t,this.alias=n};if(n.stringify=function(e,a,r){if("string"==typeof e)return e;if("Array"===t.util.type(e))return e.map(function(t){return n.stringify(t,a,e)}).join("");var i={type:e.type,content:n.stringify(e.content,a,r),tag:"span",classes:["token",e.type],attributes:{},language:a,parent:r};if("comment"==i.type&&(i.attributes.spellcheck="true"),e.alias){var l="Array"===t.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(i.classes,l)}t.hooks.run("wrap",i);var s="";for(var o in i.attributes)s+=o+'="'+(i.attributes[o]||"")+'"';return"<"+i.tag+' class="'+i.classes.join(" ")+'" '+s+">"+i.content+""},!_self.document)return _self.addEventListener?(_self.addEventListener("message",function(e){var n=JSON.parse(e.data),a=n.language,r=n.code;_self.postMessage(JSON.stringify(t.util.encode(t.tokenize(r,t.languages[a])))),_self.close()},!1),_self.Prism):_self.Prism;var a=document.getElementsByTagName("script");return a=a[a.length-1],a&&(t.filename=a.src,document.addEventListener&&!a.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)),_self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism);
    \ No newline at end of file
    +var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=_self.Prism={util:{encode:function(e){return e instanceof n?new n(e.type,t.util.encode(e.content),e.alias):"Array"===t.util.type(e)?e.map(t.util.encode):e.replace(/&/g,"&").replace(/e.length)break e;if(!(d instanceof a)){u.lastIndex=0;var m=u.exec(d);if(m){g&&(f=m[1].length);var y=m.index-1+f,m=m[0].slice(f),v=m.length,k=y+v,b=d.slice(0,y+1),w=d.slice(k+1),N=[p,1];b&&N.push(b);var O=new a(l,c?t.tokenize(m,c):m,h);N.push(O),w&&N.push(w),Array.prototype.splice.apply(r,N)}}}}}return r},hooks:{all:{},add:function(e,n){var a=t.hooks.all;a[e]=a[e]||[],a[e].push(n)},run:function(e,n){var a=t.hooks.all[e];if(a&&a.length)for(var r,i=0;r=a[i++];)r(n)}}},n=t.Token=function(e,t,n){this.type=e,this.content=t,this.alias=n};if(n.stringify=function(e,a,r){if("string"==typeof e)return e;if("Array"===t.util.type(e))return e.map(function(t){return n.stringify(t,a,e)}).join("");var i={type:e.type,content:n.stringify(e.content,a,r),tag:"span",classes:["token",e.type],attributes:{},language:a,parent:r};if("comment"==i.type&&(i.attributes.spellcheck="true"),e.alias){var l="Array"===t.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(i.classes,l)}t.hooks.run("wrap",i);var o="";for(var s in i.attributes)o+=s+'="'+(i.attributes[s]||"")+'"';return"<"+i.tag+' class="'+i.classes.join(" ")+'" '+o+">"+i.content+""},!_self.document)return _self.addEventListener?(_self.addEventListener("message",function(e){var n=JSON.parse(e.data),a=n.language,r=n.code;_self.postMessage(JSON.stringify(t.util.encode(t.tokenize(r,t.languages[a])))),_self.close()},!1),_self.Prism):_self.Prism;var a=document.getElementsByTagName("script");return a=a[a.length-1],a&&(t.filename=a.src,document.addEventListener&&!a.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)),_self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism);
    \ No newline at end of file
    diff --git a/plugins/line-highlight/prism-line-highlight.min.js b/plugins/line-highlight/prism-line-highlight.min.js
    index 83a0108a55..662768f350 100644
    --- a/plugins/line-highlight/prism-line-highlight.min.js
    +++ b/plugins/line-highlight/prism-line-highlight.min.js
    @@ -1 +1 @@
    -!function(){function e(e,t){return Array.prototype.slice.call((t||document).querySelectorAll(e))}function t(e,t){return t=" "+t+" ",(" "+e.className+" ").replace(/[\n\t]/g," ").indexOf(t)>-1}function n(e,n,i){for(var r,a=n.replace(/\s+/g,"").split(","),l=+e.getAttribute("data-line-offset")||0,o=parseFloat(getComputedStyle(e).lineHeight),d=0;r=a[d++];){r=r.split("-");var c=+r[0],h=+r[1]||c,s=document.createElement("div");s.textContent=Array(h-c+2).join(" \n"),s.className=(i||"")+" line-highlight",t(e,"line-numbers")||(s.setAttribute("data-start",c),h>c&&s.setAttribute("data-end",h)),s.style.top=(c-l-1)*o+"px",t(e,"line-numbers")?e.appendChild(s):(e.querySelector("code")||e).appendChild(s)}}function i(){var t=location.hash.slice(1);e(".temporary.line-highlight").forEach(function(e){e.parentNode.removeChild(e)});var i=(t.match(/\.([\d,-]+)$/)||[,""])[1];if(i&&!document.getElementById(t)){var r=t.slice(0,t.lastIndexOf(".")),a=document.getElementById(r);a&&(a.hasAttribute("data-line")||a.setAttribute("data-line",""),n(a,i,"temporary "),document.querySelector(".temporary.line-highlight").scrollIntoView())}}if(window.Prism){var r=(crlf=/\r?\n|\r/g,0);Prism.hooks.add("after-highlight",function(t){var a=t.element.parentNode,l=a&&a.getAttribute("data-line");a&&l&&/pre/i.test(a.nodeName)&&(clearTimeout(r),e(".line-highlight",a).forEach(function(e){e.parentNode.removeChild(e)}),n(a,l),r=setTimeout(i,1))}),addEventListener("hashchange",i)}}();
    \ No newline at end of file
    +!function(){function e(e,t){return Array.prototype.slice.call((t||document).querySelectorAll(e))}function t(e,t){return t=" "+t+" ",(" "+e.className+" ").replace(/[\n\t]/g," ").indexOf(t)>-1}function n(e,n,r){for(var i,a=n.replace(/\s+/g,"").split(","),l=+e.getAttribute("data-line-offset")||0,o=parseFloat(getComputedStyle(e).lineHeight),c=0;i=a[c++];){i=i.split("-");var d=+i[0],s=+i[1]||d,u=document.createElement("div");u.textContent=Array(s-d+2).join(" \n"),u.className=(r||"")+" line-highlight",t(e,"line-numbers")||(u.setAttribute("data-start",d),s>d&&u.setAttribute("data-end",s)),u.style.top=(d-l-1)*o+"px",t(e,"line-numbers")?e.appendChild(u):(e.querySelector("code")||e).appendChild(u)}}function r(){var t=location.hash.slice(1);e(".temporary.line-highlight").forEach(function(e){e.parentNode.removeChild(e)});var r=(t.match(/\.([\d,-]+)$/)||[,""])[1];if(r&&!document.getElementById(t)){var i=t.slice(0,t.lastIndexOf(".")),a=document.getElementById(i);a&&(a.hasAttribute("data-line")||a.setAttribute("data-line",""),n(a,r,"temporary "),document.querySelector(".temporary.line-highlight").scrollIntoView())}}if(window.Prism){var i=(crlf=/\r?\n|\r/g,0);Prism.hooks.add("complete",function(t){var a=t.element.parentNode,l=a&&a.getAttribute("data-line");a&&l&&/pre/i.test(a.nodeName)&&(clearTimeout(i),e(".line-highlight",a).forEach(function(e){e.parentNode.removeChild(e)}),n(a,l),i=setTimeout(r,1))}),addEventListener("hashchange",r)}}();
    \ No newline at end of file
    diff --git a/plugins/line-numbers/index.html b/plugins/line-numbers/index.html
    index f22653a1d4..2d01694901 100644
    --- a/plugins/line-numbers/index.html
    +++ b/plugins/line-numbers/index.html
    @@ -43,6 +43,12 @@ 

    CSS

    HTML

    Please note the data-start="-5" in the code below.

    
    +
    +  

    Unknown languages

    +
    This raw text
    +is not highlighted
    +but it still has
    +lines numbers
    diff --git a/plugins/line-numbers/prism-line-numbers.min.js b/plugins/line-numbers/prism-line-numbers.min.js index 26f0a22514..7c1c19ee42 100644 --- a/plugins/line-numbers/prism-line-numbers.min.js +++ b/plugins/line-numbers/prism-line-numbers.min.js @@ -1 +1 @@ -Prism.hooks.add("after-highlight",function(e){var t=e.element.parentNode,s=/\s*\bline-numbers\b\s*/;if(t&&/pre/i.test(t.nodeName)&&(s.test(t.className)||s.test(e.element.className))){s.test(e.element.className)&&(e.element.className=e.element.className.replace(s,"")),s.test(t.className)||(t.className+=" line-numbers");var a,n=1+e.code.split("\n").length,l=new Array(n);l=l.join(""),a=document.createElement("span"),a.className="line-numbers-rows",a.innerHTML=l,t.hasAttribute("data-start")&&(t.style.counterReset="linenumber "+(parseInt(t.getAttribute("data-start"),10)-1)),e.element.appendChild(a)}}); \ No newline at end of file +Prism.hooks.add("complete",function(e){var t=e.element.parentNode,s=/\s*\bline-numbers\b\s*/;if(t&&/pre/i.test(t.nodeName)&&(s.test(t.className)||s.test(e.element.className))&&!e.element.querySelector(".line-numbers-rows")){s.test(e.element.className)&&(e.element.className=e.element.className.replace(s,"")),s.test(t.className)||(t.className+=" line-numbers");var a,n=1+e.code.split("\n").length,l=new Array(n);l=l.join(""),a=document.createElement("span"),a.className="line-numbers-rows",a.innerHTML=l,t.hasAttribute("data-start")&&(t.style.counterReset="linenumber "+(parseInt(t.getAttribute("data-start"),10)-1)),e.element.appendChild(a)}}); \ No newline at end of file diff --git a/prism.js b/prism.js index e6a2273c4b..61bbaf307e 100644 --- a/prism.js +++ b/prism.js @@ -179,12 +179,6 @@ var _ = _self.Prism = { var code = element.textContent; - if(!code) { - return; - } - - code = code.replace(/^(?:\r?\n|\r)/,''); - var env = { element: element, language: language, @@ -192,7 +186,11 @@ var _ = _self.Prism = { code: code }; - if (!grammar) { + if(code) { + env.code = code.replace(/^(?:\r?\n|\r)/, ''); + } + + if (!code || !grammar) { _.hooks.run('complete', env); return; } @@ -211,6 +209,7 @@ var _ = _self.Prism = { callback && callback.call(env.element); _.hooks.run('after-highlight', env); + _.hooks.run('complete', env); }; worker.postMessage(JSON.stringify({ @@ -228,10 +227,8 @@ var _ = _self.Prism = { callback && callback.call(element); _.hooks.run('after-highlight', env); + _.hooks.run('complete', env); } - - _.hooks.run('complete', env); - }, highlight: function (text, grammar, language) { From 48d20e748ed96ddc94e570afb98da386b34d72c1 Mon Sep 17 00:00:00 2001 From: Golmote Date: Thu, 13 Aug 2015 08:56:38 +0200 Subject: [PATCH 140/310] Add tests for Markup component --- tests/languages/markup/cdata_feature.test | 15 +++ tests/languages/markup/comment_feature.test | 16 ++++ tests/languages/markup/doctype_feature.test | 16 ++++ tests/languages/markup/entity_feature.test | 14 +++ tests/languages/markup/issue585.test | 63 +++++++++++++ tests/languages/markup/prolog_feature.test | 16 ++++ .../markup/tag_attribute_feature.test | 92 +++++++++++++++++++ tests/languages/markup/tag_feature.test | 81 ++++++++++++++++ 8 files changed, 313 insertions(+) create mode 100644 tests/languages/markup/cdata_feature.test create mode 100644 tests/languages/markup/comment_feature.test create mode 100644 tests/languages/markup/doctype_feature.test create mode 100644 tests/languages/markup/entity_feature.test create mode 100644 tests/languages/markup/issue585.test create mode 100644 tests/languages/markup/prolog_feature.test create mode 100644 tests/languages/markup/tag_attribute_feature.test create mode 100644 tests/languages/markup/tag_feature.test diff --git a/tests/languages/markup/cdata_feature.test b/tests/languages/markup/cdata_feature.test new file mode 100644 index 0000000000..c2854c9c62 --- /dev/null +++ b/tests/languages/markup/cdata_feature.test @@ -0,0 +1,15 @@ + + + +---------------------------------------------------- + +[ + ["cdata", ""], + ["cdata", ""] +] + +---------------------------------------------------- + +Checks for CDATA sections, single-line and multi-line. \ No newline at end of file diff --git a/tests/languages/markup/comment_feature.test b/tests/languages/markup/comment_feature.test new file mode 100644 index 0000000000..8acbb0deb7 --- /dev/null +++ b/tests/languages/markup/comment_feature.test @@ -0,0 +1,16 @@ + + + + +---------------------------------------------------- + +[ + ["comment", ""], + ["comment", ""], + ["comment", ""] +] + +---------------------------------------------------- + +Checks for empty comment, single-line comment and multi-line comment. \ No newline at end of file diff --git a/tests/languages/markup/doctype_feature.test b/tests/languages/markup/doctype_feature.test new file mode 100644 index 0000000000..a7212073ee --- /dev/null +++ b/tests/languages/markup/doctype_feature.test @@ -0,0 +1,16 @@ + + + + +---------------------------------------------------- + +[ + ["doctype", ""], + ["doctype", ""], + ["doctype", ""] +] + +---------------------------------------------------- + +Checks for different doctypes, single-line and multi-line. \ No newline at end of file diff --git a/tests/languages/markup/entity_feature.test b/tests/languages/markup/entity_feature.test new file mode 100644 index 0000000000..2212c6b10f --- /dev/null +++ b/tests/languages/markup/entity_feature.test @@ -0,0 +1,14 @@ +& ϑ ⛵   + +---------------------------------------------------- + +[ + ["entity", "&"], + ["entity", "ϑ"], + ["entity", "⛵"], + ["entity", " "] +] + +---------------------------------------------------- + +Checks for HTML/XML character entity references. \ No newline at end of file diff --git a/tests/languages/markup/issue585.test b/tests/languages/markup/issue585.test new file mode 100644 index 0000000000..090506ab06 --- /dev/null +++ b/tests/languages/markup/issue585.test @@ -0,0 +1,63 @@ +foo + +baz + +---------------------------------------------------- + +[ + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "Läufer" + ]], + ["punctuation", ">"] + ]], + "foo", + ["tag", [ + ["tag", [ + ["punctuation", ""] + ]], + + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "tag" + ]], + ["attr-name", [ + "läufer" + ]], + ["attr-value", [ + ["punctuation", "="], + ["punctuation", "\""], + "läufer", + ["punctuation", "\""] + ]], + ["punctuation", ">"] + ]], + + ["tag", [ + ["tag", [ + ["punctuation", "<"], + ["namespace", "läufer:"], + "tag" + ]], + ["punctuation", ">"] + ]], + "baz", + ["tag", [ + ["tag", [ + ["punctuation", ""] + ]] +] + +---------------------------------------------------- + +Checks for tags, attributes and namespaces containing unicode characters. +See #585 for details. \ No newline at end of file diff --git a/tests/languages/markup/prolog_feature.test b/tests/languages/markup/prolog_feature.test new file mode 100644 index 0000000000..bb3f5a52a1 --- /dev/null +++ b/tests/languages/markup/prolog_feature.test @@ -0,0 +1,16 @@ + + + + +---------------------------------------------------- + +[ + ["prolog", ""], + ["prolog", ""], + ["prolog", ""] +] + +---------------------------------------------------- + +Checks for different XML prologs, single-line and multi-line. \ No newline at end of file diff --git a/tests/languages/markup/tag_attribute_feature.test b/tests/languages/markup/tag_attribute_feature.test new file mode 100644 index 0000000000..57eba1abf6 --- /dev/null +++ b/tests/languages/markup/tag_attribute_feature.test @@ -0,0 +1,92 @@ +
    +
    +
    +
    + +---------------------------------------------------- + +[ + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "div" + ]], + ["attr-name", [ + "class" + ]], + ["attr-value", [ + ["punctuation", "="], + ["punctuation", "\""], + "test", + ["punctuation", "\""] + ]], + ["attr-name", [ + "foo" + ]], + ["attr-name", [ + "bar" + ]], + ["attr-value", [ + ["punctuation", "="], + "baz" + ]], + ["punctuation", ">"] + ]], + + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "div" + ]], + ["attr-name", [ + "foo" + ]], + ["attr-value", [ + ["punctuation", "="], + ["punctuation", "'"], + "bar", + ["punctuation", "'"] + ]], + ["punctuation", ">"] + ]], + + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "div" + ]], + ["attr-name", [ + "class" + ]], + ["attr-value", [ + ["punctuation", "="], + ["punctuation", "\""], + "foo\r\nbar\r\nbaz", + ["punctuation", "\""] + ]], + ["punctuation", ">"] + ]], + + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "div" + ]], + ["attr-name", [ + ["namespace", "foo:"], + "bar" + ]], + ["attr-value", [ + ["punctuation", "="], + "42" + ]], + ["punctuation", ">"] + ]] +] + +---------------------------------------------------- + +Checks for single-quoted, double-quoted and unquoted attributes, attributes without value and +namespaced attributes. \ No newline at end of file diff --git a/tests/languages/markup/tag_feature.test b/tests/languages/markup/tag_feature.test new file mode 100644 index 0000000000..110de1df87 --- /dev/null +++ b/tests/languages/markup/tag_feature.test @@ -0,0 +1,81 @@ +

    +
    dummy
    +
    + +
    "] + ]], + ["tag", [ + ["tag", [ + ["punctuation", ""] + ]], + + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "div" + ]], + ["punctuation", ">"] + ]], + "dummy", + ["tag", [ + ["tag", [ + ["punctuation", ""] + ]], + + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "div" + ]], + ["punctuation", ">"] + ]], + ["tag", [ + ["tag", [ + ["punctuation", ""] + ]], + + ["tag", [ + ["tag", [ + ["punctuation", "<"], + ["namespace", "foo:"], + "bar" + ]], + ["punctuation", ">"] + ]], + ["tag", [ + ["tag", [ + ["punctuation", ""] + ]], + "\r\n Date: Sat, 15 Aug 2015 05:03:55 -0400 Subject: [PATCH 141/310] changed parseFloat to parseInt to prevent some inconsistency issue with different font sizes --- plugins/line-highlight/prism-line-highlight.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/line-highlight/prism-line-highlight.js b/plugins/line-highlight/prism-line-highlight.js index 8d5faa156c..b89028a1b8 100644 --- a/plugins/line-highlight/prism-line-highlight.js +++ b/plugins/line-highlight/prism-line-highlight.js @@ -19,7 +19,7 @@ function highlightLines(pre, lines, classes) { var ranges = lines.replace(/\s+/g, '').split(','), offset = +pre.getAttribute('data-line-offset') || 0; - var lineHeight = parseFloat(getComputedStyle(pre).lineHeight); + var lineHeight = parseInt(getComputedStyle(pre).lineHeight); for (var i=0, range; range = ranges[i++];) { range = range.split('-'); From 28e329cf3b4f21eb971363091a7e0e15a191c3a1 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sat, 15 Aug 2015 13:15:08 +0200 Subject: [PATCH 142/310] Run gulp task --- plugins/line-highlight/prism-line-highlight.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/line-highlight/prism-line-highlight.min.js b/plugins/line-highlight/prism-line-highlight.min.js index 662768f350..380776b0a0 100644 --- a/plugins/line-highlight/prism-line-highlight.min.js +++ b/plugins/line-highlight/prism-line-highlight.min.js @@ -1 +1 @@ -!function(){function e(e,t){return Array.prototype.slice.call((t||document).querySelectorAll(e))}function t(e,t){return t=" "+t+" ",(" "+e.className+" ").replace(/[\n\t]/g," ").indexOf(t)>-1}function n(e,n,r){for(var i,a=n.replace(/\s+/g,"").split(","),l=+e.getAttribute("data-line-offset")||0,o=parseFloat(getComputedStyle(e).lineHeight),c=0;i=a[c++];){i=i.split("-");var d=+i[0],s=+i[1]||d,u=document.createElement("div");u.textContent=Array(s-d+2).join(" \n"),u.className=(r||"")+" line-highlight",t(e,"line-numbers")||(u.setAttribute("data-start",d),s>d&&u.setAttribute("data-end",s)),u.style.top=(d-l-1)*o+"px",t(e,"line-numbers")?e.appendChild(u):(e.querySelector("code")||e).appendChild(u)}}function r(){var t=location.hash.slice(1);e(".temporary.line-highlight").forEach(function(e){e.parentNode.removeChild(e)});var r=(t.match(/\.([\d,-]+)$/)||[,""])[1];if(r&&!document.getElementById(t)){var i=t.slice(0,t.lastIndexOf(".")),a=document.getElementById(i);a&&(a.hasAttribute("data-line")||a.setAttribute("data-line",""),n(a,r,"temporary "),document.querySelector(".temporary.line-highlight").scrollIntoView())}}if(window.Prism){var i=(crlf=/\r?\n|\r/g,0);Prism.hooks.add("complete",function(t){var a=t.element.parentNode,l=a&&a.getAttribute("data-line");a&&l&&/pre/i.test(a.nodeName)&&(clearTimeout(i),e(".line-highlight",a).forEach(function(e){e.parentNode.removeChild(e)}),n(a,l),i=setTimeout(r,1))}),addEventListener("hashchange",r)}}(); \ No newline at end of file +!function(){function e(e,t){return Array.prototype.slice.call((t||document).querySelectorAll(e))}function t(e,t){return t=" "+t+" ",(" "+e.className+" ").replace(/[\n\t]/g," ").indexOf(t)>-1}function n(e,n,r){for(var i,a=n.replace(/\s+/g,"").split(","),l=+e.getAttribute("data-line-offset")||0,o=parseInt(getComputedStyle(e).lineHeight),c=0;i=a[c++];){i=i.split("-");var d=+i[0],s=+i[1]||d,u=document.createElement("div");u.textContent=Array(s-d+2).join(" \n"),u.className=(r||"")+" line-highlight",t(e,"line-numbers")||(u.setAttribute("data-start",d),s>d&&u.setAttribute("data-end",s)),u.style.top=(d-l-1)*o+"px",t(e,"line-numbers")?e.appendChild(u):(e.querySelector("code")||e).appendChild(u)}}function r(){var t=location.hash.slice(1);e(".temporary.line-highlight").forEach(function(e){e.parentNode.removeChild(e)});var r=(t.match(/\.([\d,-]+)$/)||[,""])[1];if(r&&!document.getElementById(t)){var i=t.slice(0,t.lastIndexOf(".")),a=document.getElementById(i);a&&(a.hasAttribute("data-line")||a.setAttribute("data-line",""),n(a,r,"temporary "),document.querySelector(".temporary.line-highlight").scrollIntoView())}}if(window.Prism){var i=(crlf=/\r?\n|\r/g,0);Prism.hooks.add("complete",function(t){var a=t.element.parentNode,l=a&&a.getAttribute("data-line");a&&l&&/pre/i.test(a.nodeName)&&(clearTimeout(i),e(".line-highlight",a).forEach(function(e){e.parentNode.removeChild(e)}),n(a,l),i=setTimeout(r,1))}),addEventListener("hashchange",r)}}(); \ No newline at end of file From ee463e8e7b5522dfa09154b77c9cc1918afeee23 Mon Sep 17 00:00:00 2001 From: Golmote Date: Sat, 15 Aug 2015 17:25:47 +0200 Subject: [PATCH 143/310] Line-numbers: Abort if element is empty. Fixex #669 --- plugins/line-numbers/prism-line-numbers.js | 4 ++++ plugins/line-numbers/prism-line-numbers.min.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/line-numbers/prism-line-numbers.js b/plugins/line-numbers/prism-line-numbers.js index 5b01dceeae..b526da5222 100644 --- a/plugins/line-numbers/prism-line-numbers.js +++ b/plugins/line-numbers/prism-line-numbers.js @@ -1,4 +1,8 @@ Prism.hooks.add('complete', function (env) { + if (!env.code) { + return; + } + // works only for wrapped inside
     (not inline)
     	var pre = env.element.parentNode;
     	var clsReg = /\s*\bline-numbers\b\s*/;
    diff --git a/plugins/line-numbers/prism-line-numbers.min.js b/plugins/line-numbers/prism-line-numbers.min.js
    index 7c1c19ee42..12841b15da 100644
    --- a/plugins/line-numbers/prism-line-numbers.min.js
    +++ b/plugins/line-numbers/prism-line-numbers.min.js
    @@ -1 +1 @@
    -Prism.hooks.add("complete",function(e){var t=e.element.parentNode,s=/\s*\bline-numbers\b\s*/;if(t&&/pre/i.test(t.nodeName)&&(s.test(t.className)||s.test(e.element.className))&&!e.element.querySelector(".line-numbers-rows")){s.test(e.element.className)&&(e.element.className=e.element.className.replace(s,"")),s.test(t.className)||(t.className+=" line-numbers");var a,n=1+e.code.split("\n").length,l=new Array(n);l=l.join(""),a=document.createElement("span"),a.className="line-numbers-rows",a.innerHTML=l,t.hasAttribute("data-start")&&(t.style.counterReset="linenumber "+(parseInt(t.getAttribute("data-start"),10)-1)),e.element.appendChild(a)}});
    \ No newline at end of file
    +Prism.hooks.add("complete",function(e){if(e.code){var t=e.element.parentNode,s=/\s*\bline-numbers\b\s*/;if(t&&/pre/i.test(t.nodeName)&&(s.test(t.className)||s.test(e.element.className))&&!e.element.querySelector(".line-numbers-rows")){s.test(e.element.className)&&(e.element.className=e.element.className.replace(s,"")),s.test(t.className)||(t.className+=" line-numbers");var a,n=1+e.code.split("\n").length,l=new Array(n);l=l.join(""),a=document.createElement("span"),a.className="line-numbers-rows",a.innerHTML=l,t.hasAttribute("data-start")&&(t.style.counterReset="linenumber "+(parseInt(t.getAttribute("data-start"),10)-1)),e.element.appendChild(a)}}});
    \ No newline at end of file
    
    From 14f3f80df4d58dd6e556f022f43029fac4ffb1ec Mon Sep 17 00:00:00 2001
    From: Golmote 
    Date: Mon, 17 Aug 2015 08:28:57 +0200
    Subject: [PATCH 144/310] Correct calculation for number of lines (manual
     merge, fix #385)
    
    ---
     plugins/line-numbers/prism-line-numbers.js     | 4 ++--
     plugins/line-numbers/prism-line-numbers.min.js | 2 +-
     2 files changed, 3 insertions(+), 3 deletions(-)
    
    diff --git a/plugins/line-numbers/prism-line-numbers.js b/plugins/line-numbers/prism-line-numbers.js
    index b526da5222..9cf273fce4 100644
    --- a/plugins/line-numbers/prism-line-numbers.js
    +++ b/plugins/line-numbers/prism-line-numbers.js
    @@ -28,10 +28,10 @@ Prism.hooks.add('complete', function (env) {
     		pre.className += ' line-numbers';
     	}
     
    -	var linesNum = (1 + env.code.split('\n').length);
    +	var linesNum = env.code.match(/\n(?!$)/g).length + 1;
     	var lineNumbersWrapper;
     
    -	var lines = new Array(linesNum);
    +	var lines = new Array(linesNum + 1);
     	lines = lines.join('');
     
     	lineNumbersWrapper = document.createElement('span');
    diff --git a/plugins/line-numbers/prism-line-numbers.min.js b/plugins/line-numbers/prism-line-numbers.min.js
    index 12841b15da..65f6e55b9d 100644
    --- a/plugins/line-numbers/prism-line-numbers.min.js
    +++ b/plugins/line-numbers/prism-line-numbers.min.js
    @@ -1 +1 @@
    -Prism.hooks.add("complete",function(e){if(e.code){var t=e.element.parentNode,s=/\s*\bline-numbers\b\s*/;if(t&&/pre/i.test(t.nodeName)&&(s.test(t.className)||s.test(e.element.className))&&!e.element.querySelector(".line-numbers-rows")){s.test(e.element.className)&&(e.element.className=e.element.className.replace(s,"")),s.test(t.className)||(t.className+=" line-numbers");var a,n=1+e.code.split("\n").length,l=new Array(n);l=l.join(""),a=document.createElement("span"),a.className="line-numbers-rows",a.innerHTML=l,t.hasAttribute("data-start")&&(t.style.counterReset="linenumber "+(parseInt(t.getAttribute("data-start"),10)-1)),e.element.appendChild(a)}}});
    \ No newline at end of file
    +Prism.hooks.add("complete",function(e){if(e.code){var t=e.element.parentNode,s=/\s*\bline-numbers\b\s*/;if(t&&/pre/i.test(t.nodeName)&&(s.test(t.className)||s.test(e.element.className))&&!e.element.querySelector(".line-numbers-rows")){s.test(e.element.className)&&(e.element.className=e.element.className.replace(s,"")),s.test(t.className)||(t.className+=" line-numbers");var a,n=e.code.match(/\n(?!$)/g).length+1,l=new Array(n+1);l=l.join(""),a=document.createElement("span"),a.className="line-numbers-rows",a.innerHTML=l,t.hasAttribute("data-start")&&(t.style.counterReset="linenumber "+(parseInt(t.getAttribute("data-start"),10)-1)),e.element.appendChild(a)}}});
    \ No newline at end of file
    
    From ed9f2b2179000862f7bc8c01b68676f568daa7c8 Mon Sep 17 00:00:00 2001
    From: Golmote 
    Date: Mon, 17 Aug 2015 08:47:32 +0200
    Subject: [PATCH 145/310] Move removal of initial line feed to a plugin
    
    ---
     components.js                                 |  5 ++
     components/prism-core.js                      |  4 --
     components/prism-core.min.js                  |  2 +-
     plugins/remove-initial-line-feed/index.html   | 57 +++++++++++++++++++
     .../prism-remove-initial-line-feed.js         | 13 +++++
     .../prism-remove-initial-line-feed.min.js     |  1 +
     prism.js                                      |  4 --
     7 files changed, 77 insertions(+), 9 deletions(-)
     create mode 100644 plugins/remove-initial-line-feed/index.html
     create mode 100644 plugins/remove-initial-line-feed/prism-remove-initial-line-feed.js
     create mode 100644 plugins/remove-initial-line-feed/prism-remove-initial-line-feed.min.js
    
    diff --git a/components.js b/components.js
    index 919b3c13ae..1129ef8eab 100644
    --- a/components.js
    +++ b/components.js
    @@ -377,6 +377,11 @@ var components = {
     			"title": "Highlight Keywords",
     			"owner": "vkbansal",
     			"noCSS": true
    +		},
    +		"remove-initial-line-feed": {
    +			"title": "Remove initial line feed",
    +			"owner": "Golmote",
    +			"noCSS": true
     		}
     	}
     };
    diff --git a/components/prism-core.js b/components/prism-core.js
    index 6b5799350b..fcccccde29 100644
    --- a/components/prism-core.js
    +++ b/components/prism-core.js
    @@ -181,10 +181,6 @@ var _ = _self.Prism = {
     			code: code
     		};
     
    -		if(code) {
    -			env.code = code.replace(/^(?:\r?\n|\r)/, '');
    -		}
    -
     		if (!code || !grammar) {
     			_.hooks.run('complete', env);
     			return;
    diff --git a/components/prism-core.min.js b/components/prism-core.min.js
    index bf3d9c3096..9499c01cf6 100644
    --- a/components/prism-core.min.js
    +++ b/components/prism-core.min.js
    @@ -1 +1 @@
    -var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=_self.Prism={util:{encode:function(e){return e instanceof n?new n(e.type,t.util.encode(e.content),e.alias):"Array"===t.util.type(e)?e.map(t.util.encode):e.replace(/&/g,"&").replace(/e.length)break e;if(!(d instanceof a)){u.lastIndex=0;var m=u.exec(d);if(m){g&&(f=m[1].length);var y=m.index-1+f,m=m[0].slice(f),v=m.length,k=y+v,b=d.slice(0,y+1),w=d.slice(k+1),N=[p,1];b&&N.push(b);var O=new a(l,c?t.tokenize(m,c):m,h);N.push(O),w&&N.push(w),Array.prototype.splice.apply(r,N)}}}}}return r},hooks:{all:{},add:function(e,n){var a=t.hooks.all;a[e]=a[e]||[],a[e].push(n)},run:function(e,n){var a=t.hooks.all[e];if(a&&a.length)for(var r,i=0;r=a[i++];)r(n)}}},n=t.Token=function(e,t,n){this.type=e,this.content=t,this.alias=n};if(n.stringify=function(e,a,r){if("string"==typeof e)return e;if("Array"===t.util.type(e))return e.map(function(t){return n.stringify(t,a,e)}).join("");var i={type:e.type,content:n.stringify(e.content,a,r),tag:"span",classes:["token",e.type],attributes:{},language:a,parent:r};if("comment"==i.type&&(i.attributes.spellcheck="true"),e.alias){var l="Array"===t.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(i.classes,l)}t.hooks.run("wrap",i);var o="";for(var s in i.attributes)o+=s+'="'+(i.attributes[s]||"")+'"';return"<"+i.tag+' class="'+i.classes.join(" ")+'" '+o+">"+i.content+""},!_self.document)return _self.addEventListener?(_self.addEventListener("message",function(e){var n=JSON.parse(e.data),a=n.language,r=n.code;_self.postMessage(JSON.stringify(t.util.encode(t.tokenize(r,t.languages[a])))),_self.close()},!1),_self.Prism):_self.Prism;var a=document.getElementsByTagName("script");return a=a[a.length-1],a&&(t.filename=a.src,document.addEventListener&&!a.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)),_self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism);
    \ No newline at end of file
    +var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=_self.Prism={util:{encode:function(e){return e instanceof n?new n(e.type,t.util.encode(e.content),e.alias):"Array"===t.util.type(e)?e.map(t.util.encode):e.replace(/&/g,"&").replace(/e.length)break e;if(!(d instanceof a)){u.lastIndex=0;var m=u.exec(d);if(m){c&&(f=m[1].length);var y=m.index-1+f,m=m[0].slice(f),v=m.length,k=y+v,b=d.slice(0,y+1),w=d.slice(k+1),N=[p,1];b&&N.push(b);var O=new a(l,g?t.tokenize(m,g):m,h);N.push(O),w&&N.push(w),Array.prototype.splice.apply(r,N)}}}}}return r},hooks:{all:{},add:function(e,n){var a=t.hooks.all;a[e]=a[e]||[],a[e].push(n)},run:function(e,n){var a=t.hooks.all[e];if(a&&a.length)for(var r,i=0;r=a[i++];)r(n)}}},n=t.Token=function(e,t,n){this.type=e,this.content=t,this.alias=n};if(n.stringify=function(e,a,r){if("string"==typeof e)return e;if("Array"===t.util.type(e))return e.map(function(t){return n.stringify(t,a,e)}).join("");var i={type:e.type,content:n.stringify(e.content,a,r),tag:"span",classes:["token",e.type],attributes:{},language:a,parent:r};if("comment"==i.type&&(i.attributes.spellcheck="true"),e.alias){var l="Array"===t.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(i.classes,l)}t.hooks.run("wrap",i);var o="";for(var s in i.attributes)o+=s+'="'+(i.attributes[s]||"")+'"';return"<"+i.tag+' class="'+i.classes.join(" ")+'" '+o+">"+i.content+""},!_self.document)return _self.addEventListener?(_self.addEventListener("message",function(e){var n=JSON.parse(e.data),a=n.language,r=n.code;_self.postMessage(JSON.stringify(t.util.encode(t.tokenize(r,t.languages[a])))),_self.close()},!1),_self.Prism):_self.Prism;var a=document.getElementsByTagName("script");return a=a[a.length-1],a&&(t.filename=a.src,document.addEventListener&&!a.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)),_self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism);
    \ No newline at end of file
    diff --git a/plugins/remove-initial-line-feed/index.html b/plugins/remove-initial-line-feed/index.html
    new file mode 100644
    index 0000000000..2af0b6697a
    --- /dev/null
    +++ b/plugins/remove-initial-line-feed/index.html
    @@ -0,0 +1,57 @@
    +
    +
    +
    +
    +	
    +	
    +	Remove initial line feed ▲ Prism plugins
    +	
    +	
    +	
    +	
    +
    +	
    +	
    +
    +
    +
    +
    +
    + +

    Remove initial line feed

    +

    Removes the initial line feed in code blocks.

    +
    + +
    +

    How to use

    + +

    Obviously, this is supposed to work only for code blocks (<pre><code>) and not for inline code.

    +

    Add class remove-initial-line-feed to your desired <pre>.

    +
    + +
    +

    Examples

    + +

    Without adding the class

    +
    
    +<div></div>
    +
    + +

    With the class added

    +
    
    +<div></div>
    +
    + +
    + +
    + + + + + + + + + + \ No newline at end of file diff --git a/plugins/remove-initial-line-feed/prism-remove-initial-line-feed.js b/plugins/remove-initial-line-feed/prism-remove-initial-line-feed.js new file mode 100644 index 0000000000..c4d3d0ecae --- /dev/null +++ b/plugins/remove-initial-line-feed/prism-remove-initial-line-feed.js @@ -0,0 +1,13 @@ +Prism.hooks.add('before-highlight', function(env) { + if (env.code) { + var pre = env.element.parentNode; + var clsReg = /\s*\bremove-initial-line-feed\b\s*/; + if ( + pre && pre.nodeName.toLowerCase() === 'pre' && + // Apply only if the
     or the  have the class
    +			(clsReg.test(pre.className) || clsReg.test(env.element.className))
    +		) {
    +			env.code = env.code.replace(/^(?:\r?\n|\r)/, '');
    +		}
    +	}
    +});
    \ No newline at end of file
    diff --git a/plugins/remove-initial-line-feed/prism-remove-initial-line-feed.min.js b/plugins/remove-initial-line-feed/prism-remove-initial-line-feed.min.js
    new file mode 100644
    index 0000000000..083381afdc
    --- /dev/null
    +++ b/plugins/remove-initial-line-feed/prism-remove-initial-line-feed.min.js
    @@ -0,0 +1 @@
    +Prism.hooks.add("before-highlight",function(e){if(e.code){var o=e.element.parentNode,a=/\s*\bremove-initial-line-feed\b\s*/;o&&"pre"===o.nodeName.toLowerCase()&&(a.test(o.className)||a.test(e.element.className))&&(e.code=e.code.replace(/^(?:\r?\n|\r)/,""))}});
    \ No newline at end of file
    diff --git a/prism.js b/prism.js
    index 61bbaf307e..fd979fbf77 100644
    --- a/prism.js
    +++ b/prism.js
    @@ -186,10 +186,6 @@ var _ = _self.Prism = {
     			code: code
     		};
     
    -		if(code) {
    -			env.code = code.replace(/^(?:\r?\n|\r)/, '');
    -		}
    -
     		if (!code || !grammar) {
     			_.hooks.run('complete', env);
     			return;
    
    From a88936ace2794a7506009f0bef9ef67af975ba82 Mon Sep 17 00:00:00 2001
    From: Golmote 
    Date: Mon, 17 Aug 2015 08:55:50 +0200
    Subject: [PATCH 146/310] Split plugins into 3 columns on Download page
    
    ---
     download.html | 10 ++++++++--
     1 file changed, 8 insertions(+), 2 deletions(-)
    
    diff --git a/download.html b/download.html
    index f273c7eaa0..103d81329e 100644
    --- a/download.html
    +++ b/download.html
    @@ -52,7 +52,8 @@
     	float: left;
     }
     
    -section.options#category-languages {
    +section.options#category-languages,
    +section.options#category-plugins {
     	width: 100%;
     	float: none;
     	column-count: 3;
    @@ -60,7 +61,12 @@
     	overflow: visible;
     }
     
    -	section.options#category-languages > h1 {
    +	section.options#category-languages label,
    +	section.options#category-plugins label {
    +		break-inside: avoid;
    +	}
    +	section.options#category-languages > h1,
    +	section.options#category-plugins > h1 {
     		margin-top: 0;
     		column-span: all;
     	}
    
    From b8d098e1d420715366302274c511ab4aeaeeb2fe Mon Sep 17 00:00:00 2001
    From: Golmote 
    Date: Mon, 17 Aug 2015 09:03:06 +0200
    Subject: [PATCH 147/310] Remove the behaviour of Remove initial line feed
     plugin (remove by default, allow to keep with a CSS class)
    
    ---
     plugins/remove-initial-line-feed/index.html                 | 5 +++--
     .../prism-remove-initial-line-feed.js                       | 6 +++---
     .../prism-remove-initial-line-feed.min.js                   | 2 +-
     3 files changed, 7 insertions(+), 6 deletions(-)
    
    diff --git a/plugins/remove-initial-line-feed/index.html b/plugins/remove-initial-line-feed/index.html
    index 2af0b6697a..d981fbb770 100644
    --- a/plugins/remove-initial-line-feed/index.html
    +++ b/plugins/remove-initial-line-feed/index.html
    @@ -26,7 +26,8 @@ 

    Remove initial line feed

    How to use

    Obviously, this is supposed to work only for code blocks (<pre><code>) and not for inline code.

    -

    Add class remove-initial-line-feed to your desired <pre>.

    +

    With this plugin included, any initial line feed will be removed by default.

    +

    To bypass this behaviour, you may add the class keep-initial-line-feed to your desired <pre>.

    @@ -38,7 +39,7 @@

    Without adding the class

    With the class added

    -
    
    +	
    
     <div></div>
     
    diff --git a/plugins/remove-initial-line-feed/prism-remove-initial-line-feed.js b/plugins/remove-initial-line-feed/prism-remove-initial-line-feed.js index c4d3d0ecae..0b24fb5cc2 100644 --- a/plugins/remove-initial-line-feed/prism-remove-initial-line-feed.js +++ b/plugins/remove-initial-line-feed/prism-remove-initial-line-feed.js @@ -1,11 +1,11 @@ Prism.hooks.add('before-highlight', function(env) { if (env.code) { var pre = env.element.parentNode; - var clsReg = /\s*\bremove-initial-line-feed\b\s*/; + var clsReg = /\s*\bkeep-initial-line-feed\b\s*/; if ( pre && pre.nodeName.toLowerCase() === 'pre' && - // Apply only if the
     or the  have the class
    -			(clsReg.test(pre.className) || clsReg.test(env.element.className))
    +			// Apply only if nor the 
     or the  have the class
    +			(!clsReg.test(pre.className) && !clsReg.test(env.element.className))
     		) {
     			env.code = env.code.replace(/^(?:\r?\n|\r)/, '');
     		}
    diff --git a/plugins/remove-initial-line-feed/prism-remove-initial-line-feed.min.js b/plugins/remove-initial-line-feed/prism-remove-initial-line-feed.min.js
    index 083381afdc..a8930b631e 100644
    --- a/plugins/remove-initial-line-feed/prism-remove-initial-line-feed.min.js
    +++ b/plugins/remove-initial-line-feed/prism-remove-initial-line-feed.min.js
    @@ -1 +1 @@
    -Prism.hooks.add("before-highlight",function(e){if(e.code){var o=e.element.parentNode,a=/\s*\bremove-initial-line-feed\b\s*/;o&&"pre"===o.nodeName.toLowerCase()&&(a.test(o.className)||a.test(e.element.className))&&(e.code=e.code.replace(/^(?:\r?\n|\r)/,""))}});
    \ No newline at end of file
    +Prism.hooks.add("before-highlight",function(e){if(e.code){var a=e.element.parentNode,o=/\s*\bkeep-initial-line-feed\b\s*/;!a||"pre"!==a.nodeName.toLowerCase()||o.test(a.className)||o.test(e.element.className)||(e.code=e.code.replace(/^(?:\r?\n|\r)/,""))}});
    \ No newline at end of file
    
    From d1845471b61d93ff474e98ce3480fdeb7df6f9ae Mon Sep 17 00:00:00 2001
    From: Joe Gibson 
    Date: Mon, 17 Aug 2015 14:59:31 -0400
    Subject: [PATCH 148/310] Added 'self' as keyword and added 'class-name'
     matching
    
    ---
     components/prism-python.js | 9 ++++++++-
     1 file changed, 8 insertions(+), 1 deletion(-)
    
    diff --git a/components/prism-python.js b/components/prism-python.js
    index 7ebc42a747..bdbce33965 100644
    --- a/components/prism-python.js
    +++ b/components/prism-python.js
    @@ -8,9 +8,16 @@ Prism.languages.python= {
     		pattern: /((^|\s)def[ \t]+)([a-zA-Z_][a-zA-Z0-9_]*(?=\())/g,
     		lookbehind: true
     	},
    -	'keyword' : /\b(as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/,
    +	'keyword' : /\b(as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|self|try|while|with|yield)\b/,
     	'boolean' : /\b(True|False)\b/,
     	'number' : /\b-?(0[bo])?(?:(\d|0x[a-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,
     	'operator' : /[-+]|<=?|>=?|!|={1,2}|&{1,2}|\|?\||\?|\*|\/|@|~|\^|%|\b(or|and|not)\b/,
     	'punctuation' : /[{}[\];(),.:]/
     };
    +
    +Prism.languages.insertBefore('python', 'keyword', {
    +	'class-name': {
    +		pattern: /(class\s+)[a-z0-9_]+/i,
    +		lookbehind: true
    +	}
    +});
    
    From 9ccb6cb6e1959c4edfe01dc68a55f1ef32fb2c67 Mon Sep 17 00:00:00 2001
    From: Joe Gibson 
    Date: Mon, 17 Aug 2015 17:28:11 -0400
    Subject: [PATCH 149/310] , it appears, is not actually a keyword in Python
    
    ---
     components/prism-python.js | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/components/prism-python.js b/components/prism-python.js
    index bdbce33965..a3171d7cb6 100644
    --- a/components/prism-python.js
    +++ b/components/prism-python.js
    @@ -8,7 +8,7 @@ Prism.languages.python= {
     		pattern: /((^|\s)def[ \t]+)([a-zA-Z_][a-zA-Z0-9_]*(?=\())/g,
     		lookbehind: true
     	},
    -	'keyword' : /\b(as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|self|try|while|with|yield)\b/,
    +	'keyword' : /\b(as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/,
     	'boolean' : /\b(True|False)\b/,
     	'number' : /\b-?(0[bo])?(?:(\d|0x[a-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,
     	'operator' : /[-+]|<=?|>=?|!|={1,2}|&{1,2}|\|?\||\?|\*|\/|@|~|\^|%|\b(or|and|not)\b/,
    
    From 8f8eb62691865067cf284fa1647678d8db80036b Mon Sep 17 00:00:00 2001
    From: Joe Gibson 
    Date: Mon, 17 Aug 2015 17:30:43 -0400
    Subject: [PATCH 150/310] Update to minified python
    
    ---
     components/prism-python.min.js | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/components/prism-python.min.js b/components/prism-python.min.js
    index 087ad0dd41..19ca5c55b5 100644
    --- a/components/prism-python.min.js
    +++ b/components/prism-python.min.js
    @@ -1 +1 @@
    -Prism.languages.python={comment:{pattern:/(^|[^\\])#.*?(\r?\n|$)/,lookbehind:!0},string:/"""[\s\S]+?"""|'''[\s\S]+?'''|("|')(\\?.)*?\1/,"function":{pattern:/((^|\s)def[ \t]+)([a-zA-Z_][a-zA-Z0-9_]*(?=\())/g,lookbehind:!0},keyword:/\b(as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/,"boolean":/\b(True|False)\b/,number:/\b-?(0[bo])?(?:(\d|0x[a-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,operator:/[-+]|<=?|>=?|!|={1,2}|&{1,2}|\|?\||\?|\*|\/|@|~|\^|%|\b(or|and|not)\b/,punctuation:/[{}[\];(),.:]/};
    \ No newline at end of file
    +Prism.languages.python={comment:{pattern:/(^|[^\\])#.*?(\r?\n|$)/,lookbehind:!0},string:/"""[\s\S]+?"""|'''[\s\S]+?'''|("|')(\\?.)*?\1/,"function":{pattern:/((^|\s)def[ \t]+)([a-zA-Z_][a-zA-Z0-9_]*(?=\())/g,lookbehind:!0},keyword:/\b(as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/,"boolean":/\b(True|False)\b/,number:/\b-?(0[bo])?(?:(\d|0x[a-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,operator:/[-+]|<=?|>=?|!|={1,2}|&{1,2}|\|?\||\?|\*|\/|@|~|\^|%|\b(or|and|not)\b/,punctuation:/[{}[\];(),.:]/};Prism.languages.insertBefore("python","keyword",{"class-name":{pattern:/(class\s+)[a-z0-9_]+/i,lookbehind:!0}});
    
    From 45ca8c8eee737bde813c63cf6d36b18f869552dc Mon Sep 17 00:00:00 2001
    From: Golmote 
    Date: Tue, 18 Aug 2015 08:17:01 +0200
    Subject: [PATCH 151/310] Add .gitattributes to prevent line ending changes in
     test files
    
    ---
     .gitattributes | 4 ++++
     1 file changed, 4 insertions(+)
     create mode 100644 .gitattributes
    
    diff --git a/.gitattributes b/.gitattributes
    new file mode 100644
    index 0000000000..1d598bdc92
    --- /dev/null
    +++ b/.gitattributes
    @@ -0,0 +1,4 @@
    +* text=auto
    +
    +# Test files should not have their line endings modified by git
    +/tests/languages/**/*.test binary
    \ No newline at end of file
    
    From 788f6d5e2ae92369f9ceb2c2ca553e18542b110b Mon Sep 17 00:00:00 2001
    From: Golmote 
    Date: Tue, 18 Aug 2015 08:20:54 +0200
    Subject: [PATCH 152/310] Commit updated line changes
    
    ---
     tests/languages/apacheconf/test2.test         |  32 +--
     tests/languages/javascript/testcase1.test     |  30 +--
     tests/languages/markup/cdata_feature.test     |  28 +--
     tests/languages/markup/comment_feature.test   |  30 +--
     tests/languages/markup/doctype_feature.test   |  30 +--
     tests/languages/markup/entity_feature.test    |  26 +--
     tests/languages/markup/issue585.test          | 124 ++++++------
     tests/languages/markup/prolog_feature.test    |  30 +--
     .../markup/tag_attribute_feature.test         | 182 +++++++++---------
     tests/languages/markup/tag_feature.test       | 160 +++++++--------
     utopia.js                                     |  30 +--
     11 files changed, 351 insertions(+), 351 deletions(-)
    
    diff --git a/tests/languages/apacheconf/test2.test b/tests/languages/apacheconf/test2.test
    index a136917c03..f03cf6781d 100644
    --- a/tests/languages/apacheconf/test2.test
    +++ b/tests/languages/apacheconf/test2.test
    @@ -1,16 +1,16 @@
    -"foo bar"
    -'foo bar'
    -"%{REMOTE_HOST}"
    -
    ------
    -[
    -    ["string", ["\"foo bar\""]],
    -    ["string", ["'foo bar'"]],
    -    [
    -        "string", [
    -            "\"",
    -            ["variable", "%{REMOTE_HOST}"],
    -            "\""
    -        ]
    -    ]
    -]
    +"foo bar"
    +'foo bar'
    +"%{REMOTE_HOST}"
    +
    +-----
    +[
    +    ["string", ["\"foo bar\""]],
    +    ["string", ["'foo bar'"]],
    +    [
    +        "string", [
    +            "\"",
    +            ["variable", "%{REMOTE_HOST}"],
    +            "\""
    +        ]
    +    ]
    +]
    diff --git a/tests/languages/javascript/testcase1.test b/tests/languages/javascript/testcase1.test
    index 78a197175a..e424522129 100644
    --- a/tests/languages/javascript/testcase1.test
    +++ b/tests/languages/javascript/testcase1.test
    @@ -1,15 +1,15 @@
    -var a = 5;
    -
    -----------------------------------------------------
    -
    -[
    -	["keyword", "var"],
    -	" a ",
    -	["operator", "="],
    -	["number", "5"],
    -	["punctuation", ";"]
    -]
    -
    -----------------------------------------------------
    -
    -This is a comment explaining this test case.
    +var a = 5;
    +
    +----------------------------------------------------
    +
    +[
    +	["keyword", "var"],
    +	" a ",
    +	["operator", "="],
    +	["number", "5"],
    +	["punctuation", ";"]
    +]
    +
    +----------------------------------------------------
    +
    +This is a comment explaining this test case.
    diff --git a/tests/languages/markup/cdata_feature.test b/tests/languages/markup/cdata_feature.test
    index c2854c9c62..3b7fd98d34 100644
    --- a/tests/languages/markup/cdata_feature.test
    +++ b/tests/languages/markup/cdata_feature.test
    @@ -1,15 +1,15 @@
    -
    -
    -
    -----------------------------------------------------
    -
    -[
    -	["cdata", ""],
    -	["cdata", ""]
    -]
    -
    -----------------------------------------------------
    -
    +
    +
    +
    +----------------------------------------------------
    +
    +[
    +	["cdata", ""],
    +	["cdata", ""]
    +]
    +
    +----------------------------------------------------
    +
     Checks for CDATA sections, single-line and multi-line.
    \ No newline at end of file
    diff --git a/tests/languages/markup/comment_feature.test b/tests/languages/markup/comment_feature.test
    index 8acbb0deb7..1b26ae54e5 100644
    --- a/tests/languages/markup/comment_feature.test
    +++ b/tests/languages/markup/comment_feature.test
    @@ -1,16 +1,16 @@
    -
    -
    -
    -
    -----------------------------------------------------
    -
    -[
    -	["comment", ""],
    -	["comment", ""],
    -	["comment", ""]
    -]
    -
    -----------------------------------------------------
    -
    +
    +
    +
    +
    +----------------------------------------------------
    +
    +[
    +	["comment", ""],
    +	["comment", ""],
    +	["comment", ""]
    +]
    +
    +----------------------------------------------------
    +
     Checks for empty comment, single-line comment and multi-line comment.
    \ No newline at end of file
    diff --git a/tests/languages/markup/doctype_feature.test b/tests/languages/markup/doctype_feature.test
    index a7212073ee..71398c4d83 100644
    --- a/tests/languages/markup/doctype_feature.test
    +++ b/tests/languages/markup/doctype_feature.test
    @@ -1,16 +1,16 @@
    -
    -
    -
    -
    -----------------------------------------------------
    -
    -[
    -	["doctype", ""],
    -	["doctype", ""],
    -	["doctype", ""]
    -]
    -
    -----------------------------------------------------
    -
    +
    +
    +
    +
    +----------------------------------------------------
    +
    +[
    +	["doctype", ""],
    +	["doctype", ""],
    +	["doctype", ""]
    +]
    +
    +----------------------------------------------------
    +
     Checks for different doctypes, single-line and multi-line.
    \ No newline at end of file
    diff --git a/tests/languages/markup/entity_feature.test b/tests/languages/markup/entity_feature.test
    index 2212c6b10f..44f0f83d6a 100644
    --- a/tests/languages/markup/entity_feature.test
    +++ b/tests/languages/markup/entity_feature.test
    @@ -1,14 +1,14 @@
    -& ϑ ⛵  
    -
    -----------------------------------------------------
    -
    -[
    -	["entity", "&"],
    -	["entity", "ϑ"],
    -	["entity", "⛵"],
    -	["entity", " "]
    -]
    -
    -----------------------------------------------------
    -
    +& ϑ ⛵  
    +
    +----------------------------------------------------
    +
    +[
    +	["entity", "&"],
    +	["entity", "ϑ"],
    +	["entity", "⛵"],
    +	["entity", " "]
    +]
    +
    +----------------------------------------------------
    +
     Checks for HTML/XML character entity references.
    \ No newline at end of file
    diff --git a/tests/languages/markup/issue585.test b/tests/languages/markup/issue585.test
    index 090506ab06..bb71198c23 100644
    --- a/tests/languages/markup/issue585.test
    +++ b/tests/languages/markup/issue585.test
    @@ -1,63 +1,63 @@
    -foo
    -
    -baz
    -
    -----------------------------------------------------
    -
    -[
    -	["tag", [
    -		["tag", [
    -			["punctuation", "<"],
    -			"Läufer"
    -		]],
    -		["punctuation", ">"]
    -	]],
    -	"foo",
    -	["tag", [
    -		["tag", [
    -			["punctuation", ""]
    -	]],
    -
    -	["tag", [
    -        ["tag", [
    -            ["punctuation", "<"],
    -            "tag"
    -        ]],
    -        ["attr-name", [
    -            "läufer"
    -        ]],
    -        ["attr-value", [
    -            ["punctuation", "="],
    -            ["punctuation", "\""],
    -            "läufer",
    -            ["punctuation", "\""]
    -        ]],
    -        ["punctuation", ">"]
    -    ]],
    -
    -    ["tag", [
    -		["tag", [
    -			["punctuation", "<"],
    -			["namespace", "läufer:"],
    -			"tag"
    -		]],
    -		["punctuation", ">"]
    -	]],
    -	"baz",
    -	["tag", [
    -		["tag", [
    -			["punctuation", ""]
    -	]]
    -]
    -
    -----------------------------------------------------
    -
    -Checks for tags, attributes and namespaces containing unicode characters.
    +foo
    +
    +baz
    +
    +----------------------------------------------------
    +
    +[
    +	["tag", [
    +		["tag", [
    +			["punctuation", "<"],
    +			"Läufer"
    +		]],
    +		["punctuation", ">"]
    +	]],
    +	"foo",
    +	["tag", [
    +		["tag", [
    +			["punctuation", ""]
    +	]],
    +
    +	["tag", [
    +        ["tag", [
    +            ["punctuation", "<"],
    +            "tag"
    +        ]],
    +        ["attr-name", [
    +            "läufer"
    +        ]],
    +        ["attr-value", [
    +            ["punctuation", "="],
    +            ["punctuation", "\""],
    +            "läufer",
    +            ["punctuation", "\""]
    +        ]],
    +        ["punctuation", ">"]
    +    ]],
    +
    +    ["tag", [
    +		["tag", [
    +			["punctuation", "<"],
    +			["namespace", "läufer:"],
    +			"tag"
    +		]],
    +		["punctuation", ">"]
    +	]],
    +	"baz",
    +	["tag", [
    +		["tag", [
    +			["punctuation", ""]
    +	]]
    +]
    +
    +----------------------------------------------------
    +
    +Checks for tags, attributes and namespaces containing unicode characters.
     See #585 for details.
    \ No newline at end of file
    diff --git a/tests/languages/markup/prolog_feature.test b/tests/languages/markup/prolog_feature.test
    index bb3f5a52a1..d7a2d3de86 100644
    --- a/tests/languages/markup/prolog_feature.test
    +++ b/tests/languages/markup/prolog_feature.test
    @@ -1,16 +1,16 @@
    -
    -
    -
    -
    -----------------------------------------------------
    -
    -[
    -	["prolog", ""],
    -	["prolog", ""],
    -	["prolog", ""]
    -]
    -
    -----------------------------------------------------
    -
    +
    +
    +
    +
    +----------------------------------------------------
    +
    +[
    +	["prolog", ""],
    +	["prolog", ""],
    +	["prolog", ""]
    +]
    +
    +----------------------------------------------------
    +
     Checks for different XML prologs, single-line and multi-line.
    \ No newline at end of file
    diff --git a/tests/languages/markup/tag_attribute_feature.test b/tests/languages/markup/tag_attribute_feature.test
    index 57eba1abf6..986cca8251 100644
    --- a/tests/languages/markup/tag_attribute_feature.test
    +++ b/tests/languages/markup/tag_attribute_feature.test
    @@ -1,92 +1,92 @@
    -
    -
    -
    -
    - ----------------------------------------------------- - -[ - ["tag", [ - ["tag", [ - ["punctuation", "<"], - "div" - ]], - ["attr-name", [ - "class" - ]], - ["attr-value", [ - ["punctuation", "="], - ["punctuation", "\""], - "test", - ["punctuation", "\""] - ]], - ["attr-name", [ - "foo" - ]], - ["attr-name", [ - "bar" - ]], - ["attr-value", [ - ["punctuation", "="], - "baz" - ]], - ["punctuation", ">"] - ]], - - ["tag", [ - ["tag", [ - ["punctuation", "<"], - "div" - ]], - ["attr-name", [ - "foo" - ]], - ["attr-value", [ - ["punctuation", "="], - ["punctuation", "'"], - "bar", - ["punctuation", "'"] - ]], - ["punctuation", ">"] - ]], - - ["tag", [ - ["tag", [ - ["punctuation", "<"], - "div" - ]], - ["attr-name", [ - "class" - ]], - ["attr-value", [ - ["punctuation", "="], - ["punctuation", "\""], - "foo\r\nbar\r\nbaz", - ["punctuation", "\""] - ]], - ["punctuation", ">"] - ]], - - ["tag", [ - ["tag", [ - ["punctuation", "<"], - "div" - ]], - ["attr-name", [ - ["namespace", "foo:"], - "bar" - ]], - ["attr-value", [ - ["punctuation", "="], - "42" - ]], - ["punctuation", ">"] - ]] -] - ----------------------------------------------------- - -Checks for single-quoted, double-quoted and unquoted attributes, attributes without value and +
    +
    +
    +
    + +---------------------------------------------------- + +[ + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "div" + ]], + ["attr-name", [ + "class" + ]], + ["attr-value", [ + ["punctuation", "="], + ["punctuation", "\""], + "test", + ["punctuation", "\""] + ]], + ["attr-name", [ + "foo" + ]], + ["attr-name", [ + "bar" + ]], + ["attr-value", [ + ["punctuation", "="], + "baz" + ]], + ["punctuation", ">"] + ]], + + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "div" + ]], + ["attr-name", [ + "foo" + ]], + ["attr-value", [ + ["punctuation", "="], + ["punctuation", "'"], + "bar", + ["punctuation", "'"] + ]], + ["punctuation", ">"] + ]], + + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "div" + ]], + ["attr-name", [ + "class" + ]], + ["attr-value", [ + ["punctuation", "="], + ["punctuation", "\""], + "foo\r\nbar\r\nbaz", + ["punctuation", "\""] + ]], + ["punctuation", ">"] + ]], + + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "div" + ]], + ["attr-name", [ + ["namespace", "foo:"], + "bar" + ]], + ["attr-value", [ + ["punctuation", "="], + "42" + ]], + ["punctuation", ">"] + ]] +] + +---------------------------------------------------- + +Checks for single-quoted, double-quoted and unquoted attributes, attributes without value and namespaced attributes. \ No newline at end of file diff --git a/tests/languages/markup/tag_feature.test b/tests/languages/markup/tag_feature.test index 110de1df87..43089ad640 100644 --- a/tests/languages/markup/tag_feature.test +++ b/tests/languages/markup/tag_feature.test @@ -1,81 +1,81 @@ -

    -
    dummy
    -
    - -
    "] - ]], - ["tag", [ - ["tag", [ - ["punctuation", ""] - ]], - - ["tag", [ - ["tag", [ - ["punctuation", "<"], - "div" - ]], - ["punctuation", ">"] - ]], - "dummy", - ["tag", [ - ["tag", [ - ["punctuation", ""] - ]], - - ["tag", [ - ["tag", [ - ["punctuation", "<"], - "div" - ]], - ["punctuation", ">"] - ]], - ["tag", [ - ["tag", [ - ["punctuation", ""] - ]], - - ["tag", [ - ["tag", [ - ["punctuation", "<"], - ["namespace", "foo:"], - "bar" - ]], - ["punctuation", ">"] - ]], - ["tag", [ - ["tag", [ - ["punctuation", ""] - ]], - "\r\n

    +
    dummy
    +
    + +
    "] + ]], + ["tag", [ + ["tag", [ + ["punctuation", ""] + ]], + + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "div" + ]], + ["punctuation", ">"] + ]], + "dummy", + ["tag", [ + ["tag", [ + ["punctuation", ""] + ]], + + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "div" + ]], + ["punctuation", ">"] + ]], + ["tag", [ + ["tag", [ + ["punctuation", ""] + ]], + + ["tag", [ + ["tag", [ + ["punctuation", "<"], + ["namespace", "foo:"], + "bar" + ]], + ["punctuation", ">"] + ]], + ["tag", [ + ["tag", [ + ["punctuation", ""] + ]], + "\r\n Date: Tue, 18 Aug 2015 14:39:45 +0800 Subject: [PATCH 153/310] remove code comments in components.js --- components.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/components.js b/components.js index 1129ef8eab..169d432532 100644 --- a/components.js +++ b/components.js @@ -54,9 +54,6 @@ var components = { "option": "default", "require": "clike" }, - - // --- - "actionscript": { "title": "ActionScript", "require": "javascript", From 39bd8278ec700dd651bf99e60f62bea0ffb9b378 Mon Sep 17 00:00:00 2001 From: Golmote Date: Tue, 18 Aug 2015 19:00:24 +0200 Subject: [PATCH 154/310] Add gulp task to build languages map in Show language plugin (Fix #671) --- components.js | 3 ++ gulpfile.js | 47 ++++++++++++++++++- package.json | 1 + plugins/show-language/prism-show-language.js | 8 ++-- .../show-language/prism-show-language.min.js | 2 +- 5 files changed, 53 insertions(+), 8 deletions(-) diff --git a/components.js b/components.js index 169d432532..b9ce823bbf 100644 --- a/components.js +++ b/components.js @@ -54,6 +54,9 @@ var components = { "option": "default", "require": "clike" }, + + + "actionscript": { "title": "ActionScript", "require": "javascript", diff --git a/gulpfile.js b/gulpfile.js index 25de6e500d..51af93c33f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -3,8 +3,11 @@ var gulp = require('gulp'), uglify = require('gulp-uglify'), header = require('gulp-header'), concat = require('gulp-concat'), + replace = require('gulp-replace'), + fs = require('fs'), paths = { + componentsFile: 'components.js', components: ['components/**/*.js', '!components/**/*.min.js'], main: [ 'components/prism-core.js', @@ -14,7 +17,8 @@ var gulp = require('gulp'), 'components/prism-javascript.js', 'plugins/file-highlight/prism-file-highlight.js' ], - plugins: ['plugins/**/*.js', '!plugins/**/*.min.js'] + plugins: ['plugins/**/*.js', '!plugins/**/*.min.js'], + showLanguagePlugin: 'plugins/show-language/prism-show-language.js' }; gulp.task('components', function() { @@ -33,7 +37,7 @@ gulp.task('build', function() { .pipe(gulp.dest('./')); }); -gulp.task('plugins', function() { +gulp.task('plugins', ['show-language-plugin'], function() { return gulp.src(paths.plugins) .pipe(uglify()) .pipe(rename({ suffix: '.min' })) @@ -45,4 +49,43 @@ gulp.task('watch', function() { gulp.watch(paths.plugins, ['plugins', 'build']); }); +gulp.task('show-language-plugin', function (cb) { + fs.readFile(paths.componentsFile, { + encoding: 'utf-8' + }, function (err, data) { + if (!err) { + data = data.replace(/^var\s+components\s*=\s*|;\s*$/g, ''); + try { + data = JSON.parse(data); + + var languagesMap = {}; + for (var p in data.languages) { + if (p !== 'meta') { + var title = data.languages[p].displayTitle || data.languages[p].title; + var ucfirst = p.substring(0, 1).toUpperCase() + p.substring(1); + if (title !== ucfirst) { + languagesMap[p] = title; + } + } + } + + var jsonLanguages = JSON.stringify(languagesMap); + var stream = gulp.src(paths.showLanguagePlugin) + .pipe(replace( + /\/\*languages_placeholder\[\*\/[\s\S]*?\/\*\]\*\//, + '/*languages_placeholder[*/' + jsonLanguages + '/*]*/' + )) + .pipe(gulp.dest(paths.showLanguagePlugin.substring(0, paths.showLanguagePlugin.lastIndexOf('/')))); + stream.on('error', cb); + stream.on('end', cb); + + } catch (e) { + cb(e); + } + } else { + cb(err); + } + }); +}); + gulp.task('default', ['components', 'plugins', 'build']); diff --git a/package.json b/package.json index 2f8af95a5f..b00ea8fd2a 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "gulp-header": "^1.0.5", "gulp-rename": "^1.2.0", "gulp-uglify": "^0.3.1", + "gulp-replace": "^0.5.4", "mocha": "^2.2.5" } } diff --git a/plugins/show-language/prism-show-language.js b/plugins/show-language/prism-show-language.js index 7b345d39be..ac43bd6675 100644 --- a/plugins/show-language/prism-show-language.js +++ b/plugins/show-language/prism-show-language.js @@ -4,16 +4,14 @@ if (!self.Prism) { return; } -var Languages = { - 'csharp': 'C#', - 'cpp': 'C++' -}; +// The languages map is built automatically with gulp +var Languages = /*languages_placeholder[*/{"css":"CSS","clike":"C-like","javascript":"JavaScript","actionscript":"ActionScript","apacheconf":"Apache Configuration","applescript":"AppleScript","aspnet":"ASP.NET (C#)","autohotkey":"AutoHotkey","csharp":"C#","cpp":"C++","coffeescript":"CoffeeScript","css-extras":"CSS Extras","fsharp":"F#","http":"HTTP","latex":"LaTeX","lolcode":"LOLCODE","matlab":"MATLAB","nasm":"NASM","nsis":"NSIS","objectivec":"Objective-C","php":"PHP","php-extras":"PHP Extras","powershell":"PowerShell","jsx":"React JSX","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","typescript":"TypeScript","vhdl":"VHDL","wiki":"Wiki markup","yaml":"YAML"}/*]*/; Prism.hooks.add('before-highlight', function(env) { var pre = env.element.parentNode; if (!pre || !/pre/i.test(pre.nodeName)) { return; } - var language = Languages[env.language] || env.language; + var language = Languages[env.language] || (env.language.substring(0, 1).toUpperCase() + env.language.substring(1)); pre.setAttribute('data-language', language); }); diff --git a/plugins/show-language/prism-show-language.min.js b/plugins/show-language/prism-show-language.min.js index 3f9280d985..849fc6d14a 100644 --- a/plugins/show-language/prism-show-language.min.js +++ b/plugins/show-language/prism-show-language.min.js @@ -1 +1 @@ -!function(){if(self.Prism){var e={csharp:"C#",cpp:"C++"};Prism.hooks.add("before-highlight",function(a){var t=a.element.parentNode;if(t&&/pre/i.test(t.nodeName)){var i=e[a.language]||a.language;t.setAttribute("data-language",i)}})}}(); \ No newline at end of file +!function(){if(self.Prism){var e={css:"CSS",clike:"C-like",javascript:"JavaScript",actionscript:"ActionScript",apacheconf:"Apache Configuration",applescript:"AppleScript",aspnet:"ASP.NET (C#)",autohotkey:"AutoHotkey",csharp:"C#",cpp:"C++",coffeescript:"CoffeeScript","css-extras":"CSS Extras",fsharp:"F#",http:"HTTP",latex:"LaTeX",lolcode:"LOLCODE",matlab:"MATLAB",nasm:"NASM",nsis:"NSIS",objectivec:"Objective-C",php:"PHP","php-extras":"PHP Extras",powershell:"PowerShell",jsx:"React JSX",rest:"reST (reStructuredText)",sas:"SAS",sass:"Sass (Sass)",scss:"Sass (Scss)",sql:"SQL",typescript:"TypeScript",vhdl:"VHDL",wiki:"Wiki markup",yaml:"YAML"};Prism.hooks.add("before-highlight",function(s){var t=s.element.parentNode;if(t&&/pre/i.test(t.nodeName)){var a=e[s.language]||s.language.substring(0,1).toUpperCase()+s.language.substring(1);t.setAttribute("data-language",a)}})}}(); \ No newline at end of file From 8ed7ce3a6d11d68d6c65801459d4aed78455baad Mon Sep 17 00:00:00 2001 From: Golmote Date: Tue, 18 Aug 2015 19:57:17 +0200 Subject: [PATCH 155/310] Test for rounded line-height to fix positions in Line Highlight plugin --- .../line-highlight/prism-line-highlight.js | 29 ++++++++++++++++--- .../prism-line-highlight.min.js | 2 +- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/plugins/line-highlight/prism-line-highlight.js b/plugins/line-highlight/prism-line-highlight.js index b89028a1b8..a0bd34bae3 100644 --- a/plugins/line-highlight/prism-line-highlight.js +++ b/plugins/line-highlight/prism-line-highlight.js @@ -13,13 +13,34 @@ function hasClass(element, className) { return (" " + element.className + " ").replace(/[\n\t]/g, " ").indexOf(className) > -1 } -var CRLF = crlf = /\r?\n|\r/g; - +// Some browsers round the line-height, others don't. +// We need to test for it to position the elements properly. +var isLineHeightRounded = (function() { + var res; + return function() { + if(typeof res === 'undefined') { + var d = document.createElement('div'); + d.style.fontSize = '13px'; + d.style.lineHeight = '1.5'; + d.style.padding = 0; + d.style.border = 0; + d.innerHTML = ' 
     '; + document.body.appendChild(d); + // Browsers that round the line-height should have offsetHeight === 38 + // The others should have 39. + res = d.offsetHeight === 38; + document.body.removeChild(d); + } + return res; + } +}()); + function highlightLines(pre, lines, classes) { var ranges = lines.replace(/\s+/g, '').split(','), offset = +pre.getAttribute('data-line-offset') || 0; - - var lineHeight = parseInt(getComputedStyle(pre).lineHeight); + + var parseMethod = isLineHeightRounded() ? parseInt : parseFloat; + var lineHeight = parseMethod(getComputedStyle(pre).lineHeight); for (var i=0, range; range = ranges[i++];) { range = range.split('-'); diff --git a/plugins/line-highlight/prism-line-highlight.min.js b/plugins/line-highlight/prism-line-highlight.min.js index 380776b0a0..1018af46bd 100644 --- a/plugins/line-highlight/prism-line-highlight.min.js +++ b/plugins/line-highlight/prism-line-highlight.min.js @@ -1 +1 @@ -!function(){function e(e,t){return Array.prototype.slice.call((t||document).querySelectorAll(e))}function t(e,t){return t=" "+t+" ",(" "+e.className+" ").replace(/[\n\t]/g," ").indexOf(t)>-1}function n(e,n,r){for(var i,a=n.replace(/\s+/g,"").split(","),l=+e.getAttribute("data-line-offset")||0,o=parseInt(getComputedStyle(e).lineHeight),c=0;i=a[c++];){i=i.split("-");var d=+i[0],s=+i[1]||d,u=document.createElement("div");u.textContent=Array(s-d+2).join(" \n"),u.className=(r||"")+" line-highlight",t(e,"line-numbers")||(u.setAttribute("data-start",d),s>d&&u.setAttribute("data-end",s)),u.style.top=(d-l-1)*o+"px",t(e,"line-numbers")?e.appendChild(u):(e.querySelector("code")||e).appendChild(u)}}function r(){var t=location.hash.slice(1);e(".temporary.line-highlight").forEach(function(e){e.parentNode.removeChild(e)});var r=(t.match(/\.([\d,-]+)$/)||[,""])[1];if(r&&!document.getElementById(t)){var i=t.slice(0,t.lastIndexOf(".")),a=document.getElementById(i);a&&(a.hasAttribute("data-line")||a.setAttribute("data-line",""),n(a,r,"temporary "),document.querySelector(".temporary.line-highlight").scrollIntoView())}}if(window.Prism){var i=(crlf=/\r?\n|\r/g,0);Prism.hooks.add("complete",function(t){var a=t.element.parentNode,l=a&&a.getAttribute("data-line");a&&l&&/pre/i.test(a.nodeName)&&(clearTimeout(i),e(".line-highlight",a).forEach(function(e){e.parentNode.removeChild(e)}),n(a,l),i=setTimeout(r,1))}),addEventListener("hashchange",r)}}(); \ No newline at end of file +!function(){function e(e,t){return Array.prototype.slice.call((t||document).querySelectorAll(e))}function t(e,t){return t=" "+t+" ",(" "+e.className+" ").replace(/[\n\t]/g," ").indexOf(t)>-1}function n(e,n,i){for(var a,o=n.replace(/\s+/g,"").split(","),l=+e.getAttribute("data-line-offset")||0,d=r()?parseInt:parseFloat,c=d(getComputedStyle(e).lineHeight),s=0;a=o[s++];){a=a.split("-");var u=+a[0],h=+a[1]||u,m=document.createElement("div");m.textContent=Array(h-u+2).join(" \n"),m.className=(i||"")+" line-highlight",t(e,"line-numbers")||(m.setAttribute("data-start",u),h>u&&m.setAttribute("data-end",h)),m.style.top=(u-l-1)*c+"px",t(e,"line-numbers")?e.appendChild(m):(e.querySelector("code")||e).appendChild(m)}}function i(){var t=location.hash.slice(1);e(".temporary.line-highlight").forEach(function(e){e.parentNode.removeChild(e)});var i=(t.match(/\.([\d,-]+)$/)||[,""])[1];if(i&&!document.getElementById(t)){var r=t.slice(0,t.lastIndexOf(".")),a=document.getElementById(r);a&&(a.hasAttribute("data-line")||a.setAttribute("data-line",""),n(a,i,"temporary "),document.querySelector(".temporary.line-highlight").scrollIntoView())}}if(window.Prism){var r=function(){var e;return function(){if("undefined"==typeof e){var t=document.createElement("div");t.style.fontSize="13px",t.style.lineHeight="1.5",t.style.padding=0,t.style.border=0,t.innerHTML=" 
     ",document.body.appendChild(t),e=38===t.offsetHeight,document.body.removeChild(t)}return e}}(),a=0;Prism.hooks.add("complete",function(t){var r=t.element.parentNode,o=r&&r.getAttribute("data-line");r&&o&&/pre/i.test(r.nodeName)&&(clearTimeout(a),e(".line-highlight",r).forEach(function(e){e.parentNode.removeChild(e)}),n(r,o),a=setTimeout(i,1))}),addEventListener("hashchange",i)}}(); \ No newline at end of file From 1388256b465362241b960d160b5a4e828ddbe1fe Mon Sep 17 00:00:00 2001 From: Golmote Date: Tue, 18 Aug 2015 23:54:14 +0200 Subject: [PATCH 156/310] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3c97a681ef..3406859cf7 100644 --- a/README.md +++ b/README.md @@ -11,12 +11,12 @@ Why another syntax highlighter?: http://lea.verou.me/2012/07/introducing-prism-a Prism depends on community contributions to expand and cover a wider array of use cases. If you like it, considering giving back by sending a pull request. Here are a few tips: - Read the [documentation](http://prismjs.com/extending.html). Prism was designed to be extensible. -- Do not edit prism.js, it’s just the version of Prism used by the Prism website and is built automatically. Limit your changes to the unminified files in the components/ folder. The minified files are also generated automatically. -- Currently the build system building prism.js and the minified files is just a bunch of local settings in CodeKit. If someone wants to help export them to a config file, please contact me by opening an issue. +- Do not edit `prism.js`, it’s just the version of Prism used by the Prism website and is built automatically. Limit your changes to the unminified files in the components/ folder. The minified files are also generated automatically. +- The build system uses [gulp](https://github.com/gulpjs/gulp) to minify the files and build `prism.js`. Having gulp installed, you just need to run the command `gulp`. - Please follow the code conventions used in the files already. For example, I use [tabs for indentation and spaces for alignment](http://lea.verou.me/2012/01/why-tabs-are-clearly-superior/). Opening braces are on the same line, closing braces on their own line regardless of construct. There is a space before the opening brace. etc etc. - Please try to err towards more smaller PRs rather than few huge PRs. If a PR includes changes I want to merge and changes I don't, handling it becomes difficult. - My time is very limited these days, so it might take a long time to review longer PRs (short ones are usually merged very quickly), especially those modifying the Prism Core. This doesn't mean your PR is rejected. -- If you contribute a new language definition, you will be responsible for handling bug reports about that language definition. Soon I plan to add usernames of project owners for themes, plugins and language definitions so this becomes more clear to users. +- If you contribute a new language definition, you will be responsible for handling bug reports about that language definition. - If you add a new language definition, theme or plugin, you need to add it to `components.js` as well, so that it becomes available to the download build page. Thank you so much for contributing!! From 3fb26cc72e17632767ff7385dd70022edc06117c Mon Sep 17 00:00:00 2001 From: Golmote Date: Tue, 18 Aug 2015 23:58:50 +0200 Subject: [PATCH 157/310] Add tests for CSS --- .../!markup+css/markup+css_usage.test | 71 +++++++++++++++++++ tests/languages/css/atrule_feature.test | 47 ++++++++++++ tests/languages/css/comment_feature.test | 16 +++++ tests/languages/css/function_feature.test | 35 +++++++++ tests/languages/css/important_feature.test | 21 ++++++ tests/languages/css/property_feature.test | 24 +++++++ tests/languages/css/selector_feature.test | 25 +++++++ tests/languages/css/string_feature.test | 19 +++++ tests/languages/css/url_feature.test | 21 ++++++ 9 files changed, 279 insertions(+) create mode 100644 tests/languages/!markup+css/markup+css_usage.test create mode 100644 tests/languages/css/atrule_feature.test create mode 100644 tests/languages/css/comment_feature.test create mode 100644 tests/languages/css/function_feature.test create mode 100644 tests/languages/css/important_feature.test create mode 100644 tests/languages/css/property_feature.test create mode 100644 tests/languages/css/selector_feature.test create mode 100644 tests/languages/css/string_feature.test create mode 100644 tests/languages/css/url_feature.test diff --git a/tests/languages/!markup+css/markup+css_usage.test b/tests/languages/!markup+css/markup+css_usage.test new file mode 100644 index 0000000000..b606f11470 --- /dev/null +++ b/tests/languages/!markup+css/markup+css_usage.test @@ -0,0 +1,71 @@ + + + + +---------------------------------------------------- + +[ + ["style", [ + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "style" + ]], + ["attr-name", [ + "type" + ]], + ["attr-value", [ + ["punctuation", "="], + ["punctuation", "\""], + "text/css", + ["punctuation", "\""] + ]], + ["punctuation", ">"] + ]], + ["selector", "foo"], + ["punctuation", "{"], + ["property", "bar"], + ["punctuation", ":"], + " baz", + ["punctuation", ";"], + ["punctuation", "}"], + ["tag", [ + ["tag", [ + ["punctuation", ""] + ]] + ]], + + ["tag", [ + ["tag", [ + ["punctuation", "<"], + "foo" + ]], + ["style-attr", [ + ["attr-name", [ + ["attr-name", [ + "style" + ]] + ]], + ["punctuation", "=\""], + ["attr-value", [ + ["property", "bar"], + ["punctuation", ":"], + "baz", + ["punctuation", ";"] + ]], + ["punctuation", "\""] + ]], + ["punctuation", ">"] + ]] +] + +---------------------------------------------------- + +Checks for CSS usage inside Markup, using diff --git a/examples/prism-javascript.html b/examples/prism-javascript.html index 77a63d0f40..80ea29d64f 100644 --- a/examples/prism-javascript.html +++ b/examples/prism-javascript.html @@ -1,5 +1,9 @@

    JavaScript

    -

    To use this language, use the class "language-javascript".

    +

    To use this language, use one of the following classes:

    +
      +
    • "language-javascript"
    • +
    • "language-js"
    • +

    Variable assignment

    var foo = "bar", baz = 5;
    diff --git a/examples/prism-markup.html b/examples/prism-markup.html index 7709c025fd..c1f9d33861 100644 --- a/examples/prism-markup.html +++ b/examples/prism-markup.html @@ -1,5 +1,12 @@

    Markup

    -

    To use this language, use the class "language-markup".

    +

    To use this language, use one of the following classes:

    +
      +
    • "language-markup"
    • +
    • "language-xml"
    • +
    • "language-html"
    • +
    • "language-mathml"
    • +
    • "language-svg"
    • +

    Empty tag

    <p></p>
    diff --git a/prism.js b/prism.js index 90744ba909..b2e3c47a8d 100644 --- a/prism.js +++ b/prism.js @@ -484,6 +484,11 @@ Prism.hooks.add('wrap', function(env) { } }); +Prism.languages.xml = Prism.languages.markup; +Prism.languages.html = Prism.languages.markup; +Prism.languages.mathml = Prism.languages.markup; +Prism.languages.svg = Prism.languages.markup; + /* ********************************************** Begin prism-css.js @@ -628,6 +633,7 @@ if (Prism.languages.markup) { }); } +Prism.languages.js = Prism.languages.javascript; /* ********************************************** Begin prism-file-highlight.js From 071c3ddf767d3d30bc17e4ee0b27f3543eca7a15 Mon Sep 17 00:00:00 2001 From: Golmote Date: Fri, 4 Sep 2015 00:13:37 +0200 Subject: [PATCH 298/310] Merge branch 'c-fixes' of https://github.com/rygorous/prism into gh-pages Conflicts: components/prism-c.js components/prism-c.min.js components/prism-clike.js components/prism-clike.min.js + added tests --- components/prism-c.js | 2 +- components/prism-c.min.js | 2 +- components/prism-clike.js | 2 +- components/prism-clike.min.js | 2 +- prism.js | 2 +- tests/languages/c/number_feature.test | 35 +++++++++++++++++++++++ tests/languages/clike/number_feature.test | 2 ++ 7 files changed, 42 insertions(+), 5 deletions(-) diff --git a/components/prism-c.js b/components/prism-c.js index f65e54fd1d..de4e13f145 100644 --- a/components/prism-c.js +++ b/components/prism-c.js @@ -1,7 +1,7 @@ Prism.languages.c = Prism.languages.extend('clike', { 'keyword': /\b(asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/, 'operator': /\-[>-]?|\+\+?|!=?|<>?=?|==?|&&?|\|?\||[~^%?*\/]/, - 'number': /\b-?(0x[\da-f]+|\d*\.?\d+(e[+-]?\d+)?)[fFuUlL]*\b/i + 'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)[ful]*\b/i }); Prism.languages.insertBefore('c', 'string', { diff --git a/components/prism-c.min.js b/components/prism-c.min.js index b621206cb3..4392c5cfbc 100644 --- a/components/prism-c.min.js +++ b/components/prism-c.min.js @@ -1 +1 @@ -Prism.languages.c=Prism.languages.extend("clike",{keyword:/\b(asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/,operator:/\-[>-]?|\+\+?|!=?|<>?=?|==?|&&?|\|?\||[~^%?*\/]/,number:/\b-?(0x[\da-f]+|\d*\.?\d+(e[+-]?\d+)?)[fFuUlL]*\b/i}),Prism.languages.insertBefore("c","string",{macro:{pattern:/(^\s*)#\s*[a-z]+([^\r\n\\]|\\.|\\(?:\r\n?|\n))*/im,lookbehind:!0,alias:"property",inside:{string:{pattern:/(#\s*include\s*)(<.+?>|("|')(\\?.)+?\3)/,lookbehind:!0}}}}),delete Prism.languages.c["class-name"],delete Prism.languages.c["boolean"]; \ No newline at end of file +Prism.languages.c=Prism.languages.extend("clike",{keyword:/\b(asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)\b/,operator:/\-[>-]?|\+\+?|!=?|<>?=?|==?|&&?|\|?\||[~^%?*\/]/,number:/\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)[ful]*\b/i}),Prism.languages.insertBefore("c","string",{macro:{pattern:/(^\s*)#\s*[a-z]+([^\r\n\\]|\\.|\\(?:\r\n?|\n))*/im,lookbehind:!0,alias:"property",inside:{string:{pattern:/(#\s*include\s*)(<.+?>|("|')(\\?.)+?\3)/,lookbehind:!0}}}}),delete Prism.languages.c["class-name"],delete Prism.languages.c["boolean"]; \ No newline at end of file diff --git a/components/prism-clike.js b/components/prism-clike.js index 052089e3d5..5745341f7d 100644 --- a/components/prism-clike.js +++ b/components/prism-clike.js @@ -20,7 +20,7 @@ Prism.languages.clike = { 'keyword': /\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/, 'boolean': /\b(true|false)\b/, 'function': /[a-z0-9_]+(?=\()/i, - 'number': /\b-?(0x[\da-f]+|\d*\.?\d+(e[+-]?\d+)?)\b/i, + 'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i, 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/, 'punctuation': /[{}[\];(),.:]/ }; diff --git a/components/prism-clike.min.js b/components/prism-clike.min.js index 828c6e7694..b437bab33b 100644 --- a/components/prism-clike.min.js +++ b/components/prism-clike.min.js @@ -1 +1 @@ -Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:/("|')(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,"class-name":{pattern:/((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,"boolean":/\b(true|false)\b/,"function":/[a-z0-9_]+(?=\()/i,number:/\b-?(0x[\da-f]+|\d*\.?\d+(e[+-]?\d+)?)\b/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/}; \ No newline at end of file +Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:/("|')(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,"class-name":{pattern:/((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,"boolean":/\b(true|false)\b/,"function":/[a-z0-9_]+(?=\()/i,number:/\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/}; \ No newline at end of file diff --git a/prism.js b/prism.js index b2e3c47a8d..c5b3de6177 100644 --- a/prism.js +++ b/prism.js @@ -574,7 +574,7 @@ Prism.languages.clike = { 'keyword': /\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/, 'boolean': /\b(true|false)\b/, 'function': /[a-z0-9_]+(?=\()/i, - 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/, + 'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i, 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/, 'punctuation': /[{}[\];(),.:]/ }; diff --git a/tests/languages/c/number_feature.test b/tests/languages/c/number_feature.test index e69de29bb2..0542683404 100644 --- a/tests/languages/c/number_feature.test +++ b/tests/languages/c/number_feature.test @@ -0,0 +1,35 @@ +42 +3.14159 +4e10 +2.1e-10 +0.4e+2 +0xbabe +0xBABE +42f +42F +42u +42U +42l +42L + +---------------------------------------------------- + +[ + ["number", "42"], + ["number", "3.14159"], + ["number", "4e10"], + ["number", "2.1e-10"], + ["number", "0.4e+2"], + ["number", "0xbabe"], + ["number", "0xBABE"], + ["number", "42f"], + ["number", "42F"], + ["number", "42u"], + ["number", "42U"], + ["number", "42l"], + ["number", "42L"] +] + +---------------------------------------------------- + +Checks for decimal numbers and hexadecimal numbers. \ No newline at end of file diff --git a/tests/languages/clike/number_feature.test b/tests/languages/clike/number_feature.test index 002a5c92c2..f6bcc0b662 100644 --- a/tests/languages/clike/number_feature.test +++ b/tests/languages/clike/number_feature.test @@ -2,6 +2,7 @@ 3.14159 4e10 2.1e-10 +0.4e+2 0xbabe 0xBABE @@ -12,6 +13,7 @@ ["number", "3.14159"], ["number", "4e10"], ["number", "2.1e-10"], + ["number", "0.4e+2"], ["number", "0xbabe"], ["number", "0xBABE"] ] From b2f14d961e6e1c355f040a7a0932f58b06198863 Mon Sep 17 00:00:00 2001 From: Golmote Date: Fri, 4 Sep 2015 08:19:21 +0200 Subject: [PATCH 299/310] Merge branch 'plugin-jsonp' of https://github.com/nauzilus/prism into gh-pages Conflicts: components/prism-core.min.js --- components.js | 5 + components/prism-core.js | 3 +- components/prism-core.min.js | 2 +- plugins/jsonp-highlight/index.html | 174 ++++++++++++++++++ .../jsonp-highlight/prism-jsonp-highlight.js | 151 +++++++++++++++ .../prism-jsonp-highlight.min.js | 1 + prism.js | 3 +- 7 files changed, 336 insertions(+), 3 deletions(-) create mode 100644 plugins/jsonp-highlight/index.html create mode 100644 plugins/jsonp-highlight/prism-jsonp-highlight.js create mode 100644 plugins/jsonp-highlight/prism-jsonp-highlight.min.js diff --git a/components.js b/components.js index 01fd5f9f4a..43f1536061 100644 --- a/components.js +++ b/components.js @@ -375,6 +375,11 @@ var components = { "title": "Show Language", "owner": "nauzilus" }, + "jsonp-highlight": { + "title": "JSONP Highlight", + "noCSS": true, + "owner": "nauzilus" + }, "highlight-keywords": { "title": "Highlight Keywords", "owner": "vkbansal", diff --git a/components/prism-core.js b/components/prism-core.js index 8ee4050e83..3ab918da47 100644 --- a/components/prism-core.js +++ b/components/prism-core.js @@ -140,7 +140,8 @@ var _ = _self.Prism = { } } }, - + plugins: {}, + highlightAll: function(async, callback) { var elements = document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'); diff --git a/components/prism-core.min.js b/components/prism-core.min.js index d97d828467..842973b98f 100644 --- a/components/prism-core.min.js +++ b/components/prism-core.min.js @@ -1 +1 @@ -var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=_self.Prism={util:{encode:function(e){return e instanceof n?new n(e.type,t.util.encode(e.content),e.alias):"Array"===t.util.type(e)?e.map(t.util.encode):e.replace(/&/g,"&").replace(/e.length)break e;if(!(d instanceof a)){u.lastIndex=0;var m=u.exec(d);if(m){c&&(f=m[1].length);var y=m.index-1+f,m=m[0].slice(f),v=m.length,k=y+v,b=d.slice(0,y+1),w=d.slice(k+1),N=[p,1];b&&N.push(b);var O=new a(l,g?t.tokenize(m,g):m,h);N.push(O),w&&N.push(w),Array.prototype.splice.apply(r,N)}}}}}return r},hooks:{all:{},add:function(e,n){var a=t.hooks.all;a[e]=a[e]||[],a[e].push(n)},run:function(e,n){var a=t.hooks.all[e];if(a&&a.length)for(var r,i=0;r=a[i++];)r(n)}}},n=t.Token=function(e,t,n){this.type=e,this.content=t,this.alias=n};if(n.stringify=function(e,a,r){if("string"==typeof e)return e;if("Array"===t.util.type(e))return e.map(function(t){return n.stringify(t,a,e)}).join("");var i={type:e.type,content:n.stringify(e.content,a,r),tag:"span",classes:["token",e.type],attributes:{},language:a,parent:r};if("comment"==i.type&&(i.attributes.spellcheck="true"),e.alias){var l="Array"===t.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(i.classes,l)}t.hooks.run("wrap",i);var o="";for(var s in i.attributes)o+=(o?" ":"")+s+'="'+(i.attributes[s]||"")+'"';return"<"+i.tag+' class="'+i.classes.join(" ")+'" '+o+">"+i.content+""},!_self.document)return _self.addEventListener?(_self.addEventListener("message",function(e){var n=JSON.parse(e.data),a=n.language,r=n.code,i=n.immediateClose;_self.postMessage(JSON.stringify(t.util.encode(t.tokenize(r,t.languages[a])))),i&&_self.close()},!1),_self.Prism):_self.Prism;var a=document.getElementsByTagName("script");return a=a[a.length-1],a&&(t.filename=a.src,document.addEventListener&&!a.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)),_self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism),"undefined"!=typeof global&&(global.Prism=Prism); \ No newline at end of file +var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=_self.Prism={util:{encode:function(e){return e instanceof n?new n(e.type,t.util.encode(e.content),e.alias):"Array"===t.util.type(e)?e.map(t.util.encode):e.replace(/&/g,"&").replace(/e.length)break e;if(!(d instanceof a)){u.lastIndex=0;var m=u.exec(d);if(m){c&&(f=m[1].length);var y=m.index-1+f,m=m[0].slice(f),v=m.length,k=y+v,b=d.slice(0,y+1),w=d.slice(k+1),N=[p,1];b&&N.push(b);var O=new a(l,g?t.tokenize(m,g):m,h);N.push(O),w&&N.push(w),Array.prototype.splice.apply(r,N)}}}}}return r},hooks:{all:{},add:function(e,n){var a=t.hooks.all;a[e]=a[e]||[],a[e].push(n)},run:function(e,n){var a=t.hooks.all[e];if(a&&a.length)for(var r,i=0;r=a[i++];)r(n)}}},n=t.Token=function(e,t,n){this.type=e,this.content=t,this.alias=n};if(n.stringify=function(e,a,r){if("string"==typeof e)return e;if("Array"===t.util.type(e))return e.map(function(t){return n.stringify(t,a,e)}).join("");var i={type:e.type,content:n.stringify(e.content,a,r),tag:"span",classes:["token",e.type],attributes:{},language:a,parent:r};if("comment"==i.type&&(i.attributes.spellcheck="true"),e.alias){var l="Array"===t.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(i.classes,l)}t.hooks.run("wrap",i);var o="";for(var s in i.attributes)o+=(o?" ":"")+s+'="'+(i.attributes[s]||"")+'"';return"<"+i.tag+' class="'+i.classes.join(" ")+'" '+o+">"+i.content+""},!_self.document)return _self.addEventListener?(_self.addEventListener("message",function(e){var n=JSON.parse(e.data),a=n.language,r=n.code,i=n.immediateClose;_self.postMessage(JSON.stringify(t.util.encode(t.tokenize(r,t.languages[a])))),i&&_self.close()},!1),_self.Prism):_self.Prism;var a=document.getElementsByTagName("script");return a=a[a.length-1],a&&(t.filename=a.src,document.addEventListener&&!a.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)),_self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism),"undefined"!=typeof global&&(global.Prism=Prism); \ No newline at end of file diff --git a/plugins/jsonp-highlight/index.html b/plugins/jsonp-highlight/index.html new file mode 100644 index 0000000000..d70d375e80 --- /dev/null +++ b/plugins/jsonp-highlight/index.html @@ -0,0 +1,174 @@ + + + + + + +JSONP Highlight ▲ Prism plugins + + + + + + + + + + +
    +
    + +

    JSONP Highlight

    +

    Fetch content with JSONP and highlight some interesting content (e.g. GitHub/Gists or Bitbucket API).

    +
    + +
    +

    How to use

    + +

    Use the data-jsonp attribute on <pre> elements, like so:

    + +
    <pre
    +  class="language-javascript"
    +  data-jsonp="https://api.github.com/repos/leaverou/prism/contents/prism.js">
    +</pre>
    + +

    + Don't specifiy the callback query parameter in the URL; this will be added + automatically. If the API expects a different callback parameter name however, use the + data-callback parameter to specify the name: +

    + +
    <pre class="…" data-jsonp="…" data-callback="cb"></pre>
    + +

    + The next trick is of course actually extracting something from the JSONP response worth + highlighting, which means processing the response to extract the interesting data. +

    + +

    The following JSONP APIs are automatically detected and parsed:

    + + + +

    If you need to do your own parsing, you can hook your your own data adapters in two ways:

    +
      +
    1. + Supply the data-adapter parameter on the <pre> element. + This must be the name of a globally defined function. + The plugin will use only this adapter to parse the response. +
    2. +
    3. + Register your adapter function by calling + Prism.plugins.jsonphighlight.registerAdapter(function(rsp) { … }). + It will be added to the list of inbuilt adapters and used if no other registered + adapater (e.g. GitHub/Bitbucket) can parse the response. +
    4. +
    + +

    + In either case, the function must accept at least a single parameter (the JSONP response) and + returns a string of the content to highlight. If your adapter cannot parse the response, you + must return null. The DOM node that will contain the highlighted code will also + be passed in as the second argument, incase you need to use it to query any extra information + (maybe you wish to inspect the class or data-jsonp attributes to + assist in parsing the response). +

    + +

    + The following example demonstrates both methods of using a custom adapter, to simply return + the stringyfied JSONP response (i.e highlight the entire JSONP data): +

    + +
    <!-- perhaps this is in a .js file elsewhere -->
    +<script>
    +	function dump_json(rsp) {
    +		return "using dump_json: " + JSON.stringify(rsp,null,2);
    +	}
    +</script>
    +
    +<!-- … include prism.js … -->
    +<script>
    +	Prism.plugins.jsonphighlight.registerAdapter(function(rsp) {
    +		return "using registerAdapter: " + JSON.stringify(rsp,null,2);
    +	})
    +</script>
    +
    + +

    And later in your HTML:

    + +
    <!-- using the data-adapter attribute -->
    +<pre class="language-javascript" data-jsonp="…" data-adapter="dump_json"></pre>
    +
    +<!-- using whatever data adapters are available -->
    +<pre class="language-javascript" data-jsonp="…"></pre>
    +
    + +

    + Finally, unlike like the File Highlight + plugin, you do need to supply the appropriate class with the language + to highlight. This could have been auto-detected, but since you're not actually linking to + a file it's not always possible (see below in the example using GitHub status). + Furthermore, if you're linking to files with a .xaml extension for example, + this plugin then needs to somehow map that to highlight as markup, which just + means more bloat. You know what you're trying to highlight, just say so :) +

    + +

    Caveat for Gists

    + +

    + There's a bit of a catch with gists, as they can actually contain multiple files. + There are two options to handle this: +

    + +
      +
    1. + If your gist only contains one file, you don't need to to anything; the one and only + file will automatically be chosen and highlighted +
    2. +
    3. + If your file contains multiple files, the first one will be chosen by default. + However, you can supply the filename in the data-filename attribute, and + this file will be highlighted instead: +
      <pre class="…" data-jsonp="…" data-filename="mydemo.js"></pre>
      +
    4. +
    +
    + +
    +

    Examples

    + +

    The plugin’s JS code (from GitHub):

    +
    
    +
    +	

    GitHub Gist (gist contains a single file, automatically selected):

    +
    
    +
    +	

    GitHub Gist (gist contains a multiple files, file to load specified):

    +
    
    +
    + 	

    Bitbucket API:

    +
    
    + 	
    + 	

    Custom adapter (JSON.stringify showing GitHub status):

    +
    
    +
    +	

    Registered adapter (as above, but without explicitly declaring the data-adapter attribute):

    +
    
    +
    + +
    + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/jsonp-highlight/prism-jsonp-highlight.js b/plugins/jsonp-highlight/prism-jsonp-highlight.js new file mode 100644 index 0000000000..06a9e68c09 --- /dev/null +++ b/plugins/jsonp-highlight/prism-jsonp-highlight.js @@ -0,0 +1,151 @@ +(function() { + if ( !self.Prism || !self.document || !document.querySelectorAll ) return; + + var adapters = []; + function registerAdapter(adapter) { + if (typeof adapter === "function" && !getAdapter(adapter)) { + adapters.push(adapter); + } + } + function getAdapter(adapter) { + if (typeof adapter === "function") { + return adapters.filter(function(fn) { return fn.valueOf() === adapter.valueOf()})[0]; + } + else if (typeof adapter === "string" && adapter.length > 0) { + return adapters.filter(function(fn) { return fn.name === adapter})[0]; + } + return null; + } + function removeAdapter(adapter) { + if (typeof adapter === "string") + adapter = getAdapter(adapter); + if (typeof adapter === "function") { + var index = adapters.indexOf(adapter); + if (index >=0) { + adapters.splice(index,1); + } + } + } + + Prism.plugins.jsonphighlight = { + registerAdapter: registerAdapter, + removeAdapter: removeAdapter, + highlight: highlight + }; + registerAdapter(function github(rsp, el) { + if ( rsp && rsp.meta && rsp.data ) { + if ( rsp.meta.status && rsp.meta.status >= 400 ) { + return "Error: " + ( rsp.data.message || rsp.meta.status ); + } + else if ( typeof(rsp.data.content) === "string" ) { + return typeof(atob) === "function" + ? atob(rsp.data.content.replace(/\s/g, "")) + : "Your browser cannot decode base64"; + } + } + return null; + }); + registerAdapter(function gist(rsp, el) { + if ( rsp && rsp.meta && rsp.data && rsp.data.files ) { + if ( rsp.meta.status && rsp.meta.status >= 400 ) { + return "Error: " + ( rsp.data.message || rsp.meta.status ); + } + else { + var filename = el.getAttribute("data-filename"); + if (filename == null) { + // Maybe in the future we can somehow render all files + // But the standard