html-hint.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. (function () {
  2. 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(" ");
  3. var targets = ["_blank", "_self", "_top", "_parent"];
  4. var charsets = ["ascii", "utf-8", "utf-16", "latin1", "latin1"];
  5. var methods = ["get", "post", "put", "delete"];
  6. var encs = ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"];
  7. var media = ["all", "screen", "print", "embossed", "braille", "handheld", "print", "projection", "screen", "tty", "tv", "speech",
  8. "3d-glasses", "resolution [>][<][=] [X]", "device-aspect-ratio: X/Y", "orientation:portrait",
  9. "orientation:landscape", "device-height: [X]", "device-width: [X]"];
  10. var s = { attrs: {} }; // Simple tag, reused for a whole lot of tags
  11. var data = {
  12. a: {
  13. attrs: {
  14. href: null, ping: null, type: null,
  15. media: media,
  16. target: targets,
  17. hreflang: langs
  18. }
  19. },
  20. abbr: s,
  21. acronym: s,
  22. address: s,
  23. applet: s,
  24. area: {
  25. attrs: {
  26. alt: null, coords: null, href: null, target: null, ping: null,
  27. media: media, hreflang: langs, type: null,
  28. shape: ["default", "rect", "circle", "poly"]
  29. }
  30. },
  31. article: s,
  32. aside: s,
  33. audio: {
  34. attrs: {
  35. src: null, mediagroup: null,
  36. crossorigin: ["anonymous", "use-credentials"],
  37. preload: ["none", "metadata", "auto"],
  38. autoplay: ["", "autoplay"],
  39. loop: ["", "loop"],
  40. controls: ["", "controls"]
  41. }
  42. },
  43. b: s,
  44. base: { attrs: { href: null, target: targets } },
  45. basefont: s,
  46. bdi: s,
  47. bdo: s,
  48. big: s,
  49. blockquote: { attrs: { cite: null } },
  50. body: s,
  51. br: s,
  52. button: {
  53. attrs: {
  54. form: null, formaction: null, name: null, value: null,
  55. autofocus: ["", "autofocus"],
  56. disabled: ["", "autofocus"],
  57. formenctype: encs,
  58. formmethod: methods,
  59. formnovalidate: ["", "novalidate"],
  60. formtarget: targets,
  61. type: ["submit", "reset", "button"]
  62. }
  63. },
  64. canvas: { attrs: { width: null, height: null } },
  65. caption: s,
  66. center: s,
  67. cite: s,
  68. code: s,
  69. col: { attrs: { span: null } },
  70. colgroup: { attrs: { span: null } },
  71. command: {
  72. attrs: {
  73. type: ["command", "checkbox", "radio"],
  74. label: null, icon: null, radiogroup: null, command: null, title: null,
  75. disabled: ["", "disabled"],
  76. checked: ["", "checked"]
  77. }
  78. },
  79. data: { attrs: { value: null } },
  80. datagrid: { attrs: { disabled: ["", "disabled"], multiple: ["", "multiple"] } },
  81. datalist: { attrs: { data: null } },
  82. dd: s,
  83. del: { attrs: { cite: null, datetime: null } },
  84. details: { attrs: { open: ["", "open"] } },
  85. dfn: s,
  86. dir: s,
  87. div: s,
  88. dl: s,
  89. dt: s,
  90. em: s,
  91. embed: { attrs: { src: null, type: null, width: null, height: null } },
  92. eventsource: { attrs: { src: null } },
  93. fieldset: { attrs: { disabled: ["", "disabled"], form: null, name: null } },
  94. figcaption: s,
  95. figure: s,
  96. font: s,
  97. footer: s,
  98. form: {
  99. attrs: {
  100. action: null, name: null,
  101. "accept-charset": charsets,
  102. autocomplete: ["on", "off"],
  103. enctype: encs,
  104. method: methods,
  105. novalidate: ["", "novalidate"],
  106. target: targets
  107. }
  108. },
  109. frame: s,
  110. frameset: s,
  111. h1: s, h2: s, h3: s, h4: s, h5: s, h6: s,
  112. head: {
  113. attrs: {},
  114. children: ["title", "base", "link", "style", "meta", "script", "noscript", "command"]
  115. },
  116. header: s,
  117. hgroup: s,
  118. hr: s,
  119. html: {
  120. attrs: { manifest: null },
  121. children: ["head", "body"]
  122. },
  123. i: s,
  124. iframe: {
  125. attrs: {
  126. src: null, srcdoc: null, name: null, width: null, height: null,
  127. sandbox: ["allow-top-navigation", "allow-same-origin", "allow-forms", "allow-scripts"],
  128. seamless: ["", "seamless"]
  129. }
  130. },
  131. img: {
  132. attrs: {
  133. alt: null, src: null, ismap: null, usemap: null, width: null, height: null,
  134. crossorigin: ["anonymous", "use-credentials"]
  135. }
  136. },
  137. input: {
  138. attrs: {
  139. alt: null, dirname: null, form: null, formaction: null,
  140. height: null, list: null, max: null, maxlength: null, min: null,
  141. name: null, pattern: null, placeholder: null, size: null, src: null,
  142. step: null, value: null, width: null,
  143. accept: ["audio/*", "video/*", "image/*"],
  144. autocomplete: ["on", "off"],
  145. autofocus: ["", "autofocus"],
  146. checked: ["", "checked"],
  147. disabled: ["", "disabled"],
  148. formenctype: encs,
  149. formmethod: methods,
  150. formnovalidate: ["", "novalidate"],
  151. formtarget: targets,
  152. multiple: ["", "multiple"],
  153. readonly: ["", "readonly"],
  154. required: ["", "required"],
  155. type: ["hidden", "text", "search", "tel", "url", "email", "password", "datetime", "date", "month",
  156. "week", "time", "datetime-local", "number", "range", "color", "checkbox", "radio",
  157. "file", "submit", "image", "reset", "button"]
  158. }
  159. },
  160. ins: { attrs: { cite: null, datetime: null } },
  161. kbd: s,
  162. keygen: {
  163. attrs: {
  164. challenge: null, form: null, name: null,
  165. autofocus: ["", "autofocus"],
  166. disabled: ["", "disabled"],
  167. keytype: ["RSA"]
  168. }
  169. },
  170. label: { attrs: { "for": null, form: null } },
  171. legend: s,
  172. li: { attrs: { value: null } },
  173. link: {
  174. attrs: {
  175. href: null, type: null,
  176. hreflang: langs,
  177. media: media,
  178. sizes: ["all", "16x16", "16x16 32x32", "16x16 32x32 64x64"]
  179. }
  180. },
  181. map: { attrs: { name: null } },
  182. mark: s,
  183. menu: { attrs: { label: null, type: ["list", "context", "toolbar"] } },
  184. meta: {
  185. attrs: {
  186. content: null,
  187. charset: charsets,
  188. name: ["viewport", "application-name", "author", "description", "generator", "keywords"],
  189. "http-equiv": ["content-language", "content-type", "default-style", "refresh"]
  190. }
  191. },
  192. meter: { attrs: { value: null, min: null, low: null, high: null, max: null, optimum: null } },
  193. nav: s,
  194. noframes: s,
  195. noscript: s,
  196. object: {
  197. attrs: {
  198. data: null, type: null, name: null, usemap: null, form: null, width: null, height: null,
  199. typemustmatch: ["", "typemustmatch"]
  200. }
  201. },
  202. ol: { attrs: { reversed: ["", "reversed"], start: null, type: ["1", "a", "A", "i", "I"] } },
  203. optgroup: { attrs: { disabled: ["", "disabled"], label: null } },
  204. option: { attrs: { disabled: ["", "disabled"], label: null, selected: ["", "selected"], value: null } },
  205. output: { attrs: { "for": null, form: null, name: null } },
  206. p: s,
  207. param: { attrs: { name: null, value: null } },
  208. pre: s,
  209. progress: { attrs: { value: null, max: null } },
  210. q: { attrs: { cite: null } },
  211. rp: s,
  212. rt: s,
  213. ruby: s,
  214. s: s,
  215. samp: s,
  216. script: {
  217. attrs: {
  218. type: ["text/javascript"],
  219. src: null,
  220. async: ["", "async"],
  221. defer: ["", "defer"],
  222. charset: charsets
  223. }
  224. },
  225. section: s,
  226. select: {
  227. attrs: {
  228. form: null, name: null, size: null,
  229. autofocus: ["", "autofocus"],
  230. disabled: ["", "disabled"],
  231. multiple: ["", "multiple"]
  232. }
  233. },
  234. small: s,
  235. source: { attrs: { src: null, type: null, media: null } },
  236. span: s,
  237. strike: s,
  238. strong: s,
  239. style: {
  240. attrs: {
  241. type: ["text/css"],
  242. media: media,
  243. scoped: null
  244. }
  245. },
  246. sub: s,
  247. summary: s,
  248. sup: s,
  249. table: s,
  250. tbody: s,
  251. td: { attrs: { colspan: null, rowspan: null, headers: null } },
  252. textarea: {
  253. attrs: {
  254. dirname: null, form: null, maxlength: null, name: null, placeholder: null,
  255. rows: null, cols: null,
  256. autofocus: ["", "autofocus"],
  257. disabled: ["", "disabled"],
  258. readonly: ["", "readonly"],
  259. required: ["", "required"],
  260. wrap: ["soft", "hard"]
  261. }
  262. },
  263. tfoot: s,
  264. th: { attrs: { colspan: null, rowspan: null, headers: null, scope: ["row", "col", "rowgroup", "colgroup"] } },
  265. thead: s,
  266. time: { attrs: { datetime: null } },
  267. title: s,
  268. tr: s,
  269. track: {
  270. attrs: {
  271. src: null, label: null, "default": null,
  272. kind: ["subtitles", "captions", "descriptions", "chapters", "metadata"],
  273. srclang: langs
  274. }
  275. },
  276. tt: s,
  277. u: s,
  278. ul: s,
  279. "var": s,
  280. video: {
  281. attrs: {
  282. src: null, poster: null, width: null, height: null,
  283. crossorigin: ["anonymous", "use-credentials"],
  284. preload: ["auto", "metadata", "none"],
  285. autoplay: ["", "autoplay"],
  286. mediagroup: ["movie"],
  287. muted: ["", "muted"],
  288. controls: ["", "controls"]
  289. }
  290. },
  291. wbr: s
  292. };
  293. var globalAttrs = {
  294. 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"],
  295. "class": null,
  296. contenteditable: ["true", "false"],
  297. contextmenu: null,
  298. dir: ["ltr", "rtl", "auto"],
  299. draggable: ["true", "false", "auto"],
  300. dropzone: ["copy", "move", "link", "string:", "file:"],
  301. hidden: ["hidden"],
  302. id: null,
  303. inert: ["inert"],
  304. itemid: null,
  305. itemprop: null,
  306. itemref: null,
  307. itemscope: ["itemscope"],
  308. itemtype: null,
  309. lang: ["en", "es"],
  310. spellcheck: ["true", "false"],
  311. style: null,
  312. tabindex: ["1", "2", "3", "4", "5", "6", "7", "8", "9"],
  313. title: null,
  314. translate: ["yes", "no"],
  315. onclick: null,
  316. rel: ["stylesheet", "alternate", "author", "bookmark", "help", "license", "next", "nofollow", "noreferrer", "prefetch", "prev", "search", "tag"]
  317. };
  318. function populate(obj) {
  319. for (var attr in globalAttrs) if (globalAttrs.hasOwnProperty(attr))
  320. obj.attrs[attr] = globalAttrs[attr];
  321. }
  322. populate(s);
  323. for (var tag in data) if (data.hasOwnProperty(tag) && data[tag] != s)
  324. populate(data[tag]);
  325. CodeMirror.htmlSchema = data;
  326. function htmlHint(cm, options) {
  327. var local = {schemaInfo: data};
  328. if (options) for (var opt in options) local[opt] = options[opt];
  329. return CodeMirror.hint.xml(cm, local);
  330. }
  331. CodeMirror.htmlHint = htmlHint; // deprecated
  332. CodeMirror.registerHelper("hint", "html", htmlHint);
  333. })();