LaravelTest
41 строка · 1.2 Кб
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
14// Depends on js-yaml.js from https://github.com/nodeca/js-yaml
15
16// declare global: jsyaml
17
18CodeMirror.registerHelper("lint", "yaml", function(text) {19var found = [];20if (!window.jsyaml) {21if (window.console) {22window.console.error("Error: window.jsyaml not defined, CodeMirror YAML linting cannot run.");23}24return found;25}26try { jsyaml.loadAll(text); }27catch(e) {28var loc = e.mark,29// js-yaml YAMLException doesn't always provide an accurate lineno30// e.g., when there are multiple yaml docs31// ---32// ---33// foo:bar34from = loc ? CodeMirror.Pos(loc.line, loc.column) : CodeMirror.Pos(0, 0),35to = from;36found.push({ from: from, to: to, message: e.message });37}38return found;39});40
41});42