html-hint.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. (function(mod) {
  2. if (typeof exports == "object" && typeof module == "object") // CommonJS
  3. mod(require("../../lib/codemirror"));
  4. else if (typeof define == "function" && define.amd) // AMD
  5. define(["../../lib/codemirror"], mod);
  6. else // Plain browser env
  7. mod(CodeMirror);
  8. })(function(CodeMirror) {
  9. "use strict";
  10. var langs = "ab aa af ak sq am ar an hy as av ae ay az bm ba eu be bn bh bi bs br bg my ca ch ce ny zh cv kw co cr hr cs da dv nl dz en eo et ee fo fj fi fr ff gl ka de el gn gu ht ha he hz hi ho hu ia id ie ga ig ik io is it iu ja jv kl kn kr ks kk km ki rw ky kv kg ko ku kj la lb lg li ln lo lt lu lv gv mk mg ms ml mt mi mr mh mn na nv nb nd ne ng nn no ii nr oc oj cu om or os pa pi fa pl ps pt qu rm rn ro ru sa sc sd se sm sg sr gd sn si sk sl so st es su sw ss sv ta te tg th ti bo tk tl tn to tr ts tt tw ty ug uk ur uz ve vi vo wa cy wo fy xh yi yo za zu".split(" ");
  11. var targets = ["_blank", "_self", "_top", "_parent"];
  12. var charsets = ["ascii", "utf-8", "utf-16", "latin1", "latin1"];
  13. var methods = ["get", "post", "put", "delete"];
  14. var encs = ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"];
  15. var media = ["all", "screen", "print", "embossed", "braille", "handheld", "print", "projection", "screen", "tty", "tv", "speech",
  16. "3d-glasses", "resolution [>][<][=] [X]", "device-aspect-ratio: X/Y", "orientation:portrait",
  17. "orientation:landscape", "device-height: [X]", "device-width: [X]"];
  18. var s = { attrs: {} }; // Simple tag, reused for a whole lot of tags
  19. var data = {
  20. a: {
  21. attrs: {
  22. href: null, ping: null, type: null,
  23. media: media,
  24. target: targets,
  25. hreflang: langs
  26. }
  27. },
  28. abbr: s,
  29. acronym: s,
  30. address: s,
  31. applet: s,
  32. area: {
  33. attrs: {
  34. alt: null, coords: null, href: null, target: null, ping: null,
  35. media: media, hreflang: langs, type: null,
  36. shape: ["default", "rect", "circle", "poly"]
  37. }
  38. },
  39. article: s,
  40. aside: s,
  41. audio: {
  42. attrs: {
  43. src: null, mediagroup: null,
  44. crossorigin: ["anonymous", "use-credentials"],
  45. preload: ["none", "metadata", "auto"],
  46. autoplay: ["", "autoplay"],
  47. loop: ["", "loop"],
  48. controls: ["", "controls"]
  49. }
  50. },
  51. b: s,
  52. base: { attrs: { href: null, target: targets } },
  53. basefont: s,
  54. bdi: s,
  55. bdo: s,
  56. big: s,
  57. blockquote: { attrs: { cite: null } },
  58. body: s,
  59. br: s,
  60. button: {
  61. attrs: {
  62. form: null, formaction: null, name: null, value: null,
  63. autofocus: ["", "autofocus"],
  64. disabled: ["", "autofocus"],
  65. formenctype: encs,
  66. formmethod: methods,
  67. formnovalidate: ["", "novalidate"],
  68. formtarget: targets,
  69. type: ["submit", "reset", "button"]
  70. }
  71. },
  72. canvas: { attrs: { width: null, height: null } },
  73. caption: s,
  74. center: s,
  75. cite: s,
  76. code: s,
  77. col: { attrs: { span: null } },
  78. colgroup: { attrs: { span: null } },
  79. command: {
  80. attrs: {
  81. type: ["command", "checkbox", "radio"],
  82. label: null, icon: null, radiogroup: null, command: null, title: null,
  83. disabled: ["", "disabled"],
  84. checked: ["", "checked"]
  85. }
  86. },
  87. data: { attrs: { value: null } },
  88. datagrid: { attrs: { disabled: ["", "disabled"], multiple: ["", "multiple"] } },
  89. datalist: { attrs: { data: null } },
  90. dd: s,
  91. del: { attrs: { cite: null, datetime: null } },
  92. details: { attrs: { open: ["", "open"] } },
  93. dfn: s,
  94. dir: s,
  95. div: s,
  96. dl: s,
  97. dt: s,
  98. em: s,
  99. embed: { attrs: { src: null, type: null, width: null, height: null } },
  100. eventsource: { attrs: { src: null } },
  101. fieldset: { attrs: { disabled: ["", "disabled"], form: null, name: null } },
  102. figcaption: s,
  103. figure: s,
  104. font: s,
  105. footer: s,
  106. form: {
  107. attrs: {
  108. action: null, name: null,
  109. "accept-charset": charsets,
  110. autocomplete: ["on", "off"],
  111. enctype: encs,
  112. method: methods,
  113. novalidate: ["", "novalidate"],
  114. target: targets
  115. }
  116. },
  117. frame: s,
  118. frameset: s,
  119. h1: s, h2: s, h3: s, h4: s, h5: s, h6: s,
  120. head: {
  121. attrs: {},
  122. children: ["title", "base", "link", "style", "meta", "script", "noscript", "command"]
  123. },
  124. header: s,
  125. hgroup: s,
  126. hr: s,
  127. html: {
  128. attrs: { manifest: null },
  129. children: ["head", "body"]
  130. },
  131. i: s,
  132. iframe: {
  133. attrs: {
  134. src: null, srcdoc: null, name: null, width: null, height: null,
  135. sandbox: ["allow-top-navigation", "allow-same-origin", "allow-forms", "allow-scripts"],
  136. seamless: ["", "seamless"]
  137. }
  138. },
  139. img: {
  140. attrs: {
  141. alt: null, src: null, ismap: null, usemap: null, width: null, height: null,
  142. crossorigin: ["anonymous", "use-credentials"]
  143. }
  144. },
  145. input: {
  146. attrs: {
  147. alt: null, dirname: null, form: null, formaction: null,
  148. height: null, list: null, max: null, maxlength: null, min: null,
  149. name: null, pattern: null, placeholder: null, size: null, src: null,
  150. step: null, value: null, width: null,
  151. accept: ["audio/*", "video/*", "image/*"],
  152. autocomplete: ["on", "off"],
  153. autofocus: ["", "autofocus"],
  154. checked: ["", "checked"],
  155. disabled: ["", "disabled"],
  156. formenctype: encs,
  157. formmethod: methods,
  158. formnovalidate: ["", "novalidate"],
  159. formtarget: targets,
  160. multiple: ["", "multiple"],
  161. readonly: ["", "readonly"],
  162. required: ["", "required"],
  163. type: ["hidden", "text", "search", "tel", "url", "email", "password", "datetime", "date", "month",
  164. "week", "time", "datetime-local", "number", "range", "color", "checkbox", "radio",
  165. "file", "submit", "image", "reset", "button"]
  166. }
  167. },
  168. ins: { attrs: { cite: null, datetime: null } },
  169. kbd: s,
  170. keygen: {
  171. attrs: {
  172. challenge: null, form: null, name: null,
  173. autofocus: ["", "autofocus"],
  174. disabled: ["", "disabled"],
  175. keytype: ["RSA"]
  176. }
  177. },
  178. label: { attrs: { "for": null, form: null } },
  179. legend: s,
  180. li: { attrs: { value: null } },
  181. link: {
  182. attrs: {
  183. href: null, type: null,
  184. hreflang: langs,
  185. media: media,
  186. sizes: ["all", "16x16", "16x16 32x32", "16x16 32x32 64x64"]
  187. }
  188. },
  189. map: { attrs: { name: null } },
  190. mark: s,
  191. menu: { attrs: { label: null, type: ["list", "context", "toolbar"] } },
  192. meta: {
  193. attrs: {
  194. content: null,
  195. charset: charsets,
  196. name: ["viewport", "application-name", "author", "description", "generator", "keywords"],
  197. "http-equiv": ["content-language", "content-type", "default-style", "refresh"]
  198. }
  199. },
  200. meter: { attrs: { value: null, min: null, low: null, high: null, max: null, optimum: null } },
  201. nav: s,
  202. noframes: s,
  203. noscript: s,
  204. object: {
  205. attrs: {
  206. data: null, type: null, name: null, usemap: null, form: null, width: null, height: null,
  207. typemustmatch: ["", "typemustmatch"]
  208. }
  209. },
  210. ol: { attrs: { reversed: ["", "reversed"], start: null, type: ["1", "a", "A", "i", "I"] } },
  211. optgroup: { attrs: { disabled: ["", "disabled"], label: null } },
  212. option: { attrs: { disabled: ["", "disabled"], label: null, selected: ["", "selected"], value: null } },
  213. output: { attrs: { "for": null, form: null, name: null } },
  214. p: s,
  215. param: { attrs: { name: null, value: null } },
  216. pre: s,
  217. progress: { attrs: { value: null, max: null } },
  218. q: { attrs: { cite: null } },
  219. rp: s,
  220. rt: s,
  221. ruby: s,
  222. s: s,
  223. samp: s,
  224. script: {
  225. attrs: {
  226. type: ["text/javascript"],
  227. src: null,
  228. async: ["", "async"],
  229. defer: ["", "defer"],
  230. charset: charsets
  231. }
  232. },
  233. section: s,
  234. select: {
  235. attrs: {
  236. form: null, name: null, size: null,
  237. autofocus: ["", "autofocus"],
  238. disabled: ["", "disabled"],
  239. multiple: ["", "multiple"]
  240. }
  241. },
  242. small: s,
  243. source: { attrs: { src: null, type: null, media: null } },
  244. span: s,
  245. strike: s,
  246. strong: s,
  247. style: {
  248. attrs: {
  249. type: ["text/css"],
  250. media: media,
  251. scoped: null
  252. }
  253. },
  254. sub: s,
  255. summary: s,
  256. sup: s,
  257. table: s,
  258. tbody: s,
  259. td: { attrs: { colspan: null, rowspan: null, headers: null } },
  260. textarea: {
  261. attrs: {
  262. dirname: null, form: null, maxlength: null, name: null, placeholder: null,
  263. rows: null, cols: null,
  264. autofocus: ["", "autofocus"],
  265. disabled: ["", "disabled"],
  266. readonly: ["", "readonly"],
  267. required: ["", "required"],
  268. wrap: ["soft", "hard"]
  269. }
  270. },
  271. tfoot: s,
  272. th: { attrs: { colspan: null, rowspan: null, headers: null, scope: ["row", "col", "rowgroup", "colgroup"] } },
  273. thead: s,
  274. time: { attrs: { datetime: null } },
  275. title: s,
  276. tr: s,
  277. track: {
  278. attrs: {
  279. src: null, label: null, "default": null,
  280. kind: ["subtitles", "captions", "descriptions", "chapters", "metadata"],
  281. srclang: langs
  282. }
  283. },
  284. tt: s,
  285. u: s,
  286. ul: s,
  287. "var": s,
  288. video: {
  289. attrs: {
  290. src: null, poster: null, width: null, height: null,
  291. crossorigin: ["anonymous", "use-credentials"],
  292. preload: ["auto", "metadata", "none"],
  293. autoplay: ["", "autoplay"],
  294. mediagroup: ["movie"],
  295. muted: ["", "muted"],
  296. controls: ["", "controls"]
  297. }
  298. },
  299. wbr: s
  300. };
  301. var globalAttrs = {
  302. accesskey: ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
  303. "class": null,
  304. contenteditable: ["true", "false"],
  305. contextmenu: null,
  306. dir: ["ltr", "rtl", "auto"],
  307. draggable: ["true", "false", "auto"],
  308. dropzone: ["copy", "move", "link", "string:", "file:"],
  309. hidden: ["hidden"],
  310. id: null,
  311. inert: ["inert"],
  312. itemid: null,
  313. itemprop: null,
  314. itemref: null,
  315. itemscope: ["itemscope"],
  316. itemtype: null,
  317. lang: ["en", "es"],
  318. spellcheck: ["true", "false"],
  319. style: null,
  320. tabindex: ["1", "2", "3", "4", "5", "6", "7", "8", "9"],
  321. title: null,
  322. translate: ["yes", "no"],
  323. onclick: null,
  324. rel: ["stylesheet", "alternate", "author", "bookmark", "help", "license", "next", "nofollow", "noreferrer", "prefetch", "prev", "search", "tag"]
  325. };
  326. function populate(obj) {
  327. for (var attr in globalAttrs) if (globalAttrs.hasOwnProperty(attr))
  328. obj.attrs[attr] = globalAttrs[attr];
  329. }
  330. populate(s);
  331. for (var tag in data) if (data.hasOwnProperty(tag) && data[tag] != s)
  332. populate(data[tag]);
  333. CodeMirror.htmlSchema = data;
  334. function htmlHint(cm, options) {
  335. var local = {schemaInfo: data};
  336. if (options) for (var opt in options) local[opt] = options[opt];
  337. return CodeMirror.hint.xml(cm, local);
  338. }
  339. CodeMirror.registerHelper("hint", "html", htmlHint);
  340. });