-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for [Tom's Obvious, Minimal Language](https://github.com/toml-lang/toml). Some simplifications: 1. The `.`s of dotted keys are not highlighted. This is because the `.` could be inside quotes and checking that isn't easy. 2. There is no distinction between table `[foo]` and array `[[foo]]`. `foo` will be highlighted as `table` in both cases.
- Loading branch information
1 parent
2577b6e
commit 5b6ad70
Showing
13 changed files
with
278 additions
and
3 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
(function (Prism) { | ||
|
||
// pattern: /(?:[\w-]+|'[^'\n\r]*'|"(?:\.|[^\\"\r\n])*")/ | ||
var key = "(?:[\\w-]+|'[^'\n\r]*'|\"(?:\\.|[^\\\\\"\r\n])*\")"; | ||
|
||
Prism.languages.toml = { | ||
'comment': { | ||
pattern: /#.*/, | ||
greedy: true | ||
}, | ||
'table': { | ||
pattern: RegExp("(\\[\\s*)" + key + "(?:\\s*\\.\\s*" + key + ")*(?=\\s*\\])"), | ||
lookbehind: true, | ||
greedy: true, | ||
alias: 'class-name' | ||
}, | ||
'key': { | ||
pattern: RegExp("(^\\s*|[{,]\\s*)" + key + "(?:\\s*\\.\\s*" + key + ")*(?=\\s*=)", "m"), | ||
lookbehind: true, | ||
greedy: true, | ||
alias: 'property' | ||
}, | ||
'string': { | ||
pattern: /"""(?:\\[\s\S]|[^\\])*?"""|'''[\s\S]*?'''|'[^'\n\r]*'|"(?:\\.|[^\\"\r\n])*"/, | ||
greedy: true | ||
}, | ||
'date': [ | ||
{ | ||
// Offset Date-Time, Local Date-Time, Local Date | ||
pattern: /\d{4}-\d{2}-\d{2}(?:[T\s]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?)?/i, | ||
alias: 'number' | ||
}, | ||
{ | ||
// Local Time | ||
pattern: /\d{2}:\d{2}:\d{2}(?:\.\d+)?/i, | ||
alias: 'number' | ||
} | ||
], | ||
'number': /(?:\b0(?:x[\da-zA-Z]+(?:_[\da-zA-Z]+)*|o[0-7]+(?:_[0-7]+)*|b[10]+(?:_[10]+)*))\b|[-+]?\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?(?:[eE][+-]?\d+(?:_\d+)*)?\b|[-+]?(?:inf|nan)\b/, | ||
'boolean': /\b(?:true|false)\b/, | ||
'punctuation': /[.,=[\]{}]/ | ||
}; | ||
}(Prism)); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
true | ||
false | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["boolean", "true"], | ||
["boolean", "false"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for booleans. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# I'm a comment, you're not. | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["comment", "# I'm a comment, you're not."] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for comments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
1979-05-27T07:32:00Z | ||
1979-05-27T00:32:00-07:00 | ||
1979-05-27T00:32:00.999999-07:00 | ||
1979-05-27 07:32:00Z | ||
|
||
1979-05-27T07:32:00 | ||
1979-05-27T00:32:00.999999 | ||
|
||
1979-05-27 | ||
|
||
07:32:00 | ||
00:32:00.999999 | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["date", "1979-05-27T07:32:00Z"], | ||
["date", "1979-05-27T00:32:00-07:00"], | ||
["date", "1979-05-27T00:32:00.999999-07:00"], | ||
["date", "1979-05-27 07:32:00Z"], | ||
|
||
["date", "1979-05-27T07:32:00"], | ||
["date", "1979-05-27T00:32:00.999999"], | ||
|
||
["date", "1979-05-27"], | ||
|
||
["date", "07:32:00"], | ||
["date", "00:32:00.999999"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for dates. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
abc = "abc" | ||
"abc" = "abc" | ||
"abc".'a"b"c'.abc = "abc" | ||
a . b . c = "abc" | ||
|
||
a = { b = "b", c = "c" } | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["key", "abc"], | ||
["punctuation", "="], | ||
["string", "\"abc\""], | ||
|
||
["key", "\"abc\""], | ||
["punctuation", "="], | ||
["string", "\"abc\""], | ||
|
||
["key", "\"abc\".'a\"b\"c'.abc"], | ||
["punctuation", "="], | ||
["string", "\"abc\""], | ||
|
||
["key", "a . b . c"], | ||
["punctuation", "="], | ||
["string", "\"abc\""], | ||
|
||
["key", "a"], | ||
["punctuation", "="], | ||
["punctuation", "{"], | ||
["key", "b"], | ||
["punctuation", "="], | ||
["string", "\"b\""], | ||
["punctuation", ","], | ||
["key", "c"], | ||
["punctuation", "="], | ||
["string", "\"c\""], | ||
["punctuation", "}"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for keys. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
42 | ||
0 | ||
+0 | ||
-0 | ||
+99 | ||
-17 | ||
|
||
1_000 | ||
5_349_221 | ||
|
||
0xDEADBEEF | ||
0xdeadbeef | ||
0xdead_beef | ||
|
||
0o0123_4567 | ||
0o755 | ||
|
||
0b1101_0110 | ||
|
||
+1.0 | ||
3.1415 | ||
-0.01 | ||
5e+22 | ||
1e6 | ||
1e1_000 | ||
-2E-2 | ||
6.626e-34 | ||
9_224_617.445_991_228_313 | ||
|
||
inf | ||
+inf | ||
-inf | ||
nan | ||
+nan | ||
-nan | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["number", "42"], | ||
["number", "0"], | ||
["number", "+0"], | ||
["number", "-0"], | ||
["number", "+99"], | ||
["number", "-17"], | ||
|
||
["number", "1_000"], | ||
["number", "5_349_221"], | ||
|
||
["number", "0xDEADBEEF"], | ||
["number", "0xdeadbeef"], | ||
["number", "0xdead_beef"], | ||
|
||
["number", "0o0123_4567"], | ||
["number", "0o755"], | ||
|
||
["number", "0b1101_0110"], | ||
|
||
["number", "+1.0"], | ||
["number", "3.1415"], | ||
["number", "-0.01"], | ||
["number", "5e+22"], | ||
["number", "1e6"], | ||
["number", "1e1_000"], | ||
["number", "-2E-2"], | ||
["number", "6.626e-34"], | ||
["number", "9_224_617.445_991_228_313"], | ||
|
||
["number", "inf"], | ||
["number", "+inf"], | ||
["number", "-inf"], | ||
["number", "nan"], | ||
["number", "+nan"], | ||
["number", "-nan"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for numbers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"" | ||
"abc" | ||
"\"" | ||
'' | ||
'#' | ||
'"abc"' | ||
""" | ||
abc | ||
""" | ||
''' | ||
abc | ||
''' | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["string", "\"\""], | ||
["string", "\"abc\""], | ||
["string", "\"\\\"\""], | ||
["string", "''"], | ||
["string", "'#'"], | ||
["string", "'\"abc\"'"], | ||
["string", "\"\"\"\n\tabc\n\t\"\"\""], | ||
["string", "'''\n\tabc\n\t'''"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for strings. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[table] | ||
[[array]] | ||
|
||
---------------------------------------------------- | ||
|
||
[ | ||
["punctuation", "["], | ||
["table", "table"], | ||
["punctuation", "]"], | ||
|
||
["punctuation", "["], | ||
["punctuation", "["], | ||
["table", "array"], | ||
["punctuation", "]"], | ||
["punctuation", "]"] | ||
] | ||
|
||
---------------------------------------------------- | ||
|
||
Checks for tables. |