Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for CFScript #2771

Merged
merged 11 commits into from Feb 19, 2021
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions components.json
Expand Up @@ -238,6 +238,12 @@
"require": "c",
"owner": "zeitgeist87"
},
"cfscript": {
"title": "CFScript",
"require": "clike",
"alias": "cfc",
"owner": "mjclemente"
},
"chaiscript": {
"title": "ChaiScript",
"require": ["clike", "cpp"],
Expand Down
44 changes: 44 additions & 0 deletions components/prism-cfscript.js
@@ -0,0 +1,44 @@
// https://cfdocs.org/script
Prism.languages.cfscript = Prism.languages.extend('clike', {
'comment': [
{
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
lookbehind: true,
inside: {
'annotation': {
pattern: /(?:^|[^.])@[\w\.]+/,
alias: 'punctuation'
}
}
},
{
pattern: /(^|[^\\:])\/\/.*/,
lookbehind: true,
greedy: true
}
],
'keyword': /\b(?:abstract|break|catch|component|continue|default|do|else|extends|final|finally|for|function|if|in|include|package|private|property|public|remote|required|rethrow|return|static|switch|throw|try|var|while|xml)\b(?!\s*\=)/,
'operator': [
/\+\+|--|&&|\|\||::|=>|[!=]==|<=?|>=?|[-+*/%&|^!=<>]=?|\?(?:\.|:)?|[?:]/,
/\b(?:and|contains|eq|equal|eqv|gt|gte|imp|is|lt|lte|mod|not|or|xor)\b/
],
'scope': {
pattern: /\b(?:application|arguments|cgi|client|cookie|local|session|super|this|variables)\b/,
alias: 'global'
},
'type': {
pattern: /\b(?:any|array|binary|boolean|date|guid|numeric|query|string|struct|uuid|void|xml)\b/,
alias: 'builtin'
}
});

Prism.languages.insertBefore('cfscript', 'keyword', {
// This must be declared before keyword because we use "function" inside the lookahead
'function-variable': {
mjclemente marked this conversation as resolved.
Show resolved Hide resolved
pattern: /[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
alias: 'function'
}
});

delete Prism.languages.cfscript['class-name'];
Prism.languages.cfc = Prism.languages['cfscript'];
1 change: 1 addition & 0 deletions components/prism-cfscript.min.js

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

43 changes: 43 additions & 0 deletions examples/prism-cfscript.html
@@ -0,0 +1,43 @@
<h2>Comments</h2>
<pre><code>// This is a comment

/* This is a comment
on multiple lines */

/**
* This is a Javadoc style comment
*
* @hint This is an annotation
*/
</code></pre>

<h2>Functions</h2>
<pre><code>public boolean function myFunc(required any arg) {
return true;
}</code></pre>

<h2>Full example</h2>
<pre><code>component accessors="true" {
property type="string" name="prop1" default="";
property string prop2;
function init(){
this.prop3 = 12;
return this;
}

/**
* @hint Annotations supported
* @foo.hint
*/
public any function build( required foo, color="blue", boolean bar=true ){
arguments.foo = {
'name' : "something",
test = true
}
var foobar = function( required string baz, x=true, y=false ){
return "bar!";
};
return foo;
}
}
</code></pre>
2 changes: 2 additions & 0 deletions plugins/autoloader/prism-autoloader.js
Expand Up @@ -25,6 +25,7 @@
"c": "clike",
"csharp": "clike",
"cpp": "c",
"cfscript": "clike",
"chaiscript": [
"clike",
"cpp"
Expand Down Expand Up @@ -173,6 +174,7 @@
"oscript": "bsl",
"cs": "csharp",
"dotnet": "csharp",
"cfc": "cfscript",
"coffee": "coffeescript",
"conc": "concurnas",
"jinja2": "django",
Expand Down
2 changes: 1 addition & 1 deletion plugins/autoloader/prism-autoloader.min.js

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

2 changes: 2 additions & 0 deletions plugins/show-language/prism-show-language.js
Expand Up @@ -47,6 +47,8 @@
"cs": "C#",
"dotnet": "C#",
"cpp": "C++",
"cfscript": "CFScript",
"cfc": "CFScript",
"cil": "CIL",
"cmake": "CMake",
"coffee": "CoffeeScript",
Expand Down