Skip to content

Commit b0a6ec8

Browse files
authored
Added support for CFScript (#2771)
1 parent f79b0ee commit b0a6ec8

15 files changed

+467
-3
lines changed

components.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components.json

+6
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,12 @@
238238
"require": "c",
239239
"owner": "zeitgeist87"
240240
},
241+
"cfscript": {
242+
"title": "CFScript",
243+
"require": "clike",
244+
"alias": "cfc",
245+
"owner": "mjclemente"
246+
},
241247
"chaiscript": {
242248
"title": "ChaiScript",
243249
"require": ["clike", "cpp"],

components/prism-cfscript.js

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// https://cfdocs.org/script
2+
Prism.languages.cfscript = Prism.languages.extend('clike', {
3+
'comment': [
4+
{
5+
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
6+
lookbehind: true,
7+
inside: {
8+
'annotation': {
9+
pattern: /(?:^|[^.])@[\w\.]+/,
10+
alias: 'punctuation'
11+
}
12+
}
13+
},
14+
{
15+
pattern: /(^|[^\\:])\/\/.*/,
16+
lookbehind: true,
17+
greedy: true
18+
}
19+
],
20+
'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*\=)/,
21+
'operator': [
22+
/\+\+|--|&&|\|\||::|=>|[!=]==|<=?|>=?|[-+*/%&|^!=<>]=?|\?(?:\.|:)?|[?:]/,
23+
/\b(?:and|contains|eq|equal|eqv|gt|gte|imp|is|lt|lte|mod|not|or|xor)\b/
24+
],
25+
'scope': {
26+
pattern: /\b(?:application|arguments|cgi|client|cookie|local|session|super|this|variables)\b/,
27+
alias: 'global'
28+
},
29+
'type': {
30+
pattern: /\b(?:any|array|binary|boolean|date|guid|numeric|query|string|struct|uuid|void|xml)\b/,
31+
alias: 'builtin'
32+
}
33+
});
34+
35+
Prism.languages.insertBefore('cfscript', 'keyword', {
36+
// This must be declared before keyword because we use "function" inside the lookahead
37+
'function-variable': {
38+
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*=>))/,
39+
alias: 'function'
40+
}
41+
});
42+
43+
delete Prism.languages.cfscript['class-name'];
44+
Prism.languages.cfc = Prism.languages['cfscript'];

components/prism-cfscript.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/prism-cfscript.html

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<h2>Comments</h2>
2+
<pre><code>// This is a comment
3+
4+
/* This is a comment
5+
on multiple lines */
6+
7+
/**
8+
* This is a Javadoc style comment
9+
*
10+
* @hint This is an annotation
11+
*/
12+
</code></pre>
13+
14+
<h2>Functions</h2>
15+
<pre><code>public boolean function myFunc(required any arg) {
16+
return true;
17+
}</code></pre>
18+
19+
<h2>Full example</h2>
20+
<pre><code>component accessors="true" {
21+
property type="string" name="prop1" default="";
22+
property string prop2;
23+
function init(){
24+
this.prop3 = 12;
25+
return this;
26+
}
27+
28+
/**
29+
* @hint Annotations supported
30+
* @foo.hint
31+
*/
32+
public any function build( required foo, color="blue", boolean bar=true ){
33+
arguments.foo = {
34+
'name' : "something",
35+
test = true
36+
}
37+
var foobar = function( required string baz, x=true, y=false ){
38+
return "bar!";
39+
};
40+
return foo;
41+
}
42+
}
43+
</code></pre>

plugins/autoloader/prism-autoloader.js

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"c": "clike",
2626
"csharp": "clike",
2727
"cpp": "c",
28+
"cfscript": "clike",
2829
"chaiscript": [
2930
"clike",
3031
"cpp"
@@ -173,6 +174,7 @@
173174
"oscript": "bsl",
174175
"cs": "csharp",
175176
"dotnet": "csharp",
177+
"cfc": "cfscript",
176178
"coffee": "coffeescript",
177179
"conc": "concurnas",
178180
"jinja2": "django",

plugins/autoloader/prism-autoloader.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/show-language/prism-show-language.js

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
"cs": "C#",
4848
"dotnet": "C#",
4949
"cpp": "C++",
50+
"cfscript": "CFScript",
51+
"cfc": "CFScript",
5052
"cil": "CIL",
5153
"cmake": "CMake",
5254
"coffee": "CoffeeScript",

0 commit comments

Comments
 (0)