source: node_modules/refractor/lang/toml.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[d24f17c]1'use strict'
2
3module.exports = toml
4toml.displayName = 'toml'
5toml.aliases = []
6function toml(Prism) {
7 ;(function (Prism) {
8 var key = /(?:[\w-]+|'[^'\n\r]*'|"(?:\\.|[^\\"\r\n])*")/.source
9 /**
10 * @param {string} pattern
11 */
12 function insertKey(pattern) {
13 return pattern.replace(/__/g, function () {
14 return key
15 })
16 }
17 Prism.languages.toml = {
18 comment: {
19 pattern: /#.*/,
20 greedy: true
21 },
22 table: {
23 pattern: RegExp(
24 insertKey(
25 /(^[\t ]*\[\s*(?:\[\s*)?)__(?:\s*\.\s*__)*(?=\s*\])/.source
26 ),
27 'm'
28 ),
29 lookbehind: true,
30 greedy: true,
31 alias: 'class-name'
32 },
33 key: {
34 pattern: RegExp(
35 insertKey(/(^[\t ]*|[{,]\s*)__(?:\s*\.\s*__)*(?=\s*=)/.source),
36 'm'
37 ),
38 lookbehind: true,
39 greedy: true,
40 alias: 'property'
41 },
42 string: {
43 pattern:
44 /"""(?:\\[\s\S]|[^\\])*?"""|'''[\s\S]*?'''|'[^'\n\r]*'|"(?:\\.|[^\\"\r\n])*"/,
45 greedy: true
46 },
47 date: [
48 {
49 // Offset Date-Time, Local Date-Time, Local Date
50 pattern:
51 /\b\d{4}-\d{2}-\d{2}(?:[T\s]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?)?\b/i,
52 alias: 'number'
53 },
54 {
55 // Local Time
56 pattern: /\b\d{2}:\d{2}:\d{2}(?:\.\d+)?\b/,
57 alias: 'number'
58 }
59 ],
60 number:
61 /(?:\b0(?:x[\da-zA-Z]+(?:_[\da-zA-Z]+)*|o[0-7]+(?:_[0-7]+)*|b[10]+(?:_[10]+)*))\b|[-+]?\b\d+(?:_\d+)*(?:\.\d+(?:_\d+)*)?(?:[eE][+-]?\d+(?:_\d+)*)?\b|[-+]?\b(?:inf|nan)\b/,
62 boolean: /\b(?:false|true)\b/,
63 punctuation: /[.,=[\]{}]/
64 }
65 })(Prism)
66}
Note: See TracBrowser for help on using the repository browser.