9
if (typeof exports == "object" && typeof module == "object")
10
mod(require("../../lib/codemirror"), require("htmlhint"));
11
else if (typeof define == "function" && define.amd)
12
define(["../../lib/codemirror", "htmlhint"], mod);
14
mod(CodeMirror, window.HTMLHint);
15
})(function(CodeMirror, HTMLHint) {
19
"tagname-lowercase": true,
20
"attr-lowercase": true,
21
"attr-value-double-quotes": true,
22
"doctype-first": false,
24
"spec-char-escape": true,
26
"src-not-empty": true,
27
"attr-no-duplication": true
30
CodeMirror.registerHelper("lint", "html", function(text, options) {
32
if (HTMLHint && !HTMLHint.verify) {
33
if(typeof HTMLHint.default !== 'undefined') {
34
HTMLHint = HTMLHint.default;
36
HTMLHint = HTMLHint.HTMLHint;
39
if (!HTMLHint) HTMLHint = window.HTMLHint;
42
window.console.error("Error: HTMLHint not found, not defined on window, or not available through define/require, CodeMirror HTML linting cannot run.");
46
var messages = HTMLHint.verify(text, options && options.rules || defaultRules);
47
for (var i = 0; i < messages.length; i++) {
48
var message = messages[i];
49
var startLine = message.line - 1, endLine = message.line - 1, startCol = message.col - 1, endCol = message.col;
51
from: CodeMirror.Pos(startLine, startCol),
52
to: CodeMirror.Pos(endLine, endCol),
53
message: message.message,
54
severity : message.type