Skip to content

Commit

Permalink
Added support for Solution (.sln) files (#2213)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment authored Feb 23, 2020
1 parent 5362ba1 commit 15983d5
Show file tree
Hide file tree
Showing 15 changed files with 328 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,11 @@
"require": "clike",
"owner": "glachaud"
},
"solution-file": {
"title": "Solution file",
"alias": "sln",
"owner": "RunDevelopment"
},
"soy": {
"title": "Soy (Closure Template)",
"require": "markup-templating",
Expand Down
51 changes: 51 additions & 0 deletions components/prism-solution-file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
(function (Prism){

var guid = {
// https://en.wikipedia.org/wiki/Universally_unique_identifier#Format
pattern: /\{[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}\}/i,
alias: 'constant',
inside: {
'punctuation': /[{}]/
}
};

Prism.languages['solution-file'] = {
'comment': {
pattern: /#.*/,
greedy: true
},
'string': {
pattern: /"[^"\r\n]*"|'[^'\r\n]*'/,
greedy: true,
inside: {
'guid': guid
}
},
'object': {
// Foo
// Bar("abs") = 9
// EndBar
// Prop = TRUE
// EndFoo
pattern: /^([ \t]*)(?:([A-Z]\w*)\b(?=.*(?:\r\n?|\n)(?:\1[ \t].*(?:\r\n?|\n))*\1End\2(?=[ \t]*$))|End[A-Z]\w*(?=[ \t]*$))/m,
lookbehind: true,
greedy: true,
alias: 'keyword'
},
'property': {
pattern: /^([ \t]*)[^\r\n"#=()]*[^\s"#=()](?=\s*=)/m,
lookbehind: true,
inside: {
'guid': guid
}
},
'guid': guid,
'number': /\b\d+(?:\.\d+)*\b/,
'boolean': /\b(?:FALSE|TRUE)\b/,
'operator': /=/,
'punctuation': /[(),]/
};

Prism.languages['sln'] = Prism.languages['solution-file'];

}(Prism));
1 change: 1 addition & 0 deletions components/prism-solution-file.min.js

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

28 changes: 28 additions & 0 deletions examples/prism-solution-file.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<h2>Full example</h2>
<pre><code># https://docs.microsoft.com/en-us/visualstudio/extensibility/internals/solution-dot-sln-file?view=vs-2015&redirectedfrom=MSDN
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29709.97
MinimumVisualStudioVersion = 10.0.40219.1
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Project1", "Project1.vbproj", "{8CDD8387-B905-44A8-B5D5-07BB50E05BEA}"
EndProject
Global
GlobalSection(SolutionNotes) = postSolution
EndGlobalSection
GlobalSection(SolutionConfiguration) = preSolution
ConfigName.0 = Debug
ConfigName.1 = Release
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{8CDD8387-B905-44A8-B5D5-07BB50E05BEA}.Debug.ActiveCfg = Debug|x86
{8CDD8387-B905-44A8-B5D5-07BB50E05BEA}.Debug.Build.0 = Debug|x86
{8CDD8387-B905-44A8-B5D5-07BB50E05BEA}.Release.ActiveCfg = Release|x86
{8CDD8387-B905-44A8-B5D5-07BB50E05BEA}.Release.Build.0 = Release|x86
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal</code></pre>
1 change: 1 addition & 0 deletions plugins/autoloader/prism-autoloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
"py": "python",
"robot": "robotframework",
"rb": "ruby",
"sln": "solution-file",
"rq": "sparql",
"trig": "turtle",
"ts": "typescript",
Expand Down
2 changes: 1 addition & 1 deletion plugins/autoloader/prism-autoloader.min.js

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

2 changes: 2 additions & 0 deletions plugins/show-language/prism-show-language.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@
"scss": "Sass (Scss)",
"shell-session": "Shell session",
"solidity": "Solidity (Ethereum)",
"solution-file": "Solution file",
"sln": "Solution file",
"soy": "Soy (Closure Template)",
"sparql": "SPARQL",
"rq": "SPARQL",
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/solution-file/boolean_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
TRUE
FALSE

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

[
["boolean", "TRUE"],
["boolean", "FALSE"]
]

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

Checks for booleans.
11 changes: 11 additions & 0 deletions tests/languages/solution-file/comment_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# comment

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

[
["comment", "# comment"]
]

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

Checks for comments.
Loading

0 comments on commit 15983d5

Please sign in to comment.