LaravelTest
59 строк · 1.9 Кб
1// CodeMirror, copyright (c) by Marijn Haverbeke and others
2// Distributed under an MIT license: https://codemirror.net/LICENSE
3
4// Depends on htmlhint.js from http://htmlhint.com/js/htmlhint.js
5
6// declare global: HTMLHint
7
8(function(mod) {9if (typeof exports == "object" && typeof module == "object") // CommonJS10mod(require("../../lib/codemirror"), require("htmlhint"));11else if (typeof define == "function" && define.amd) // AMD12define(["../../lib/codemirror", "htmlhint"], mod);13else // Plain browser env14mod(CodeMirror, window.HTMLHint);15})(function(CodeMirror, HTMLHint) {16"use strict";17
18var defaultRules = {19"tagname-lowercase": true,20"attr-lowercase": true,21"attr-value-double-quotes": true,22"doctype-first": false,23"tag-pair": true,24"spec-char-escape": true,25"id-unique": true,26"src-not-empty": true,27"attr-no-duplication": true28};29
30CodeMirror.registerHelper("lint", "html", function(text, options) {31var found = [];32if (HTMLHint && !HTMLHint.verify) {33if(typeof HTMLHint.default !== 'undefined') {34HTMLHint = HTMLHint.default;35} else {36HTMLHint = HTMLHint.HTMLHint;37}38}39if (!HTMLHint) HTMLHint = window.HTMLHint;40if (!HTMLHint) {41if (window.console) {42window.console.error("Error: HTMLHint not found, not defined on window, or not available through define/require, CodeMirror HTML linting cannot run.");43}44return found;45}46var messages = HTMLHint.verify(text, options && options.rules || defaultRules);47for (var i = 0; i < messages.length; i++) {48var message = messages[i];49var startLine = message.line - 1, endLine = message.line - 1, startCol = message.col - 1, endCol = message.col;50found.push({51from: CodeMirror.Pos(startLine, startCol),52to: CodeMirror.Pos(endLine, endCol),53message: message.message,54severity : message.type55});56}57return found;58});59});60