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:/
-
+
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:/
+
+
+
+
+
+
+
+
+
+ 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:
+
+ - Your language snippet. The code you want to compile using Prism. (required)
+ - The simplified token stream you expect. Needs to be valid JSON. (required)
+ - A comment explaining the test case. (optional)
+
+ 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:
+
+ - Run all internal tests (test the test runner).
+ - Find all language tests.
+ - Run all language tests individually.
+ - Report the results.
+
+
+
+
+
+
+
+
+
+
+
+
+