LaravelTest
78 строк · 2.1 Кб
1// CodeMirror, copyright (c) by Marijn Haverbeke and others
2// Distributed under an MIT license: https://codemirror.net/LICENSE
3
4(function(mod) {5if (typeof exports == "object" && typeof module == "object") // CommonJS6mod(require("../../lib/codemirror"));7else if (typeof define == "function" && define.amd) // AMD8define(["../../lib/codemirror"], mod);9else // Plain browser env10mod(CodeMirror);11})(function(CodeMirror) {12"use strict";13
14CodeMirror.defineMode("properties", function() {15return {16token: function(stream, state) {17var sol = stream.sol() || state.afterSection;18var eol = stream.eol();19
20state.afterSection = false;21
22if (sol) {23if (state.nextMultiline) {24state.inMultiline = true;25state.nextMultiline = false;26} else {27state.position = "def";28}29}30
31if (eol && ! state.nextMultiline) {32state.inMultiline = false;33state.position = "def";34}35
36if (sol) {37while(stream.eatSpace()) {}38}39
40var ch = stream.next();41
42if (sol && (ch === "#" || ch === "!" || ch === ";")) {43state.position = "comment";44stream.skipToEnd();45return "comment";46} else if (sol && ch === "[") {47state.afterSection = true;48stream.skipTo("]"); stream.eat("]");49return "header";50} else if (ch === "=" || ch === ":") {51state.position = "quote";52return null;53} else if (ch === "\\" && state.position === "quote") {54if (stream.eol()) { // end of line?55// Multiline value56state.nextMultiline = true;57}58}59
60return state.position;61},62
63startState: function() {64return {65position : "def", // Current position, "def", "quote" or "comment"66nextMultiline : false, // Is the next line multiline value67inMultiline : false, // Is the current line a multiline value68afterSection : false // Did we just open a section69};70}71
72};73});74
75CodeMirror.defineMIME("text/x-properties", "properties");76CodeMirror.defineMIME("text/x-ini", "properties");77
78});79