diff options
| author | Armand Philippot <git@armandphilippot.com> | 2021-12-30 19:47:21 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2021-12-30 19:47:21 +0100 |
| commit | a98b5ea6fe8e8cc98a55e0fd793e6e8660ea31c1 (patch) | |
| tree | 542810ab5aef99150db228bb54fd58303dcb31c7 /public/prism/prism-toml.js | |
| parent | ab355897a12b7bda1089a44de326d41455a0f7a3 (diff) | |
chore: add prismjs for syntax highlighting
Diffstat (limited to 'public/prism/prism-toml.js')
| -rw-r--r-- | public/prism/prism-toml.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/public/prism/prism-toml.js b/public/prism/prism-toml.js new file mode 100644 index 0000000..b2bd892 --- /dev/null +++ b/public/prism/prism-toml.js @@ -0,0 +1,59 @@ +(function (Prism) { + var key = /(?:[\w-]+|'[^'\n\r]*'|"(?:\\.|[^\\"\r\n])*")/.source; + + /** + * @param {string} pattern + */ + function insertKey(pattern) { + return pattern.replace(/__/g, function () { + return key; + }); + } + + Prism.languages.toml = { + comment: { + pattern: /#.*/, + greedy: true, + }, + table: { + pattern: RegExp( + insertKey(/(^[\t ]*\[\s*(?:\[\s*)?)__(?:\s*\.\s*__)*(?=\s*\])/.source), + 'm' + ), + lookbehind: true, + greedy: true, + alias: 'class-name', + }, + key: { + pattern: RegExp( + insertKey(/(^[\t ]*|[{,]\s*)__(?:\s*\.\s*__)*(?=\s*=)/.source), + '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: + /\b\d{4}-\d{2}-\d{2}(?:[T\s]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?)?\b/i, + alias: 'number', + }, + { + // Local Time + pattern: /\b\d{2}:\d{2}:\d{2}(?:\.\d+)?\b/, + alias: 'number', + }, + ], + number: + /(?:\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/, + boolean: /\b(?:false|true)\b/, + punctuation: /[.,=[\]{}]/, + }; +})(Prism); |
