Skip to content

Commit

Permalink
Merge branch 'master' into uri
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed Jan 24, 2021
2 parents 462d2a0 + b37987d commit 3138cee
Show file tree
Hide file tree
Showing 49 changed files with 1,526 additions and 104 deletions.
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@
"require": "c",
"owner": "zeitgeist87"
},
"chaiscript": {
"title": "ChaiScript",
"require": ["clike", "cpp"],
"owner": "RunDevelopment"
},
"cil": {
"title": "CIL",
"owner": "sbrl"
Expand Down Expand Up @@ -322,6 +327,12 @@
"alias": "dockerfile",
"owner": "JustinBeckwith"
},
"dot": {
"title": "DOT (Graphviz)",
"alias": "gv",
"optional": "markup",
"owner": "RunDevelopment"
},
"ebnf": {
"title": "EBNF",
"owner": "RunDevelopment"
Expand Down
60 changes: 60 additions & 0 deletions components/prism-chaiscript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Prism.languages.chaiscript = Prism.languages.extend('clike', {
'string': {
pattern: /(^|[^\\])'(?:[^'\\]|\\[\s\S])*'/,
lookbehind: true,
greedy: true
},
'class-name': [
{
// e.g. class Rectangle { ... }
pattern: /(\bclass\s+)\w+/,
lookbehind: true
},
{
// e.g. attr Rectangle::height, def Rectangle::area() { ... }
pattern: /(\b(?:attr|def)\s+)\w+(?=\s*::)/,
lookbehind: true
}
],
'keyword': /\b(?:attr|auto|break|case|catch|class|continue|def|default|else|finally|for|fun|global|if|return|switch|this|try|var|while)\b/,
'number': [
Prism.languages.cpp.number,
/\b(?:Infinity|NaN)\b/
],
'operator': />>=?|<<=?|\|\||&&|:[:=]?|--|\+\+|[=!<>+\-*/%|&^]=?|[?~]|`[^`\r\n]{1,4}`/,
});

Prism.languages.insertBefore('chaiscript', 'operator', {
'parameter-type': {
// e.g. def foo(int x, Vector y) {...}
pattern: /([,(]\s*)\w+(?=\s+\w)/,
lookbehind: true,
alias: 'class-name'
},
});

Prism.languages.insertBefore('chaiscript', 'string', {
'string-interpolation': {
pattern: /(^|[^\\])"(?:[^"$\\]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*\})*"/,
lookbehind: true,
greedy: true,
inside: {
'interpolation': {
pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*\}/,
lookbehind: true,
inside: {
'interpolation-expression': {
pattern: /(^\$\{)[\s\S]+(?=\}$)/,
lookbehind: true,
inside: Prism.languages.chaiscript
},
'interpolation-punctuation': {
pattern: /^\$\{|\}$/,
alias: 'punctuation'
}
}
},
'string': /[\s\S]+/
}
},
});
1 change: 1 addition & 0 deletions components/prism-chaiscript.min.js

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

12 changes: 10 additions & 2 deletions components/prism-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -984,10 +984,18 @@ function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
if (removeCount > 1) {
// at least one Token object was removed, so we have to do some rematching
// this can only happen if the current pattern is greedy
matchGrammar(text, tokenList, grammar, currentNode.prev, pos, {

/** @type {RematchOptions} */
var nestedRematch = {
cause: token + ',' + j,
reach: reach
});
};
matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch);

// the reach might have been extended because of the rematching
if (rematch && nestedRematch.reach > rematch.reach) {
rematch.reach = nestedRematch.reach;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/prism-core.min.js

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

77 changes: 77 additions & 0 deletions components/prism-dot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// https://www.graphviz.org/doc/info/lang.html

(function (Prism) {

var ID = '(?:' + [
// an identifier
/[a-zA-Z_\x80-\uFFFF][\w\x80-\uFFFF]*/.source,
// a number
/-?(?:\.\d+|\d+(?:\.\d*)?)/.source,
// a double-quoted string
/"[^"\\]*(?:\\[\s\S][^"\\]*)*"/.source,
// HTML-like string
/<(?:[^<>]|(?!<!--)<(?:[^<>"']|"[^"]*"|'[^']*')+>|<!--(?:[^-]|-(?!->))*-->)*>/.source
].join('|') + ')';

var IDInside = {
'markup': {
pattern: /(^<)[\s\S]+(?=>$)/,
lookbehind: true,
alias: ['language-markup', 'language-html', 'language-xml'],
inside: Prism.languages.markup
}
};

/**
* @param {string} source
* @param {string} flags
* @returns {RegExp}
*/
function withID(source, flags) {
return RegExp(source.replace(/<ID>/g, function () { return ID; }), flags);
}

Prism.languages.dot = {
'comment': {
pattern: /\/\/.*|\/\*[\s\S]*?\*\/|^#.*/m,
greedy: true
},
'graph-name': {
pattern: withID(/(\b(?:digraph|graph|subgraph)[ \t\r\n]+)<ID>/.source, 'i'),
lookbehind: true,
greedy: true,
alias: 'class-name',
inside: IDInside
},
'attr-value': {
pattern: withID(/(=[ \t\r\n]*)<ID>/.source),
lookbehind: true,
greedy: true,
inside: IDInside
},
'attr-name': {
pattern: withID(/([\[;, \t\r\n])<ID>(?=[ \t\r\n]*=)/.source),
lookbehind: true,
greedy: true,
inside: IDInside
},
'keyword': /\b(?:digraph|edge|graph|node|strict|subgraph)\b/i,
'compass-point': {
pattern: /(:[ \t\r\n]*)(?:[ns][ew]?|[ewc_])(?![\w\x80-\uFFFF])/,
lookbehind: true,
alias: 'builtin'
},
'node': {
pattern: withID(/(^|[^-.\w\x80-\uFFFF\\])<ID>/.source),
lookbehind: true,
greedy: true,
inside: IDInside
},
'operator': /[=:]|-[->]/,
'punctuation': /[\[\]{};,]/
};

Prism.languages.gv = Prism.languages.dot;

}(Prism));

Loading

0 comments on commit 3138cee

Please sign in to comment.