LaravelTest
84 строки · 2.3 Кб
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")6mod(require("../../lib/codemirror"));7else if (typeof define == "function" && define.amd)8define(["../../lib/codemirror"], mod);9else10mod(CodeMirror);11})(function(CodeMirror) {12"use strict";13
14CodeMirror.defineMode('troff', function() {15
16var words = {};17
18function tokenBase(stream) {19if (stream.eatSpace()) return null;20
21var sol = stream.sol();22var ch = stream.next();23
24if (ch === '\\') {25if (stream.match('fB') || stream.match('fR') || stream.match('fI') ||26stream.match('u') || stream.match('d') ||27stream.match('%') || stream.match('&')) {28return 'string';29}30if (stream.match('m[')) {31stream.skipTo(']');32stream.next();33return 'string';34}35if (stream.match('s+') || stream.match('s-')) {36stream.eatWhile(/[\d-]/);37return 'string';38}39if (stream.match('\(') || stream.match('*\(')) {40stream.eatWhile(/[\w-]/);41return 'string';42}43return 'string';44}45if (sol && (ch === '.' || ch === '\'')) {46if (stream.eat('\\') && stream.eat('\"')) {47stream.skipToEnd();48return 'comment';49}50}51if (sol && ch === '.') {52if (stream.match('B ') || stream.match('I ') || stream.match('R ')) {53return 'attribute';54}55if (stream.match('TH ') || stream.match('SH ') || stream.match('SS ') || stream.match('HP ')) {56stream.skipToEnd();57return 'quote';58}59if ((stream.match(/[A-Z]/) && stream.match(/[A-Z]/)) || (stream.match(/[a-z]/) && stream.match(/[a-z]/))) {60return 'attribute';61}62}63stream.eatWhile(/[\w-]/);64var cur = stream.current();65return words.hasOwnProperty(cur) ? words[cur] : null;66}67
68function tokenize(stream, state) {69return (state.tokens[0] || tokenBase) (stream, state);70};71
72return {73startState: function() {return {tokens:[]};},74token: function(stream, state) {75return tokenize(stream, state);76}77};78});79
80CodeMirror.defineMIME('text/troff', 'troff');81CodeMirror.defineMIME('text/x-troff', 'troff');82CodeMirror.defineMIME('application/x-troff', 'troff');83
84});85