@salesforcedevs/dx-components 0.63.0-alpha.0 → 0.63.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +12 -0
- package/package.json +3 -2
- package/src/modules/dx/codeBlock/codeBlock.ts +0 -13
- package/src/modules/dx/dropdownOption/dropdownOption.ts +1 -1
- package/src/modules/dx/sidebarSearch/sidebarSearch.ts +5 -1
- package/src/modules/dxUtils/codeLanguageDetector/codeLanguageDetector.ts +0 -81
- package/src/modules/dxUtils/codeLanguageDetector/languageList.ts +0 -345
package/LICENSE
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Copyright (c) 2020, Salesforce.com, Inc.
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
5
|
+
|
|
6
|
+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
7
|
+
|
|
8
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
9
|
+
|
|
10
|
+
* Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
11
|
+
|
|
12
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dx-components",
|
|
3
|
-
"version": "0.63.
|
|
3
|
+
"version": "0.63.2",
|
|
4
4
|
"description": "DX Lightning web components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -24,5 +24,6 @@
|
|
|
24
24
|
"@types/debounce": "^1.2.0",
|
|
25
25
|
"@types/lodash.get": "^4.4.6",
|
|
26
26
|
"@types/vimeo__player": "^2.16.2"
|
|
27
|
-
}
|
|
27
|
+
},
|
|
28
|
+
"gitHead": "4e885b33ab4f17d2e7f4a083d9be2f90e8ba6363"
|
|
28
29
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { LightningElement, api, wire, track } from "lwc";
|
|
2
2
|
import { CodeBlockTheme, CodeBlockLanguage } from "typings/custom";
|
|
3
3
|
import cx from "classnames";
|
|
4
|
-
import { detect } from "dxUtils/codeLanguageDetector";
|
|
5
4
|
import Prism from "dxUtils/prismjs";
|
|
6
5
|
import {
|
|
7
6
|
getLocalStorageData,
|
|
@@ -213,18 +212,6 @@ export default class CodeBlock extends LightningElement {
|
|
|
213
212
|
) || this.allLanguages[0];
|
|
214
213
|
this.selectedLanguageLabel = this.selectedLanguage.label;
|
|
215
214
|
this.selectedLanguageId = this.selectedLanguage.id;
|
|
216
|
-
|
|
217
|
-
// Auto detect code language if it isn't specified
|
|
218
|
-
if (!this.language) {
|
|
219
|
-
const detectedLanguage = detect(this.codeBlock);
|
|
220
|
-
this.selectedLanguage = {
|
|
221
|
-
label: detectedLanguage,
|
|
222
|
-
id: detectedLanguage.toLowerCase()
|
|
223
|
-
};
|
|
224
|
-
this.selectedLanguageLabel = detectedLanguage;
|
|
225
|
-
this.selectedLanguageId = detectedLanguage.toLowerCase();
|
|
226
|
-
}
|
|
227
|
-
|
|
228
215
|
this.formatCodeBlock();
|
|
229
216
|
this._codeBlockRendered = true;
|
|
230
217
|
}
|
|
@@ -47,7 +47,6 @@ export default class DropdownOption extends LightningElement {
|
|
|
47
47
|
...this.analyticsBasePayload,
|
|
48
48
|
clickText: this.keyValue || undefined,
|
|
49
49
|
itemTitle: this.option.label || undefined,
|
|
50
|
-
pageLocation: window.location.pathname,
|
|
51
50
|
clickUrl: this.option.link?.href || undefined
|
|
52
51
|
};
|
|
53
52
|
|
|
@@ -58,6 +57,7 @@ export default class DropdownOption extends LightningElement {
|
|
|
58
57
|
if (!this.suppressGtmNavHeadings) {
|
|
59
58
|
payload.navHeading = navHeading;
|
|
60
59
|
payload.navSubHeading = navSubHeading;
|
|
60
|
+
payload.pageLocation = window.location.pathname;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
if (this.analyticsEvent && e.currentTarget) {
|
|
@@ -310,7 +310,11 @@ export default class SidebarSearch extends LightningElement {
|
|
|
310
310
|
let isSelected = false;
|
|
311
311
|
const isReferenceUrl = clickUri.includes("/references/");
|
|
312
312
|
if (isReferenceUrl) {
|
|
313
|
-
|
|
313
|
+
if (queryParam) {
|
|
314
|
+
href = `${pathname}${queryParam}&q=${this.value}`;
|
|
315
|
+
} else {
|
|
316
|
+
href = `${pathname}?q=${this.value}`;
|
|
317
|
+
}
|
|
314
318
|
|
|
315
319
|
//NOTE: This is specific to references related comparison
|
|
316
320
|
const resultHrefWithMetaQuery = `${pathname}${queryParam}`;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import LANGUAGES from "./languageList";
|
|
2
|
-
import {
|
|
3
|
-
codeLanguages,
|
|
4
|
-
codeLanguagePattern,
|
|
5
|
-
codeLanguagePatternList
|
|
6
|
-
} from "typings/custom";
|
|
7
|
-
|
|
8
|
-
function getPoints(lineOfCode: string, checkers: codeLanguagePatternList) {
|
|
9
|
-
return checkers
|
|
10
|
-
.map((checker: codeLanguagePattern) => {
|
|
11
|
-
if (checker.pattern.test(lineOfCode)) {
|
|
12
|
-
return checker.points;
|
|
13
|
-
}
|
|
14
|
-
return 0;
|
|
15
|
-
})
|
|
16
|
-
.reduce((memo, num) => memo + num, 0);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function detect(snippet: string) {
|
|
20
|
-
const opts = Object.assign({
|
|
21
|
-
heuristic: true
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
let linesOfCode = snippet
|
|
25
|
-
.replace(/\r\n?/g, "\n")
|
|
26
|
-
.replace(/\n{2,}/g, "\n")
|
|
27
|
-
.split("\n");
|
|
28
|
-
|
|
29
|
-
function nearTop(index: number) {
|
|
30
|
-
return linesOfCode.length <= 10 || index < linesOfCode.length / 10;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (opts.heuristic && linesOfCode.length > 500) {
|
|
34
|
-
linesOfCode = linesOfCode.filter((lineOfCode, index) => {
|
|
35
|
-
return (
|
|
36
|
-
nearTop(index) ||
|
|
37
|
-
index % Math.ceil(linesOfCode.length / 500) === 0
|
|
38
|
-
);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const pairs = Object.keys(LANGUAGES).map((key) => {
|
|
43
|
-
return {
|
|
44
|
-
language: key,
|
|
45
|
-
checkers: LANGUAGES[key as keyof typeof LANGUAGES]
|
|
46
|
-
};
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const results = pairs.map((pair) => {
|
|
50
|
-
const language = pair.language;
|
|
51
|
-
const checkers = pair.checkers;
|
|
52
|
-
|
|
53
|
-
if (language === "Unknown") {
|
|
54
|
-
return { language: "Unknown", points: 1 };
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const pointsList = linesOfCode.map((lineOfCode) => {
|
|
58
|
-
return getPoints(lineOfCode, checkers);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
const points = pointsList.reduce((memo, num) => memo + num);
|
|
62
|
-
|
|
63
|
-
return { language, points };
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
const sortedResult = results.sort(
|
|
67
|
-
(prev, next) => prev.points - next.points
|
|
68
|
-
);
|
|
69
|
-
const bestResult = sortedResult[sortedResult.length - 1];
|
|
70
|
-
|
|
71
|
-
return bestResult.language;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const languages: any = Object.keys(LANGUAGES);
|
|
75
|
-
const LANG: { [key: string]: codeLanguages } = {};
|
|
76
|
-
|
|
77
|
-
languages.forEach((language: codeLanguages) => {
|
|
78
|
-
LANG[language] = language;
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
export { detect, languages, LANG };
|
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
JavaScript: [
|
|
3
|
-
// undefined keyword
|
|
4
|
-
{ pattern: /undefined/g, points: 2 },
|
|
5
|
-
// console.log('ayy lmao')
|
|
6
|
-
{ pattern: /console\.log( )*\(/, points: 2 },
|
|
7
|
-
// Variable declaration
|
|
8
|
-
{ pattern: /(var|const|let)( )+\w+( )*=?/, points: 2 },
|
|
9
|
-
// Array/Object declaration
|
|
10
|
-
{ pattern: /(('|").+('|")( )*|\w+):( )*[{[]/, points: 2 },
|
|
11
|
-
// === operator
|
|
12
|
-
{ pattern: /===/g, points: 1 },
|
|
13
|
-
// !== operator
|
|
14
|
-
{ pattern: /!==/g, points: 1 },
|
|
15
|
-
// Function definition
|
|
16
|
-
{
|
|
17
|
-
pattern: /function\*?(( )+[$\w]+( )*\(.*\)|( )*\(.*\))/g,
|
|
18
|
-
points: 1
|
|
19
|
-
},
|
|
20
|
-
// null keyword
|
|
21
|
-
{ pattern: /null/g, points: 1 },
|
|
22
|
-
// lambda expression
|
|
23
|
-
{ pattern: /\(.*\)( )*=>( )*.+/, points: 1 },
|
|
24
|
-
// (else )if statement
|
|
25
|
-
{ pattern: /(else )?if( )+\(.+\)/, points: 1 },
|
|
26
|
-
// while loop
|
|
27
|
-
{ pattern: /while( )+\(.+\)/, points: 1 },
|
|
28
|
-
// C style variable declaration.
|
|
29
|
-
{
|
|
30
|
-
pattern: /(^|\s)(char|long|int|float|double)( )+\w+( )*=?/,
|
|
31
|
-
points: -1
|
|
32
|
-
},
|
|
33
|
-
// pointer
|
|
34
|
-
{ pattern: /(\w+)( )*\*( )*\w+/, points: -1 },
|
|
35
|
-
// HTML <script> tag
|
|
36
|
-
{
|
|
37
|
-
pattern: /<(\/)?script( type=('|")text\/javascript('|"))?>/,
|
|
38
|
-
points: -50
|
|
39
|
-
},
|
|
40
|
-
// ES6 import / export
|
|
41
|
-
{
|
|
42
|
-
pattern:
|
|
43
|
-
/(import|export(\s+)default)\s+({\s+[\w\s,]+\s+}|\w+)\s+from\s/,
|
|
44
|
-
points: 2
|
|
45
|
-
},
|
|
46
|
-
// ES6 arrow function
|
|
47
|
-
{ pattern: /\([^()]{0,}\)\s+=>(\s+{)?/, points: 3 }
|
|
48
|
-
// () => {}
|
|
49
|
-
// (a) => {}
|
|
50
|
-
// (a, b) => {}
|
|
51
|
-
// ({ a, b}) => {}
|
|
52
|
-
// ([ a, b ]) => {}
|
|
53
|
-
],
|
|
54
|
-
|
|
55
|
-
C: [
|
|
56
|
-
// Primitive variable declaration.
|
|
57
|
-
{ pattern: /(char|long|int|float|double)( )+\w+( )*=?/, points: 2 },
|
|
58
|
-
// malloc function call
|
|
59
|
-
{ pattern: /malloc\(.+\)/, points: 2 },
|
|
60
|
-
// #include <whatever.h>
|
|
61
|
-
{ pattern: /#include (<|")\w+\.h(>|")/, points: 2, nearTop: true },
|
|
62
|
-
// pointer
|
|
63
|
-
{ pattern: /(\w+)( )*\*( )*\w+/, points: 2 },
|
|
64
|
-
// Variable declaration and/or initialisation.
|
|
65
|
-
{ pattern: /(\w+)( )+\w+(;|( )*=)/, points: 1 },
|
|
66
|
-
// Array declaration.
|
|
67
|
-
{ pattern: /(\w+)( )+\w+\[.+\]/, points: 1 },
|
|
68
|
-
// #define macro
|
|
69
|
-
{ pattern: /#define( )+.+/, points: 1 },
|
|
70
|
-
// NULL constant
|
|
71
|
-
{ pattern: /NULL/, points: 1 },
|
|
72
|
-
// void keyword
|
|
73
|
-
{ pattern: /void/g, points: 1 },
|
|
74
|
-
// (else )if statement
|
|
75
|
-
{ pattern: /(else )?if( )*\(.+\)/, points: 1 },
|
|
76
|
-
// while loop
|
|
77
|
-
{ pattern: /while( )+\(.+\)/, points: 1 },
|
|
78
|
-
// printf function
|
|
79
|
-
{ pattern: /(printf|puts)( )*\(.+\)/, points: 1 },
|
|
80
|
-
// new Keyword from C++
|
|
81
|
-
{ pattern: /new \w+/, points: -1 },
|
|
82
|
-
// Single quote multicharacter string
|
|
83
|
-
{ pattern: /'.{2,}'/, points: -1 },
|
|
84
|
-
// JS variable declaration
|
|
85
|
-
{ pattern: /var( )+\w+( )*=?/, points: -1 }
|
|
86
|
-
],
|
|
87
|
-
|
|
88
|
-
"C++": [
|
|
89
|
-
// Primitive variable declaration.
|
|
90
|
-
{ pattern: /(char|long|int|float|double)( )+\w+( )*=?/, points: 2 },
|
|
91
|
-
// #include <whatever.h>
|
|
92
|
-
{
|
|
93
|
-
pattern: /#include( )*(<|")\w+(\.h)?(>|")/,
|
|
94
|
-
points: 2,
|
|
95
|
-
nearTop: true
|
|
96
|
-
},
|
|
97
|
-
// using namespace something
|
|
98
|
-
{ pattern: /using( )+namespace( )+.+( )*;/, points: 2 },
|
|
99
|
-
// template declaration
|
|
100
|
-
{ pattern: /template( )*<.*>/, points: 2 },
|
|
101
|
-
// std
|
|
102
|
-
{ pattern: /std::\w+/g, points: 2 },
|
|
103
|
-
// cout/cin/endl
|
|
104
|
-
{ pattern: /(cout|cin|endl)/g, points: 2 },
|
|
105
|
-
// Visibility specifiers
|
|
106
|
-
{ pattern: /(public|protected|private):/, points: 2 },
|
|
107
|
-
// nullptr
|
|
108
|
-
{ pattern: /nullptr/, points: 2 },
|
|
109
|
-
// new Keyword
|
|
110
|
-
{ pattern: /new \w+(\(.*\))?/, points: 1 },
|
|
111
|
-
// #define macro
|
|
112
|
-
{ pattern: /#define( )+.+/, points: 1 },
|
|
113
|
-
// template usage
|
|
114
|
-
{ pattern: /\w+<\w+>/, points: 1 },
|
|
115
|
-
// class keyword
|
|
116
|
-
{ pattern: /class( )+\w+/, points: 1 },
|
|
117
|
-
// void keyword
|
|
118
|
-
{ pattern: /void/g, points: 1 },
|
|
119
|
-
// (else )if statement
|
|
120
|
-
{ pattern: /(else )?if( )*\(.+\)/, points: 1 },
|
|
121
|
-
// while loop
|
|
122
|
-
{ pattern: /while( )+\(.+\)/, points: 1 },
|
|
123
|
-
// Scope operator
|
|
124
|
-
{ pattern: /\w*::\w+/, points: 1 },
|
|
125
|
-
// Single quote multicharacter string
|
|
126
|
-
{ pattern: /'.{2,}'/, points: -1 },
|
|
127
|
-
// Java List/ArrayList
|
|
128
|
-
{
|
|
129
|
-
pattern: /(List<\w+>|ArrayList<\w*>( )*\(.*\))(( )+[\w]+|;)/,
|
|
130
|
-
points: -1
|
|
131
|
-
}
|
|
132
|
-
],
|
|
133
|
-
|
|
134
|
-
Python: [
|
|
135
|
-
// Function definition
|
|
136
|
-
{ pattern: /def( )+\w+\(.*\)( )*:/, points: 2 },
|
|
137
|
-
// while loop
|
|
138
|
-
{ pattern: /while (.+):/, points: 2 },
|
|
139
|
-
// from library import something
|
|
140
|
-
{ pattern: /from [\w.]+ import (\w+|\*)/, points: 2 },
|
|
141
|
-
// class keyword
|
|
142
|
-
{ pattern: /class( )*\w+(\(( )*\w+( )*\))?( )*:/, points: 2 },
|
|
143
|
-
// if keyword
|
|
144
|
-
{ pattern: /if( )+(.+)( )*:/, points: 2 },
|
|
145
|
-
// elif keyword
|
|
146
|
-
{ pattern: /elif( )+(.+)( )*:/, points: 2 },
|
|
147
|
-
// else keyword
|
|
148
|
-
{ pattern: /else:/, points: 2 },
|
|
149
|
-
// for loop
|
|
150
|
-
{ pattern: /for (\w+|\(?\w+,( )*\w+\)?) in (.+):/, points: 2 },
|
|
151
|
-
// Python variable declaration.
|
|
152
|
-
{ pattern: /\w+( )*=( )*\w+(?!;)(\n|$)/, points: 1 },
|
|
153
|
-
// import something
|
|
154
|
-
{ pattern: /import ([[^.]\w])+/, points: 1, nearTop: true },
|
|
155
|
-
// print statement/function
|
|
156
|
-
{ pattern: /print((( )*\(.+\))|( )+.+)/, points: 1 },
|
|
157
|
-
// &&/|| operators
|
|
158
|
-
{ pattern: /(&{2}|\|{2})/, points: -1 }
|
|
159
|
-
],
|
|
160
|
-
|
|
161
|
-
Java: [
|
|
162
|
-
// System.out.println() etc.
|
|
163
|
-
{ pattern: /System\.(in|out)\.\w+/, points: 2 },
|
|
164
|
-
// Class variable declarations
|
|
165
|
-
{
|
|
166
|
-
pattern: /(private|protected|public)( )*\w+( )*\w+(( )*=( )*[\w])?/,
|
|
167
|
-
points: 2
|
|
168
|
-
},
|
|
169
|
-
// Method
|
|
170
|
-
{
|
|
171
|
-
pattern: /(private|protected|public)( )*\w+( )*[\w]+\(.+\)/,
|
|
172
|
-
points: 2
|
|
173
|
-
},
|
|
174
|
-
// String class
|
|
175
|
-
{ pattern: /(^|\s)(String)( )+[\w]+( )*=?/, points: 2 },
|
|
176
|
-
// List/ArrayList
|
|
177
|
-
{
|
|
178
|
-
pattern: /(List<\w+>|ArrayList<\w*>( )*\(.*\))(( )+[\w]+|;)/,
|
|
179
|
-
points: 2
|
|
180
|
-
},
|
|
181
|
-
// class keyword
|
|
182
|
-
{ pattern: /(public( )*)?class( )*\w+/, points: 2 },
|
|
183
|
-
// Array declaration.
|
|
184
|
-
{ pattern: /(\w+)(\[( )*\])+( )+\w+/, points: 2 },
|
|
185
|
-
// final keyword
|
|
186
|
-
{ pattern: /final( )*\w+/, points: 2 },
|
|
187
|
-
// getter & setter
|
|
188
|
-
{ pattern: /\w+\.(get|set)\(.+\)/, points: 2 },
|
|
189
|
-
// new Keyword (Java)
|
|
190
|
-
{ pattern: /new [A-Z]\w*( )*\(.+\)/, points: 2 },
|
|
191
|
-
// C style variable declaration.
|
|
192
|
-
{
|
|
193
|
-
pattern: /(^|\s)(char|long|int|float|double)( )+[\w]+( )*=?/,
|
|
194
|
-
points: 1
|
|
195
|
-
},
|
|
196
|
-
// extends/implements keywords
|
|
197
|
-
{ pattern: /(extends|implements)/, points: 2, nearTop: true },
|
|
198
|
-
// null keyword
|
|
199
|
-
{ pattern: /null/g, points: 1 },
|
|
200
|
-
// (else )if statement
|
|
201
|
-
{ pattern: /(else )?if( )*\(.+\)/, points: 1 },
|
|
202
|
-
// while loop
|
|
203
|
-
{ pattern: /while( )+\(.+\)/, points: 1 },
|
|
204
|
-
// void keyword
|
|
205
|
-
{ pattern: /void/g, points: 1 },
|
|
206
|
-
// const
|
|
207
|
-
{ pattern: /const( )*\w+/, points: -1 },
|
|
208
|
-
// pointer
|
|
209
|
-
{ pattern: /(\w+)( )*\*( )*\w+/, points: -1 },
|
|
210
|
-
// Single quote multicharacter string
|
|
211
|
-
{ pattern: /'.{2,}'/, points: -1 },
|
|
212
|
-
// C style include
|
|
213
|
-
{
|
|
214
|
-
pattern: /#include( )*(<|")\w+(\.h)?(>|")/,
|
|
215
|
-
points: -1,
|
|
216
|
-
nearTop: true
|
|
217
|
-
}
|
|
218
|
-
],
|
|
219
|
-
|
|
220
|
-
HTML: [
|
|
221
|
-
{
|
|
222
|
-
pattern: /<!DOCTYPE (html|HTML PUBLIC .+)>/,
|
|
223
|
-
points: 2,
|
|
224
|
-
nearTop: true
|
|
225
|
-
},
|
|
226
|
-
// Tags
|
|
227
|
-
{
|
|
228
|
-
pattern: /<[a-z0-9]+(( )*[\w]+=('|").+('|")( )*)?>.*<\/[a-z0-9]+>/g,
|
|
229
|
-
points: 2
|
|
230
|
-
},
|
|
231
|
-
// Properties
|
|
232
|
-
{ pattern: /[a-z-]+=("|').+("|')/g, points: 2 },
|
|
233
|
-
// PHP tag
|
|
234
|
-
{ pattern: /<\?php/, points: -50 }
|
|
235
|
-
],
|
|
236
|
-
|
|
237
|
-
CSS: [
|
|
238
|
-
// Properties
|
|
239
|
-
{ pattern: /[a-z-]+:(?!:).+;/, points: 2 },
|
|
240
|
-
// <style> tag from HTML
|
|
241
|
-
{ pattern: /<(\/)?style>/, points: -50 }
|
|
242
|
-
],
|
|
243
|
-
|
|
244
|
-
Ruby: [
|
|
245
|
-
// require/include
|
|
246
|
-
{
|
|
247
|
-
pattern: /(require|include)( )+'\w+(\.rb)?'/,
|
|
248
|
-
points: 2,
|
|
249
|
-
nearTop: true
|
|
250
|
-
},
|
|
251
|
-
// Function definition
|
|
252
|
-
{ pattern: /def( )+\w+( )*(\(.+\))?( )*\n/, points: 2 },
|
|
253
|
-
// Instance variables
|
|
254
|
-
{ pattern: /@\w+/, points: 2 },
|
|
255
|
-
// Boolean property
|
|
256
|
-
{ pattern: /\.\w+\?/, points: 2 },
|
|
257
|
-
// puts (Ruby print)
|
|
258
|
-
{ pattern: /puts( )+("|').+("|')/, points: 2 },
|
|
259
|
-
// Inheriting class
|
|
260
|
-
{ pattern: /class [A-Z]\w*( )*<( )*([A-Z]\w*(::)?)+/, points: 2 },
|
|
261
|
-
// attr_accessor
|
|
262
|
-
{ pattern: /attr_accessor( )+(:\w+(,( )*)?)+/, points: 2 },
|
|
263
|
-
// new
|
|
264
|
-
{ pattern: /\w+\.new( )+/, points: 2 },
|
|
265
|
-
// elsif keyword
|
|
266
|
-
{ pattern: /elsif/, points: 2 },
|
|
267
|
-
// do
|
|
268
|
-
{ pattern: /do( )*\|(\w+(,( )*\w+)?)+\|/, points: 2 },
|
|
269
|
-
// for loop
|
|
270
|
-
{ pattern: /for (\w+|\(?\w+,( )*\w+\)?) in (.+)/, points: 1 },
|
|
271
|
-
// nil keyword
|
|
272
|
-
{ pattern: /nil/, points: 1 },
|
|
273
|
-
// Scope operator
|
|
274
|
-
{ pattern: /[A-Z]\w*::[A-Z]\w*/, points: 1 }
|
|
275
|
-
],
|
|
276
|
-
|
|
277
|
-
Go: [
|
|
278
|
-
// package something
|
|
279
|
-
{ pattern: /package( )+[a-z]+\n/, points: 2, nearTop: true },
|
|
280
|
-
// import
|
|
281
|
-
{
|
|
282
|
-
pattern: /(import( )*\(( )*\n)|(import( )+"[a-z0-9/.]+")/,
|
|
283
|
-
points: 2,
|
|
284
|
-
nearTop: true
|
|
285
|
-
},
|
|
286
|
-
// error check
|
|
287
|
-
{ pattern: /if.+err( )*!=( )*nil.+{/, points: 2 },
|
|
288
|
-
// Go print
|
|
289
|
-
{ pattern: /fmt\.Print(f|ln)?\(.*\)/, points: 2 },
|
|
290
|
-
// function
|
|
291
|
-
{ pattern: /func(( )+\w+( )*)?\(.*\).*{/, points: 2 },
|
|
292
|
-
// variable initialisation
|
|
293
|
-
{ pattern: /\w+( )*:=( )*.+[^;\n]/, points: 2 },
|
|
294
|
-
// if/else if
|
|
295
|
-
{ pattern: /(}( )*else( )*)?if[^()]+{/, points: 2 },
|
|
296
|
-
// var/const declaration
|
|
297
|
-
{ pattern: /(var|const)( )+\w+( )+[\w*]+(\n|( )*=|$)/, points: 2 },
|
|
298
|
-
// public access on package
|
|
299
|
-
{ pattern: /[a-z]+\.[A-Z]\w*/, points: 1 },
|
|
300
|
-
// nil keyword
|
|
301
|
-
{ pattern: /nil/, points: 1 },
|
|
302
|
-
// Single quote multicharacter string
|
|
303
|
-
{ pattern: /'.{2,}'/, points: -1 }
|
|
304
|
-
],
|
|
305
|
-
|
|
306
|
-
PHP: [
|
|
307
|
-
// PHP tag
|
|
308
|
-
{ pattern: /<\?php/, points: 2 },
|
|
309
|
-
// PHP style variables.
|
|
310
|
-
{ pattern: /\$\w+/, points: 2 },
|
|
311
|
-
// use Something\Something;
|
|
312
|
-
{ pattern: /use( )+\w+(\\\w+)+( )*;/, points: 2, nearTop: true },
|
|
313
|
-
// arrow
|
|
314
|
-
{ pattern: /\$\w+->\w+/, points: 2 },
|
|
315
|
-
// require/include
|
|
316
|
-
{
|
|
317
|
-
pattern:
|
|
318
|
-
/(require|include)(_once)?( )*\(?( )*('|").+\.php('|")( )*\)?( )*;/,
|
|
319
|
-
points: 2
|
|
320
|
-
},
|
|
321
|
-
// echo 'something';
|
|
322
|
-
{ pattern: /echo( )+('|").+('|")( )*;/, points: 1 },
|
|
323
|
-
// NULL constant
|
|
324
|
-
{ pattern: /NULL/, points: 1 },
|
|
325
|
-
// new keyword
|
|
326
|
-
{ pattern: /new( )+((\\\w+)+|\w+)(\(.*\))?/, points: 1 },
|
|
327
|
-
// Function definition
|
|
328
|
-
{ pattern: /function(( )+[$\w]+\(.*\)|( )*\(.*\))/g, points: 1 },
|
|
329
|
-
// (else)if statement
|
|
330
|
-
{ pattern: /(else)?if( )+\(.+\)/, points: 1 },
|
|
331
|
-
// scope operator
|
|
332
|
-
{ pattern: /\w+::\w+/, points: 1 },
|
|
333
|
-
// === operator
|
|
334
|
-
{ pattern: /===/g, points: 1 },
|
|
335
|
-
// !== operator
|
|
336
|
-
{ pattern: /!==/g, points: 1 },
|
|
337
|
-
// C/JS style variable declaration.
|
|
338
|
-
{
|
|
339
|
-
pattern: /(^|\s)(var|char|long|int|float|double)( )+\w+( )*=?/,
|
|
340
|
-
points: -1
|
|
341
|
-
}
|
|
342
|
-
],
|
|
343
|
-
|
|
344
|
-
Unknown: []
|
|
345
|
-
};
|