1 |
|
2 |
|
3 |
|
4 | (function(mod) {
|
5 | if (typeof exports == "object" && typeof module == "object")
|
6 | mod(require("../../lib/codemirror"));
|
7 | else if (typeof define == "function" && define.amd)
|
8 | define(["../../lib/codemirror"], mod);
|
9 | else
|
10 | mod(CodeMirror);
|
11 | })(function(CodeMirror) {
|
12 | "use strict";
|
13 |
|
14 | CodeMirror.defineMode("properties", function() {
|
15 | return {
|
16 | token: function(stream, state) {
|
17 | var sol = stream.sol() || state.afterSection;
|
18 | var eol = stream.eol();
|
19 |
|
20 | state.afterSection = false;
|
21 |
|
22 | if (sol) {
|
23 | if (state.nextMultiline) {
|
24 | state.inMultiline = true;
|
25 | state.nextMultiline = false;
|
26 | } else {
|
27 | state.position = "def";
|
28 | }
|
29 | }
|
30 |
|
31 | if (eol && ! state.nextMultiline) {
|
32 | state.inMultiline = false;
|
33 | state.position = "def";
|
34 | }
|
35 |
|
36 | if (sol) {
|
37 | while(stream.eatSpace()) {}
|
38 | }
|
39 |
|
40 | var ch = stream.next();
|
41 |
|
42 | if (sol && (ch === "#" || ch === "!" || ch === ";")) {
|
43 | state.position = "comment";
|
44 | stream.skipToEnd();
|
45 | return "comment";
|
46 | } else if (sol && ch === "[") {
|
47 | state.afterSection = true;
|
48 | stream.skipTo("]"); stream.eat("]");
|
49 | return "header";
|
50 | } else if (ch === "=" || ch === ":") {
|
51 | state.position = "quote";
|
52 | return null;
|
53 | } else if (ch === "\\" && state.position === "quote") {
|
54 | if (stream.eol()) {
|
55 |
|
56 | state.nextMultiline = true;
|
57 | }
|
58 | }
|
59 |
|
60 | return state.position;
|
61 | },
|
62 |
|
63 | startState: function() {
|
64 | return {
|
65 | position : "def",
|
66 | nextMultiline : false,
|
67 | inMultiline : false,
|
68 | afterSection : false
|
69 | };
|
70 | }
|
71 |
|
72 | };
|
73 | });
|
74 |
|
75 | CodeMirror.defineMIME("text/x-properties", "properties");
|
76 | CodeMirror.defineMIME("text/x-ini", "properties");
|
77 |
|
78 | });
|