diff --git a/components.js b/components.js index db90cc284f..0674d04acb 100644 --- a/components.js +++ b/components.js @@ -550,6 +550,10 @@ var components = { "require": "markup", "owner": "Golmote" }, + "xojo": { + "title": "Xojo (REALbasic)", + "owner": "Golmote" + }, "yaml": { "title": "YAML", "owner": "hason" diff --git a/components/prism-xojo.js b/components/prism-xojo.js new file mode 100644 index 0000000000..ede0cd0c8f --- /dev/null +++ b/components/prism-xojo.js @@ -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': /[.,;:()]/ +}; \ No newline at end of file diff --git a/components/prism-xojo.min.js b/components/prism-xojo.min.js new file mode 100644 index 0000000000..848789084c --- /dev/null +++ b/components/prism-xojo.min.js @@ -0,0 +1 @@ +Prism.languages.xojo={comment:{pattern:/(?:'|\/\/|Rem\b).+/i,inside:{keyword:/^Rem/i}},string:{pattern:/"(?:""|[^"])*"/,greedy:!0},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:/[.,;:()]/}; \ No newline at end of file diff --git a/examples/prism-xojo.html b/examples/prism-xojo.html new file mode 100644 index 0000000000..2f5b8b8dc5 --- /dev/null +++ b/examples/prism-xojo.html @@ -0,0 +1,66 @@ +
To use this language, use the class "language-xojo".
+ +' This is a comment
+// This is a comment too
+Rem This is a remark
+
+""
+"foo ""bar"" baz"
+
+42
+3.14159
+3E4
+&b0110
+&cAABBCCDD
+&hBadFace
+&o777
+&u9
+
+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
+
diff --git a/plugins/show-language/prism-show-language.js b/plugins/show-language/prism-show-language.js
index 5ca2ade724..10bdff15e2 100644
--- a/plugins/show-language/prism-show-language.js
+++ b/plugins/show-language/prism-show-language.js
@@ -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)) {
diff --git a/plugins/show-language/prism-show-language.min.js b/plugins/show-language/prism-show-language.min.js
index a990adbaa8..afa963ce48 100644
--- a/plugins/show-language/prism-show-language.min.js
+++ b/plugins/show-language/prism-show-language.min.js
@@ -1 +1 @@
-!function(){if("undefined"!=typeof self&&self.Prism&&self.document){var e={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"};Prism.hooks.add("before-highlight",function(s){var a=s.element.parentNode;if(a&&/pre/i.test(a.nodeName)){var t,i,r=a.getAttribute("data-language")||e[s.language]||s.language.substring(0,1).toUpperCase()+s.language.substring(1),p=a.previousSibling;p&&/\s*\bprism-show-language\b\s*/.test(p.className)&&p.firstChild&&/\s*\bprism-show-language-label\b\s*/.test(p.firstChild.className)?i=p.firstChild:(t=document.createElement("div"),i=document.createElement("div"),i.className="prism-show-language-label",t.className="prism-show-language",t.appendChild(i),a.parentNode.insertBefore(t,a)),i.innerHTML=r}})}}();
\ No newline at end of file
+!function(){if("undefined"!=typeof self&&self.Prism&&self.document){var e={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(s){var a=s.element.parentNode;if(a&&/pre/i.test(a.nodeName)){var t,i,r=a.getAttribute("data-language")||e[s.language]||s.language.substring(0,1).toUpperCase()+s.language.substring(1),p=a.previousSibling;p&&/\s*\bprism-show-language\b\s*/.test(p.className)&&p.firstChild&&/\s*\bprism-show-language-label\b\s*/.test(p.firstChild.className)?i=p.firstChild:(t=document.createElement("div"),i=document.createElement("div"),i.className="prism-show-language-label",t.className="prism-show-language",t.appendChild(i),a.parentNode.insertBefore(t,a)),i.innerHTML=r}})}}();
\ No newline at end of file
diff --git a/tests/languages/xojo/comment_feature.test b/tests/languages/xojo/comment_feature.test
new file mode 100644
index 0000000000..c980136164
--- /dev/null
+++ b/tests/languages/xojo/comment_feature.test
@@ -0,0 +1,15 @@
+' Foobar
+// Foobar
+Rem Foobar
+
+----------------------------------------------------
+
+[
+ ["comment", ["' Foobar"]],
+ ["comment", ["// Foobar"]],
+ ["comment", [["keyword", "Rem"], " Foobar"]]
+]
+
+----------------------------------------------------
+
+Checks for comments and remarks.
\ No newline at end of file
diff --git a/tests/languages/xojo/keyword_feature.test b/tests/languages/xojo/keyword_feature.test
new file mode 100644
index 0000000000..52a419b245
--- /dev/null
+++ b/tests/languages/xojo/keyword_feature.test
@@ -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.
\ No newline at end of file
diff --git a/tests/languages/xojo/number_feature.test b/tests/languages/xojo/number_feature.test
new file mode 100644
index 0000000000..209a7bce07
--- /dev/null
+++ b/tests/languages/xojo/number_feature.test
@@ -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.
\ No newline at end of file
diff --git a/tests/languages/xojo/operator_feature.test b/tests/languages/xojo/operator_feature.test
new file mode 100644
index 0000000000..8f95b0ed65
--- /dev/null
+++ b/tests/languages/xojo/operator_feature.test
@@ -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.
\ No newline at end of file
diff --git a/tests/languages/xojo/string_feature.test b/tests/languages/xojo/string_feature.test
new file mode 100644
index 0000000000..4da4f55216
--- /dev/null
+++ b/tests/languages/xojo/string_feature.test
@@ -0,0 +1,15 @@
+""
+""""
+"Foo ""bar"""
+
+----------------------------------------------------
+
+[
+ ["string", "\"\""],
+ ["string", "\"\"\"\""],
+ ["string", "\"Foo \"\"bar\"\"\""]
+]
+
+----------------------------------------------------
+
+Checks for strings.
\ No newline at end of file
diff --git a/tests/languages/xojo/symbol_feature.test b/tests/languages/xojo/symbol_feature.test
new file mode 100644
index 0000000000..980c0f13ed
--- /dev/null
+++ b/tests/languages/xojo/symbol_feature.test
@@ -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.
\ No newline at end of file