LaravelTest
68 строк · 2.4 Кб
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"), require("../htmlmixed/htmlmixed"),7require("../../addon/mode/overlay"));8else if (typeof define == "function" && define.amd) // AMD9define(["../../lib/codemirror", "../htmlmixed/htmlmixed",10"../../addon/mode/overlay"], mod);11else // Plain browser env12mod(CodeMirror);13})(function(CodeMirror) {14"use strict";15
16CodeMirror.defineMode("tornado:inner", function() {17var keywords = ["and","as","assert","autoescape","block","break","class","comment","context",18"continue","datetime","def","del","elif","else","end","escape","except",19"exec","extends","false","finally","for","from","global","if","import","in",20"include","is","json_encode","lambda","length","linkify","load","module",21"none","not","or","pass","print","put","raise","raw","return","self","set",22"squeeze","super","true","try","url_escape","while","with","without","xhtml_escape","yield"];23keywords = new RegExp("^((" + keywords.join(")|(") + "))\\b");24
25function tokenBase (stream, state) {26stream.eatWhile(/[^\{]/);27var ch = stream.next();28if (ch == "{") {29if (ch = stream.eat(/\{|%|#/)) {30state.tokenize = inTag(ch);31return "tag";32}33}34}35function inTag (close) {36if (close == "{") {37close = "}";38}39return function (stream, state) {40var ch = stream.next();41if ((ch == close) && stream.eat("}")) {42state.tokenize = tokenBase;43return "tag";44}45if (stream.match(keywords)) {46return "keyword";47}48return close == "#" ? "comment" : "string";49};50}51return {52startState: function () {53return {tokenize: tokenBase};54},55token: function (stream, state) {56return state.tokenize(stream, state);57}58};59});60
61CodeMirror.defineMode("tornado", function(config) {62var htmlBase = CodeMirror.getMode(config, "text/html");63var tornadoInner = CodeMirror.getMode(config, "tornado:inner");64return CodeMirror.overlayMode(htmlBase, tornadoInner);65});66
67CodeMirror.defineMIME("text/x-tornado", "tornado");68});69