Debian Codegraph @

codemirror-legacy-modes/mode/properties.js

raw
1 export const properties = {
2 name: "properties",
3
4 token: function(stream, state) {
5 var sol = stream.sol() || state.afterSection;
6 var eol = stream.eol();
7
8 state.afterSection = false;
9
10 if (sol) {
11 if (state.nextMultiline) {
12 state.inMultiline = true;
13 state.nextMultiline = false;
14 } else {
15 state.position = "def";
16 }
17 }
18
19 if (eol && ! state.nextMultiline) {
20 state.inMultiline = false;
21 state.position = "def";
22 }
23
24 if (sol) {
25 while(stream.eatSpace()) {}
26 }
27
28 var ch = stream.next();
29
30 if (sol && (ch === "#" || ch === "!" || ch === ";")) {
31 state.position = "comment";
32 stream.skipToEnd();
33 return "comment";
34 } else if (sol && ch === "[") {
35 state.afterSection = true;
36 stream.skipTo("]"); stream.eat("]");
37 return "header";
38 } else if (ch === "=" || ch === ":") {
39 state.position = "quote";
40 return null;
41 } else if (ch === "\\" && state.position === "quote") {
42 if (stream.eol()) { // end of line?
43 // Multiline value
44 state.nextMultiline = true;
45 }
46 }
47
48 return state.position;
49 },
50
51 startState: function() {
52 return {
53 position : "def", // Current position, "def", "quote" or "comment"
54 nextMultiline : false, // Is the next line multiline value
55 inMultiline : false, // Is the current line a multiline value
56 afterSection : false // Did we just open a section
57 };
58 }
59
60 };