Skip to content

Commit b301c2f

Browse files
committed
add highlightjs definition
1 parent a9771b7 commit b301c2f

File tree

4 files changed

+82
-3
lines changed

4 files changed

+82
-3
lines changed

.github/workflows/release.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ jobs:
2121
files: |
2222
gen/rascript.tmLanguage.json
2323
gen/rascript.tmLanguage
24-
gen/RAScript.xml
24+
gen/RAScript.xml
25+
gen/rascript.js

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ run `make generate` to create the grammar files in the `gen` folder. The current
1111
* rascript.tmLanguage.json -- vscode, linguist
1212
* rascript.tmLanguage -- sublime
1313
* RAScript.xml -- Notepad++
14+
* rascript.js -- highlight.js
1415

1516
## Download
1617

@@ -19,4 +20,5 @@ Grab the latest generated files on the [release](https://github.com/joshraphael/
1920
## Projects Using rascript-syntax
2021
- [vscode-rascript](https://github.com/joshraphael/vscode-rascript) - VSCode language client for RAScript.
2122
- [sublime-rascript](https://github.com/joshraphael/sublime-rascript) - SublimeText language client for RAScript.
22-
- [npp-rascript](https://github.com/joshraphael/npp-rascript) - Notepad++ language client for RAScript.
23+
- [npp-rascript](https://github.com/joshraphael/npp-rascript) - Notepad++ language client for RAScript.
24+
- [highlightjs-rascript](https://github.com/joshraphael/highlightjs-rascript) - highlight.js grammar definition for RAScript.

rascript.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
Language: RAScript
3+
Author: Joshua Raphael
4+
Description: Syntax grammar for RAScript, a RetroAchievements.org DSL
5+
Category: syntax
6+
Version: <GRAMMAR_VERSION>
7+
*/
8+
export default function(hljs) {
9+
return {
10+
case_insensitive: false,
11+
contains: [
12+
hljs.C_LINE_COMMENT_MODE,
13+
hljs.QUOTE_STRING_MODE,
14+
hljs.C_NUMBER_MODE,
15+
hljs.COMMENT(
16+
'/\\*',
17+
'\\*/',
18+
),
19+
{
20+
className: 'variable.language',
21+
begin: /\b(this)\b/
22+
},
23+
{
24+
className: 'keyword',
25+
begin: /\b(function|class|else|for|if|in|return)\b/
26+
},
27+
{
28+
className: 'literal',
29+
begin: /\b(true|false)\b/
30+
},
31+
{
32+
className: 'operator',
33+
begin: /(\|\||\&\&|\=\=|\!\=|\>\=|\<\=|\=\>)/
34+
},
35+
{
36+
scope: 'operator',
37+
match: /[\+\-\*\/\%\^\&\^\~\>\<\!\|]/,
38+
relevance: 0
39+
},
40+
{
41+
begin: [
42+
/function[\t ]+/,
43+
/[a-zA-Z_][\w]*/,
44+
/\(/
45+
],
46+
beginScope: {
47+
2: "title.function"
48+
}
49+
},
50+
{
51+
begin: [
52+
/class[\t ]+/,
53+
/[a-zA-Z_][\w]*/
54+
],
55+
beginScope: {
56+
2: "title.class"
57+
}
58+
},
59+
{
60+
begin: [
61+
/[a-zA-Z_][\w]*/,
62+
/\(/
63+
],
64+
beginScope: {
65+
1: "title.function.invoke"
66+
}
67+
},
68+
{
69+
className: 'variable',
70+
begin: /[a-zA-Z_][\w]*/,
71+
relevance: 0
72+
}
73+
]
74+
}
75+
}

scripts/generate.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ fi
88

99
sed "s/<GRAMMAR_VERSION>/$VERSION/g" rascript.tmLanguage.json > gen/rascript.tmLanguage.json
1010
plistutil -f xml -i gen/rascript.tmLanguage.json -o gen/rascript.tmLanguage
11-
sed "s/<GRAMMAR_VERSION>/$VERSION/g" RAScript.xml > gen/RAScript.xml
11+
sed "s/<GRAMMAR_VERSION>/$VERSION/g" RAScript.xml > gen/RAScript.xml
12+
sed "s/<GRAMMAR_VERSION>/$VERSION/g" rascript.js > gen/rascript.js

0 commit comments

Comments
 (0)