[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/vendor/codemirror/addon/lint/ -> html-lint.js (source)

   1  // CodeMirror, copyright (c) by Marijn Haverbeke and others
   2  // Distributed under an MIT license: https://codemirror.net/5/LICENSE
   3  
   4  // Depends on htmlhint.js from http://htmlhint.com/js/htmlhint.js
   5  
   6  // declare global: HTMLHint
   7  
   8  (function(mod) {
   9    if (typeof exports == "object" && typeof module == "object") // CommonJS
  10      mod(require("../../lib/codemirror"), require("htmlhint"));
  11    else if (typeof define == "function" && define.amd) // AMD
  12      define(["../../lib/codemirror", "htmlhint"], mod);
  13    else // Plain browser env
  14      mod(CodeMirror, window.HTMLHint);
  15  })(function(CodeMirror, HTMLHint) {
  16    "use strict";
  17  
  18    var 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": true
  28    };
  29  
  30    CodeMirror.registerHelper("lint", "html", function(text, options) {
  31      var found = [];
  32      if (HTMLHint && !HTMLHint.verify) {
  33        if(typeof HTMLHint.default !== 'undefined') {
  34          HTMLHint = HTMLHint.default;
  35        } else {
  36          HTMLHint = HTMLHint.HTMLHint;
  37        }
  38      }
  39      if (!HTMLHint) HTMLHint = window.HTMLHint;
  40      if (!HTMLHint) {
  41        if (window.console) {
  42            window.console.error("Error: HTMLHint not found, not defined on window, or not available through define/require, CodeMirror HTML linting cannot run.");
  43        }
  44        return found;
  45      }
  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;
  50        found.push({
  51          from: CodeMirror.Pos(startLine, startCol),
  52          to: CodeMirror.Pos(endLine, endCol),
  53          message: message.message,
  54          severity : message.type
  55        });
  56      }
  57      return found;
  58    });
  59  });


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer