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

Add support for Xojo. Fix #898 #994

Merged
merged 2 commits into from
Jul 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions components.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,10 @@ var components = {
"require": "markup",
"owner": "Golmote"
},
"xojo": {
"title": "Xojo (REALbasic)",
"owner": "Golmote"
},
"yaml": {
"title": "YAML",
"owner": "hason"
Expand Down
20 changes: 20 additions & 0 deletions components/prism-xojo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Prism.languages.xojo = {
'comment': {
pattern: /(?:'|\/\/|Rem\b).+/i,
inside: {
'keyword': /^Rem/i
}
},
'string': {
pattern: /"(?:""|[^"])*"/,
greedy: true
},
'number': [
/(?:\b|\B[.-])(?:\d+\.?\d*)(?:E[+-]?\d+)?/i,
/&[bchou][a-z\d]+/i
],
'symbol': /#(?:If|Else|ElseIf|Endif|Pragma)\b/i,
'keyword': /\b(?:AddHandler|App|Array|As(?:signs)?|By(?:Ref|Val)|Break|Call|Case|Catch|Const|Continue|CurrentMethodName|Declare|Dim|Do(?:wnTo)?|Each|Else(?:If)?|End|Exit|Extends|False|Finally|For|Global|If|In|Lib|Loop|Me|Next|Nil|Optional|ParamArray|Raise(?:Event)?|ReDim|Rem|RemoveHandler|Return|Select|Self|Soft|Static|Step|Super|Then|To|True|Try|Ubound|Until|Using|Wend|While)\b/i,
'operator': /<[=>]?|>=?|[+\-*\/\\^=]|\b(?:AddressOf|And|Ctype|IsA?|Mod|New|Not|Or|Xor|WeakAddressOf)\b/i,
'punctuation': /[.,;:()]/
};
1 change: 1 addition & 0 deletions components/prism-xojo.min.js

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

66 changes: 66 additions & 0 deletions examples/prism-xojo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<h1>Xojo (REALbasic)</h1>
<p>To use this language, use the class "language-xojo".</p>

<h2>Comments</h2>
<pre><code>' This is a comment
// This is a comment too
Rem This is a remark</code></pre>

<h2>Strings</h2>
<pre><code>""
"foo ""bar"" baz"</code></pre>

<h2>Numbers and colors</h2>
<pre><code>42
3.14159
3E4
&b0110
&cAABBCCDD
&hBadFace
&o777
&u9</code></pre>

<h2>Example</h2>
<pre><code>Dim g As Graphics
Dim yOffSet As Integer
g = OpenPrinterDialog()
If g <> Nil Then
If MainDishMenu.ListIndex <> -1 Then
g.Bold = True
g.DrawString("Main Dish:",20,20)
g.Bold = False
g.DrawString(MainDishMenu.Text,100,20)
g.Bold = True
g.DrawString("Side Order:",20,40)
g.Bold = False
If FriesRadio.Value Then
g.DrawString(FriesRadio.Caption,100,40)
End If
If PotatoRadio.Value Then
g.DrawString(PotatoRadio.Caption,100,40)
End If
If OnionRingRadio.Value Then
g.DrawString(OnionRingRadio.Caption,100,40)
End If
yOffSet = 60
If CheeseCheckBox.Value Then
g.Bold = True
g.DrawString("Extra:",20,yOffSet)
g.Bold = False
g.DrawString(CheeseCheckBox.Caption,100,yOffSet)
yOffSet = yOffSet + 20
End If
If BaconCheckBox.Value Then
g.Bold = True
g.DrawString("Extra:",20,yOffSet)
g.Bold = False
g.DrawString(BaconCheckBox.Caption,100,yOffSet)
yOffSet = yOffSet + 20
End If
g.Bold = True
g.DrawString("Notes:",20,yOffSet)
g.Bold = False
g.DrawString(NotesField.Text,100,yOffSet,(g.Width-40))
End If
End If
</code></pre>
2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if (typeof self === 'undefined' || !self.Prism || !self.document) {
}

// The languages map is built automatically with gulp
var Languages = /*languages_placeholder[*/{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML","css":"CSS","clike":"C-like","javascript":"JavaScript","abap":"ABAP","actionscript":"ActionScript","apacheconf":"Apache Configuration","apl":"APL","applescript":"AppleScript","asciidoc":"AsciiDoc","aspnet":"ASP.NET (C#)","autoit":"AutoIt","autohotkey":"AutoHotkey","basic":"BASIC","csharp":"C#","cpp":"C++","coffeescript":"CoffeeScript","css-extras":"CSS Extras","fsharp":"F#","glsl":"GLSL","graphql":"GraphQL","http":"HTTP","inform7":"Inform 7","json":"JSON","latex":"LaTeX","livescript":"LiveScript","lolcode":"LOLCODE","matlab":"MATLAB","mel":"MEL","nasm":"NASM","nginx":"nginx","nsis":"NSIS","objectivec":"Objective-C","ocaml":"OCaml","parigp":"PARI/GP","php":"PHP","php-extras":"PHP Extras","powershell":"PowerShell","properties":".properties","protobuf":"Protocol Buffers","jsx":"React JSX","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","typescript":"TypeScript","vhdl":"VHDL","vim":"vim","wiki":"Wiki markup","yaml":"YAML"}/*]*/;
var Languages = /*languages_placeholder[*/{"html":"HTML","xml":"XML","svg":"SVG","mathml":"MathML","css":"CSS","clike":"C-like","javascript":"JavaScript","abap":"ABAP","actionscript":"ActionScript","apacheconf":"Apache Configuration","apl":"APL","applescript":"AppleScript","asciidoc":"AsciiDoc","aspnet":"ASP.NET (C#)","autoit":"AutoIt","autohotkey":"AutoHotkey","basic":"BASIC","csharp":"C#","cpp":"C++","coffeescript":"CoffeeScript","css-extras":"CSS Extras","fsharp":"F#","glsl":"GLSL","graphql":"GraphQL","http":"HTTP","inform7":"Inform 7","json":"JSON","latex":"LaTeX","livescript":"LiveScript","lolcode":"LOLCODE","matlab":"MATLAB","mel":"MEL","nasm":"NASM","nginx":"nginx","nsis":"NSIS","objectivec":"Objective-C","ocaml":"OCaml","parigp":"PARI/GP","php":"PHP","php-extras":"PHP Extras","powershell":"PowerShell","properties":".properties","protobuf":"Protocol Buffers","jsx":"React JSX","rest":"reST (reStructuredText)","sas":"SAS","sass":"Sass (Sass)","scss":"Sass (Scss)","sql":"SQL","typescript":"TypeScript","vhdl":"VHDL","vim":"vim","wiki":"Wiki markup","xojo":"Xojo (REALbasic)","yaml":"YAML"}/*]*/;
Prism.hooks.add('before-highlight', function(env) {
var pre = env.element.parentNode;
if (!pre || !/pre/i.test(pre.nodeName)) {
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.

15 changes: 15 additions & 0 deletions tests/languages/xojo/comment_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
' Foobar
// Foobar
Rem Foobar

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

[
["comment", ["' Foobar"]],
["comment", ["// Foobar"]],
["comment", [["keyword", "Rem"], " Foobar"]]
]

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

Checks for comments and remarks.
125 changes: 125 additions & 0 deletions tests/languages/xojo/keyword_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
AddHandler
App
Array
As
Assigns
ByRef
ByVal
Break
Call
Case
Catch
Const
Continue
CurrentMethodName
Declare
Dim
Do
DownTo
Each
Else
ElseIf
End
Exit
Extends
False
Finally
For
Global
If
In
Lib
Loop
Me
Next
Nil
Optional
ParamArray
Raise
RaiseEvent
ReDim
Rem
RemoveHandler
Return
Select
Self
Soft
Static
Step
Super
Then
To
True
Try
Ubound
Until
Using
Wend
While

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

[
["keyword", "AddHandler"],
["keyword", "App"],
["keyword", "Array"],
["keyword", "As"],
["keyword", "Assigns"],
["keyword", "ByRef"],
["keyword", "ByVal"],
["keyword", "Break"],
["keyword", "Call"],
["keyword", "Case"],
["keyword", "Catch"],
["keyword", "Const"],
["keyword", "Continue"],
["keyword", "CurrentMethodName"],
["keyword", "Declare"],
["keyword", "Dim"],
["keyword", "Do"],
["keyword", "DownTo"],
["keyword", "Each"],
["keyword", "Else"],
["keyword", "ElseIf"],
["keyword", "End"],
["keyword", "Exit"],
["keyword", "Extends"],
["keyword", "False"],
["keyword", "Finally"],
["keyword", "For"],
["keyword", "Global"],
["keyword", "If"],
["keyword", "In"],
["keyword", "Lib"],
["keyword", "Loop"],
["keyword", "Me"],
["keyword", "Next"],
["keyword", "Nil"],
["keyword", "Optional"],
["keyword", "ParamArray"],
["keyword", "Raise"],
["keyword", "RaiseEvent"],
["keyword", "ReDim"],
["keyword", "Rem"],
["keyword", "RemoveHandler"],
["keyword", "Return"],
["keyword", "Select"],
["keyword", "Self"],
["keyword", "Soft"],
["keyword", "Static"],
["keyword", "Step"],
["keyword", "Super"],
["keyword", "Then"],
["keyword", "To"],
["keyword", "True"],
["keyword", "Try"],
["keyword", "Ubound"],
["keyword", "Until"],
["keyword", "Using"],
["keyword", "Wend"],
["keyword", "While"]
]

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

Checks for keywords.
27 changes: 27 additions & 0 deletions tests/languages/xojo/number_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
42
3.14159
0.5e8
5.7e-74
&b0110
&cBadFace0
&hBadFace
&o742
&u9

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

[
["number", "42"],
["number", "3.14159"],
["number", "0.5e8"],
["number", "5.7e-74"],
["number", "&b0110"],
["number", "&cBadFace0"],
["number", "&hBadFace"],
["number", "&o742"],
["number", "&u9"]
]

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

Checks for numbers and colors.
27 changes: 27 additions & 0 deletions tests/languages/xojo/operator_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
< <= <>
> >=
+ - *
/ \ ^
=
AddressOf And
Ctype Is IsA
Mod New Not
Or Xor WeakAddressOf

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

[
["operator", "<"], ["operator", "<="], ["operator", "<>"],
["operator", ">"], ["operator", ">="],
["operator", "+"], ["operator", "-"], ["operator", "*"],
["operator", "/"], ["operator", "\\"], ["operator", "^"],
["operator", "="],
["operator", "AddressOf"], ["operator", "And"],
["operator", "Ctype"], ["operator", "Is"], ["operator", "IsA"],
["operator", "Mod"], ["operator", "New"], ["operator", "Not"],
["operator", "Or"], ["operator", "Xor"], ["operator", "WeakAddressOf"]
]

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

Checks for operators.
15 changes: 15 additions & 0 deletions tests/languages/xojo/string_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
""
""""
"Foo ""bar"""

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

[
["string", "\"\""],
["string", "\"\"\"\""],
["string", "\"Foo \"\"bar\"\"\""]
]

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

Checks for strings.
19 changes: 19 additions & 0 deletions tests/languages/xojo/symbol_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#If
#Else
#ElseIf
#Endif
#Pragma

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

[
["symbol", "#If"],
["symbol", "#Else"],
["symbol", "#ElseIf"],
["symbol", "#Endif"],
["symbol", "#Pragma"]
]

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

Checks for conditional compilation and pragma.