Skip to content

Commit

Permalink
Merge branch 'master' into issue2744
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed Sep 12, 2021
2 parents b617554 + 148c1ec commit b03a56f
Show file tree
Hide file tree
Showing 57 changed files with 4,175 additions and 15 deletions.
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion components.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@
"title": "AutoIt",
"owner": "Golmote"
},
"avro-idl": {
"title":"Avro IDL",
"alias": "avdl",
"owner": "RunDevelopment"
},
"bash": {
"title": "Bash",
"alias": "shell",
Expand Down Expand Up @@ -470,6 +475,11 @@
"require": "c",
"owner": "Golmote"
},
"gn": {
"title": "GN",
"alias": "gni",
"owner": "RunDevelopment"
},
"go": {
"title": "Go",
"require": "clike",
Expand Down Expand Up @@ -797,6 +807,10 @@
"title": "MEL",
"owner": "Golmote"
},
"mermaid": {
"title": "Mermaid",
"owner": "RunDevelopment"
},
"mizar": {
"title": "Mizar",
"owner": "Golmote"
Expand Down Expand Up @@ -1227,6 +1241,10 @@
"title": "Swift",
"owner": "chrischares"
},
"systemd": {
"title": "Systemd configuration file",
"owner": "RunDevelopment"
},
"t4-templating": {
"title": "T4 templating",
"owner": "RunDevelopment"
Expand Down Expand Up @@ -1464,7 +1482,7 @@
},
"highlight-keywords": {
"title": "Highlight Keywords",
"description": "Adds special CSS classes for each keyword matched in the code. For example, the keyword <code>if</code> will have the class <code>keyword-if</code> as well. You can have fine grained control over the appearance of each keyword by providing your own CSS rules.",
"description": "Adds special CSS classes for each keyword for fine-grained highlighting.",
"owner": "vkbansal",
"noCSS": true
},
Expand Down
57 changes: 57 additions & 0 deletions components/prism-avro-idl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// GitHub: https://github.com/apache/avro
// Docs: https://avro.apache.org/docs/current/idl.html

Prism.languages['avro-idl'] = {
'comment': {
pattern: /\/\/.*|\/\*[\s\S]*?\*\//,
greedy: true
},
'string': [
{
pattern: /(^|[^\\])"(?:[^\r\n"\\]|\\.)*"/,
lookbehind: true,
greedy: true
},
{
pattern: /(^|[^\\])'(?:[^\r\n'\\]|\\(?:[\s\S]|\d{1,3}))'/,
lookbehind: true,
greedy: true
}
],

'annotation': {
pattern: /@(?:[$\w.-]|`[^\r\n`]+`)+/,
greedy: true,
alias: 'function'
},
'function-identifier': {
pattern: /`[^\r\n`]+`(?=\s*\()/,
greedy: true,
alias: 'function'
},
'identifier': {
pattern: /`[^\r\n`]+`/,
greedy: true
},

'class-name': {
pattern: /(\b(?:enum|error|protocol|record|throws)\b\s+)[$\w]+/,
lookbehind: true,
greedy: true
},
'keyword': /\b(?:array|boolean|bytes|date|decimal|double|enum|error|false|fixed|float|idl|import|int|local_timestamp_ms|long|map|null|oneway|protocol|record|schema|string|throws|time_ms|timestamp_ms|true|union|uuid|void)\b/,
'function': /\b[a-z_]\w*(?=\s*\()/i,

'number': [
{
pattern: /(^|[^\w.])-?(?:(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|0x(?:[a-f0-9]+(?:\.[a-f0-9]*)?|\.[a-f0-9]+)(?:p[+-]?\d+)?)[dfl]?(?![\w.])/i,
lookbehind: true
},
/-?\b(?:NaN|Infinity)\b/
],

'operator': /=/,
'punctuation': /[()\[\]{}<>.:,;-]/
};

Prism.languages.avdl = Prism.languages['avro-idl'];
1 change: 1 addition & 0 deletions components/prism-avro-idl.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/prism-cpp.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@

Prism.languages.insertBefore('cpp', 'keyword', {
'generic-function': {
pattern: /\b[a-z_]\w*\s*<(?:[^<>]|<(?:[^<>])*>)*>(?=\s*\()/i,
pattern: /\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,
inside: {
'function': /^\w+/,
'generic': {
Expand Down
2 changes: 1 addition & 1 deletion components/prism-cpp.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions components/prism-gn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// https://gn.googlesource.com/gn/+/refs/heads/main/docs/reference.md#grammar

Prism.languages.gn = {
'comment': {
pattern: /#.*/,
greedy: true
},
'string-literal': {
pattern: /(^|[^\\"])"(?:[^\r\n"\\]|\\.)*"/,
lookbehind: true,
greedy: true,
inside: {
'interpolation': {
pattern: /((?:^|[^\\])(?:\\{2})*)\$(?:\{[\s\S]*?\}|[a-zA-Z_]\w*|0x[a-fA-F0-9]{2})/,
lookbehind: true,
inside: {
'number': /^\$0x[\s\S]{2}$/,
'variable': /^\$\w+$/,
'interpolation-punctuation': {
pattern: /^\$\{|\}$/,
alias: 'punctuation'
},
'expression': {
pattern: /[\s\S]+/,
inside: null // see below
}
}
},
'string': /[\s\S]+/
}
},

'keyword': /\b(?:else|if)\b/,
'boolean': /\b(?:true|false)\b/,
'builtin-function': {
// a few functions get special highlighting to improve readability
pattern: /\b(?:assert|defined|foreach|import|pool|print|template|tool|toolchain)(?=\s*\()/i,
alias: 'keyword'
},
'function': /\b[a-z_]\w*(?=\s*\()/i,
'constant': /\b(?:current_cpu|current_os|current_toolchain|default_toolchain|host_cpu|host_os|root_build_dir|root_gen_dir|root_out_dir|target_cpu|target_gen_dir|target_out_dir|target_os)\b/,

'number': /-?\b\d+\b/,

'operator': /[-+!=<>]=?|&&|\|\|/,
'punctuation': /[(){}[\],.]/
};

Prism.languages.gn['string-literal'].inside['interpolation'].inside['expression'].inside = Prism.languages.gn;

Prism.languages.gni = Prism.languages.gn;
1 change: 1 addition & 0 deletions components/prism-gn.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

113 changes: 113 additions & 0 deletions components/prism-mermaid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
Prism.languages.mermaid = {
'comment': {
pattern: /%%.*/,
greedy: true
},

'style': {
pattern: /^([ \t]*(?:classDef|linkStyle|style)[ \t]+[\w$-]+[ \t]+)\w.*[^\s;]/m,
lookbehind: true,
inside: {
'property': /\b\w[\w-]*(?=[ \t]*:)/,
'operator': /:/,
'punctuation': /,/
}
},

'inter-arrow-label': {
pattern: /([^<>ox.=-])(?:-[-.]|==)(?![<>ox.=-])[ \t]*(?:"[^"\r\n]*"|[^\s".=-](?:[^\r\n.=-]*[^\s.=-])?)[ \t]*(?:\.+->?|--+[->]|==+[=>])(?![<>ox.=-])/,
lookbehind: true,
greedy: true,
inside: {
'arrow': {
pattern: /(?:\.+->?|--+[->]|==+[=>])$/,
alias: 'operator'
},
'label': {
pattern: /^([\s\S]{2}[ \t]*)\S(?:[\s\S]*\S)?/,
lookbehind: true,
alias: 'property'
},
'arrow-head': {
pattern: /^\S+/,
alias: ['arrow', 'operator']
}
}
},

'arrow': [
// This might look complex but it really isn't.
// There are many possible arrows (see tests) and it's impossible to fit all of them into one pattern. The
// problem is that we only have one lookbehind per pattern. However, we cannot disallow too many arrow
// characters in the one lookbehind because that would create too many false negatives. So we have to split the
// arrows into different patterns.
{
// ER diagram
pattern: /(^|[^{}|o.-])[|}][|o](?:--|\.\.)[|o][|{](?![{}|o.-])/,
lookbehind: true,
alias: 'operator'
},
{
// flow chart
// (?:==+|--+|-\.*-)
pattern: /(^|[^<>ox.=-])(?:[<ox](?:==+|--+|-\.*-)[>ox]?|(?:==+|--+|-\.*-)[>ox]|===+|---+|-\.+-)(?![<>ox.=-])/,
lookbehind: true,
alias: 'operator'
},
{
// sequence diagram
pattern: /(^|[^<>()x-])(?:--?(?:>>|[x>)])(?![<>()x])|(?:<<|[x<(])--?(?!-))/,
lookbehind: true,
alias: 'operator'
},
{
// class diagram
pattern: /(^|[^<>|*o.-])(?:[*o]--|--[*o]|<\|?(?:--|\.\.)|(?:--|\.\.)\|?>|--|\.\.)(?![<>|*o.-])/,
lookbehind: true,
alias: 'operator'
},
],

'label': {
pattern: /(^|[^|<])\|(?:[^\r\n"|]|"[^"\r\n]*")+\|/,
lookbehind: true,
greedy: true,
alias: 'property'
},

'text': {
pattern: /(?:[(\[{]+|\b>)(?:[^\r\n"()\[\]{}]|"[^"\r\n]*")+(?:[)\]}]+|>)/,
alias: 'string'
},
'string': {
pattern: /"[^"\r\n]*"/,
greedy: true
},

'annotation': {
pattern: /<<(?:abstract|choice|enumeration|fork|interface|join|service)>>|\[\[(?:choice|fork|join)\]\]/i,
alias: 'important'
},

'keyword': [
// This language has both case-sensitive and case-insensitive keywords
{
pattern: /(^[ \t]*)(?:action|callback|class|classDef|classDiagram|click|direction|erDiagram|flowchart|gantt|gitGraph|graph|journey|link|linkStyle|pie|requirementDiagram|sequenceDiagram|stateDiagram|stateDiagram-v2|style|subgraph)(?![\w$-])/m,
lookbehind: true,
greedy: true
},
{
pattern: /(^[ \t]*)(?:activate|alt|and|as|autonumber|deactivate|else|end(?:[ \t]+note)?|loop|opt|par|participant|rect|state|note[ \t]+(?:over|(?:left|right)[ \t]+of))(?![\w$-])/im,
lookbehind: true,
greedy: true
}
],

'entity': /#[a-z0-9]+;/,

'operator': {
pattern: /(\w[ \t]*)&(?=[ \t]*\w)|:::|:/,
lookbehind: true
},
'punctuation': /[(){};]/
};
1 change: 1 addition & 0 deletions components/prism-mermaid.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 14 additions & 3 deletions components/prism-shell-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,22 @@
'command': {
pattern: RegExp(
// user info
/^(?:[^\s@:$#%*!/\\]+@[^\r\n@:$#%*!/\\]+(?::[^\0-\x1F$#%*?"<>:;|]+)?|[^\0-\x1F$#%*?"<>@:;|]+)?/.source +
/^/.source +
'(?:' +
(
// <user> ":" ( <path> )?
/[^\s@:$#%*!/\\]+@[^\r\n@:$#%*!/\\]+(?::[^\0-\x1F$#%*?"<>:;|]+)?/.source +
'|' +
// <path>
// Since the path pattern is quite general, we will require it to start with a special character to
// prevent false positives.
/[/~.][^\0-\x1F$#%*?"<>@:;|]*/.source
) +
')?' +
// shell symbol
/[$#%]/.source +
/[$#%](?=\s)/.source +
// bash command
/(?:[^\\\r\n'"<$]|\\(?:[^\r]|\r\n?)|\$(?!')|<<str>>)+/.source.replace(/<<str>>/g, function () { return strings; }),
/(?:[^\\\r\n \t'"<$]|[ \t](?:(?!#)|#.*$)|\\(?:[^\r]|\r\n?)|\$(?!')|<(?!<)|<<str>>)+/.source.replace(/<<str>>/g, function () { return strings; }),
'm'
),
greedy: true,
Expand Down
2 changes: 1 addition & 1 deletion components/prism-shell-session.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b03a56f

Please sign in to comment.