Skip to content

Commit

Permalink
Added UO Razor Script (#3309)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaseowns authored Jan 28, 2022
1 parent bcb2e2c commit 3f8cc5a
Show file tree
Hide file tree
Showing 14 changed files with 502 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,10 @@
"alias": ["uscript", "uc"],
"owner": "RunDevelopment"
},
"uorazor": {
"title": "UO Razor Script",
"owner": "jaseowns"
},
"uri": {
"title": "URI",
"alias": "url",
Expand Down
48 changes: 48 additions & 0 deletions components/prism-uorazor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Prism.languages.uorazor = {
'comment-hash': {
pattern: /#.*/,
alias: 'comment',
greedy: true
},
'comment-slash': {
pattern: /\/\/.*/,
alias: 'comment',
greedy: true
},
'string': {
pattern: /("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
inside: {
'punctuation': /^['"]|['"]$/
},
greedy: true
},
'source-layers': {
pattern: /\b(?:arms|backpack|blue|bracelet|cancel|clear|cloak|criminal|earrings|enemy|facialhair|friend|friendly|gloves|gray|grey|ground|hair|head|innerlegs|innertorso|innocent|lefthand|middletorso|murderer|neck|nonfriendly|onehandedsecondary|outerlegs|outertorso|pants|red|righthand|ring|self|shirt|shoes|talisman|waist)\b/i,
alias: 'function'
},
'source-commands': {
pattern: /\b(?:alliance|attack|cast|clearall|clearignore|clearjournal|clearlist|clearsysmsg|createlist|createtimer|dclick|dclicktype|dclickvar|dress|dressconfig|drop|droprelloc|emote|getlabel|guild|gumpclose|gumpresponse|hotkey|ignore|lasttarget|lift|lifttype|menu|menuresponse|msg|org|organize|organizer|overhead|pause|poplist|potion|promptresponse|pushlist|removelist|removetimer|rename|restock|say|scav|scavenger|script|setability|setlasttarget|setskill|settimer|setvar|sysmsg|target|targetloc|targetrelloc|targettype|undress|unignore|unsetvar|useobject|useonce|useskill|usetype|virtue|wait|waitforgump|waitformenu|waitforprompt|waitforstat|waitforsysmsg|waitfortarget|walk|wfsysmsg|wft|whisper|yell)\b/,
alias: 'function'
},
'tag-name': {
pattern: /(^\{%-?\s*)\w+/,
lookbehind: true,
alias: 'keyword'
},
'delimiter': {
pattern: /^\{[{%]-?|-?[%}]\}$/,
alias: 'punctuation'
},
'function': /\b(?:atlist|close|closest|count|counter|counttype|dead|dex|diffhits|diffmana|diffstam|diffweight|find|findbuff|finddebuff|findlayer|findtype|findtypelist|followers|gumpexists|hidden|hits|hp|hue|human|humanoid|ingump|inlist|insysmessage|insysmsg|int|invul|lhandempty|list|listexists|mana|maxhits|maxhp|maxmana|maxstam|maxweight|monster|mounted|name|next|noto|paralyzed|poisoned|position|prev|previous|queued|rand|random|rhandempty|skill|stam|str|targetexists|timer|timerexists|varexist|warmode|weight)\b/,
'keyword': /\b(?:and|as|break|continue|else|elseif|endfor|endif|endwhile|for|if|loop|not|or|replay|stop|while)\b/,
'boolean': /\b(?:false|null|true)\b/,
'number': /\b0x[\dA-Fa-f]+|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee][-+]?\d+)?/,
'operator': [
{
pattern: /(\s)(?:and|b-and|b-or|b-xor|ends with|in|is|matches|not|or|same as|starts with)(?=\s)/,
lookbehind: true
},
/[=<>]=?|!=|\*\*?|\/\/?|\?:?|[-+~%|]/
],
'punctuation': /[()\[\]{}:.,]/
};
1 change: 1 addition & 0 deletions components/prism-uorazor.min.js

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

13 changes: 13 additions & 0 deletions examples/prism-uorazor.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<h2>Full example</h2>
<pre><code>
# UO Razor Script Highlighting by Jaseowns
// These two are comments
// Example script:
setvar "my_training_target"
while skill "anatomy" &lt; 100
useskill "anatomy"
wft 500
target "my_training_target"
wait 2000
endwhile
</code></pre>
1 change: 1 addition & 0 deletions plugins/show-language/prism-show-language.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
"tsconfig": "TSConfig",
"uscript": "UnrealScript",
"uc": "UnrealScript",
"uorazor": "UO Razor Script",
"uri": "URI",
"url": "URL",
"vbnet": "VB.Net",
Expand Down
2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.min.js

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

13 changes: 13 additions & 0 deletions tests/languages/uorazor/boolean_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
false
true

----------------------------------------------------

[
["boolean", "false"],
["boolean", "true"]
]

----------------------------------------------------

Checks for boolean values
54 changes: 54 additions & 0 deletions tests/languages/uorazor/breakdown_script_example_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
setvar "my_training_target"
while skill "anatomy" < 100
useskill "anatomy"
wft 500
target "my_training_target"
wait 2000
endwhile

----------------------------------------------------

[
["source-commands", "setvar"],
["string", [
["punctuation", "\""],
"my_training_target",
["punctuation", "\""]
]],

["keyword", "while"],
["function", "skill"],
["string", [
["punctuation", "\""],
"anatomy",
["punctuation", "\""]
]],
["operator", "<"],
["number", "100"],

["source-commands", "useskill"],
["string", [
["punctuation", "\""],
"anatomy",
["punctuation", "\""]
]],

["source-commands", "wft"],
["number", "500"],

["source-commands", "target"],
["string", [
["punctuation", "\""],
"my_training_target",
["punctuation", "\""]
]],

["source-commands", "wait"],
["number", "2000"],

["keyword", "endwhile"]
]

----------------------------------------------------

Checks for each type of syntax breakdown
Loading

0 comments on commit 3f8cc5a

Please sign in to comment.