]> luflow.net public git repositories - flow-web.git/blob - static/highlight/languages/nestedtext.js
Initial commit.
[flow-web.git] / static / highlight / languages / nestedtext.js
1 /*! `nestedtext` grammar compiled for Highlight.js 11.11.1 */
2 (function(){
3 var hljsGrammar = (function () {
4 'use strict';
5
6 /*
7 Language: NestedText
8 Description: NestedText is a file format for holding data that is to be entered, edited, or viewed by people.
9 Website: https://nestedtext.org/
10 Category: config
11 */
12
13 /** @type LanguageFn */
14 function nestedtext(hljs) {
15 const NESTED = {
16 match: [
17 /^\s*(?=\S)/, // have to look forward here to avoid polynomial backtracking
18 /[^:]+/,
19 /:\s*/,
20 /$/
21 ],
22 className: {
23 2: "attribute",
24 3: "punctuation"
25 }
26 };
27 const DICTIONARY_ITEM = {
28 match: [
29 /^\s*(?=\S)/, // have to look forward here to avoid polynomial backtracking
30 /[^:]*[^: ]/,
31 /[ ]*:/,
32 /[ ]/,
33 /.*$/
34 ],
35 className: {
36 2: "attribute",
37 3: "punctuation",
38 5: "string"
39 }
40 };
41 const STRING = {
42 match: [
43 /^\s*/,
44 />/,
45 /[ ]/,
46 /.*$/
47 ],
48 className: {
49 2: "punctuation",
50 4: "string"
51 }
52 };
53 const LIST_ITEM = {
54 variants: [
55 { match: [
56 /^\s*/,
57 /-/,
58 /[ ]/,
59 /.*$/
60 ] },
61 { match: [
62 /^\s*/,
63 /-$/
64 ] }
65 ],
66 className: {
67 2: "bullet",
68 4: "string"
69 }
70 };
71
72 return {
73 name: 'Nested Text',
74 aliases: [ 'nt' ],
75 contains: [
76 hljs.inherit(hljs.HASH_COMMENT_MODE, {
77 begin: /^\s*(?=#)/,
78 excludeBegin: true
79 }),
80 LIST_ITEM,
81 STRING,
82 NESTED,
83 DICTIONARY_ITEM
84 ]
85 };
86 }
87
88 return nestedtext;
89
90 })();
91
92 hljs.registerLanguage('nestedtext', hljsGrammar);
93 })();