meta.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  2. // Distributed under an MIT license: https://codemirror.net/LICENSE
  3. ;(function (mod) {
  4. if (typeof exports == 'object' && typeof module == 'object')
  5. // CommonJS
  6. mod(require('../lib/codemirror'))
  7. else if (typeof define == 'function' && define.amd)
  8. // AMD
  9. define(['../lib/codemirror'], mod)
  10. // Plain browser env
  11. else mod(CodeMirror)
  12. })(function (CodeMirror) {
  13. 'use strict'
  14. CodeMirror.modeInfo = [
  15. { name: 'APL', mime: 'text/apl', mode: 'apl', ext: ['dyalog', 'apl'] },
  16. { name: 'PGP', mimes: ['application/pgp', 'application/pgp-encrypted', 'application/pgp-keys', 'application/pgp-signature'], mode: 'asciiarmor', ext: ['asc', 'pgp', 'sig'] },
  17. { name: 'ASN.1', mime: 'text/x-ttcn-asn', mode: 'asn.1', ext: ['asn', 'asn1'] },
  18. { name: 'Asterisk', mime: 'text/x-asterisk', mode: 'asterisk', file: /^extensions\.conf$/i },
  19. { name: 'Brainfuck', mime: 'text/x-brainfuck', mode: 'brainfuck', ext: ['b', 'bf'] },
  20. { name: 'C', mime: 'text/x-csrc', mode: 'clike', ext: ['c', 'h', 'ino'] },
  21. { name: 'C++', mime: 'text/x-c++src', mode: 'clike', ext: ['cpp', 'c++', 'cc', 'cxx', 'hpp', 'h++', 'hh', 'hxx'], alias: ['cpp'] },
  22. { name: 'Cobol', mime: 'text/x-cobol', mode: 'cobol', ext: ['cob', 'cpy', 'cbl'] },
  23. { name: 'C#', mime: 'text/x-csharp', mode: 'clike', ext: ['cs'], alias: ['csharp', 'cs'] },
  24. { name: 'Clojure', mime: 'text/x-clojure', mode: 'clojure', ext: ['clj', 'cljc', 'cljx'] },
  25. { name: 'ClojureScript', mime: 'text/x-clojurescript', mode: 'clojure', ext: ['cljs'] },
  26. { name: 'Closure Stylesheets (GSS)', mime: 'text/x-gss', mode: 'css', ext: ['gss'] },
  27. { name: 'CMake', mime: 'text/x-cmake', mode: 'cmake', ext: ['cmake', 'cmake.in'], file: /^CMakeLists\.txt$/ },
  28. { name: 'CoffeeScript', mimes: ['application/vnd.coffeescript', 'text/coffeescript', 'text/x-coffeescript'], mode: 'coffeescript', ext: ['coffee'], alias: ['coffee', 'coffee-script'] },
  29. { name: 'Common Lisp', mime: 'text/x-common-lisp', mode: 'commonlisp', ext: ['cl', 'lisp', 'el'], alias: ['lisp'] },
  30. { name: 'Cypher', mime: 'application/x-cypher-query', mode: 'cypher', ext: ['cyp', 'cypher'] },
  31. { name: 'Cython', mime: 'text/x-cython', mode: 'python', ext: ['pyx', 'pxd', 'pxi'] },
  32. { name: 'Crystal', mime: 'text/x-crystal', mode: 'crystal', ext: ['cr'] },
  33. { name: 'CSS', mime: 'text/css', mode: 'css', ext: ['css'] },
  34. { name: 'CQL', mime: 'text/x-cassandra', mode: 'sql', ext: ['cql'] },
  35. { name: 'D', mime: 'text/x-d', mode: 'd', ext: ['d'] },
  36. { name: 'Dart', mimes: ['application/dart', 'text/x-dart'], mode: 'dart', ext: ['dart'] },
  37. { name: 'diff', mime: 'text/x-diff', mode: 'diff', ext: ['diff', 'patch'] },
  38. { name: 'Django', mime: 'text/x-django', mode: 'django' },
  39. { name: 'Dockerfile', mime: 'text/x-dockerfile', mode: 'dockerfile', file: /^Dockerfile$/ },
  40. { name: 'DTD', mime: 'application/xml-dtd', mode: 'dtd', ext: ['dtd'] },
  41. { name: 'Dylan', mime: 'text/x-dylan', mode: 'dylan', ext: ['dylan', 'dyl', 'intr'] },
  42. { name: 'EBNF', mime: 'text/x-ebnf', mode: 'ebnf' },
  43. { name: 'ECL', mime: 'text/x-ecl', mode: 'ecl', ext: ['ecl'] },
  44. { name: 'edn', mime: 'application/edn', mode: 'clojure', ext: ['edn'] },
  45. { name: 'Eiffel', mime: 'text/x-eiffel', mode: 'eiffel', ext: ['e'] },
  46. { name: 'Elm', mime: 'text/x-elm', mode: 'elm', ext: ['elm'] },
  47. { name: 'Embedded JavaScript', mime: 'application/x-ejs', mode: 'htmlembedded', ext: ['ejs'] },
  48. { name: 'Embedded Ruby', mime: 'application/x-erb', mode: 'htmlembedded', ext: ['erb'] },
  49. { name: 'Erlang', mime: 'text/x-erlang', mode: 'erlang', ext: ['erl'] },
  50. { name: 'Esper', mime: 'text/x-esper', mode: 'sql' },
  51. { name: 'Factor', mime: 'text/x-factor', mode: 'factor', ext: ['factor'] },
  52. { name: 'FCL', mime: 'text/x-fcl', mode: 'fcl' },
  53. { name: 'Forth', mime: 'text/x-forth', mode: 'forth', ext: ['forth', 'fth', '4th'] },
  54. { name: 'Fortran', mime: 'text/x-fortran', mode: 'fortran', ext: ['f', 'for', 'f77', 'f90', 'f95'] },
  55. { name: 'F#', mime: 'text/x-fsharp', mode: 'mllike', ext: ['fs'], alias: ['fsharp'] },
  56. { name: 'Gas', mime: 'text/x-gas', mode: 'gas', ext: ['s'] },
  57. { name: 'Gherkin', mime: 'text/x-feature', mode: 'gherkin', ext: ['feature'] },
  58. { name: 'GitHub Flavored Markdown', mime: 'text/x-gfm', mode: 'gfm', file: /^(readme|contributing|history)\.md$/i },
  59. { name: 'Go', mime: 'text/x-go', mode: 'go', ext: ['go'] },
  60. { name: 'Groovy', mime: 'text/x-groovy', mode: 'groovy', ext: ['groovy', 'gradle'], file: /^Jenkinsfile$/ },
  61. { name: 'HAML', mime: 'text/x-haml', mode: 'haml', ext: ['haml'] },
  62. { name: 'Haskell', mime: 'text/x-haskell', mode: 'haskell', ext: ['hs'] },
  63. { name: 'Haskell (Literate)', mime: 'text/x-literate-haskell', mode: 'haskell-literate', ext: ['lhs'] },
  64. { name: 'Haxe', mime: 'text/x-haxe', mode: 'haxe', ext: ['hx'] },
  65. { name: 'HXML', mime: 'text/x-hxml', mode: 'haxe', ext: ['hxml'] },
  66. { name: 'ASP.NET', mime: 'application/x-aspx', mode: 'htmlembedded', ext: ['aspx'], alias: ['asp', 'aspx'] },
  67. { name: 'HTML', mime: 'text/html', mode: 'htmlmixed', ext: ['html', 'htm', 'handlebars', 'hbs'], alias: ['xhtml'] },
  68. { name: 'HTTP', mime: 'message/http', mode: 'http' },
  69. { name: 'IDL', mime: 'text/x-idl', mode: 'idl', ext: ['pro'] },
  70. { name: 'Pug', mime: 'text/x-pug', mode: 'pug', ext: ['jade', 'pug'], alias: ['jade'] },
  71. { name: 'Java', mime: 'text/x-java', mode: 'clike', ext: ['java'] },
  72. { name: 'Java Server Pages', mime: 'application/x-jsp', mode: 'htmlembedded', ext: ['jsp'], alias: ['jsp'] },
  73. {
  74. name: 'JavaScript',
  75. mimes: ['text/javascript', 'text/ecmascript', 'application/javascript', 'application/x-javascript', 'application/ecmascript'],
  76. mode: 'javascript',
  77. ext: ['js'],
  78. alias: ['ecmascript', 'js', 'node'],
  79. },
  80. { name: 'JSON', mimes: ['application/json', 'application/x-json'], mode: 'javascript', ext: ['json', 'map'], alias: ['json5'] },
  81. { name: 'JSON-LD', mime: 'application/ld+json', mode: 'javascript', ext: ['jsonld'], alias: ['jsonld'] },
  82. { name: 'JSX', mime: 'text/jsx', mode: 'jsx', ext: ['jsx'] },
  83. { name: 'Jinja2', mime: 'text/jinja2', mode: 'jinja2', ext: ['j2', 'jinja', 'jinja2'] },
  84. { name: 'Julia', mime: 'text/x-julia', mode: 'julia', ext: ['jl'], alias: ['jl'] },
  85. { name: 'Kotlin', mime: 'text/x-kotlin', mode: 'clike', ext: ['kt'] },
  86. { name: 'LESS', mime: 'text/x-less', mode: 'css', ext: ['less'] },
  87. { name: 'LiveScript', mime: 'text/x-livescript', mode: 'livescript', ext: ['ls'], alias: ['ls'] },
  88. { name: 'Lua', mime: 'text/x-lua', mode: 'lua', ext: ['lua'] },
  89. { name: 'Markdown', mime: 'text/x-markdown', mode: 'markdown', ext: ['markdown', 'md', 'mkd'] },
  90. { name: 'mIRC', mime: 'text/mirc', mode: 'mirc' },
  91. { name: 'MariaDB SQL', mime: 'text/x-mariadb', mode: 'sql' },
  92. { name: 'Mathematica', mime: 'text/x-mathematica', mode: 'mathematica', ext: ['m', 'nb', 'wl', 'wls'] },
  93. { name: 'Modelica', mime: 'text/x-modelica', mode: 'modelica', ext: ['mo'] },
  94. { name: 'MUMPS', mime: 'text/x-mumps', mode: 'mumps', ext: ['mps'] },
  95. { name: 'MS SQL', mime: 'text/x-mssql', mode: 'sql' },
  96. { name: 'mbox', mime: 'application/mbox', mode: 'mbox', ext: ['mbox'] },
  97. { name: 'MySQL', mime: 'text/x-mysql', mode: 'sql' },
  98. { name: 'Nginx', mime: 'text/x-nginx-conf', mode: 'nginx', file: /nginx.*\.conf$/i },
  99. { name: 'NSIS', mime: 'text/x-nsis', mode: 'nsis', ext: ['nsh', 'nsi'] },
  100. { name: 'NTriples', mimes: ['application/n-triples', 'application/n-quads', 'text/n-triples'], mode: 'ntriples', ext: ['nt', 'nq'] },
  101. { name: 'Objective-C', mime: 'text/x-objectivec', mode: 'clike', ext: ['m'], alias: ['objective-c', 'objc'] },
  102. { name: 'Objective-C++', mime: 'text/x-objectivec++', mode: 'clike', ext: ['mm'], alias: ['objective-c++', 'objc++'] },
  103. { name: 'OCaml', mime: 'text/x-ocaml', mode: 'mllike', ext: ['ml', 'mli', 'mll', 'mly'] },
  104. { name: 'Octave', mime: 'text/x-octave', mode: 'octave', ext: ['m'] },
  105. { name: 'Oz', mime: 'text/x-oz', mode: 'oz', ext: ['oz'] },
  106. { name: 'Pascal', mime: 'text/x-pascal', mode: 'pascal', ext: ['p', 'pas'] },
  107. { name: 'PEG.js', mime: 'null', mode: 'pegjs', ext: ['jsonld'] },
  108. { name: 'Perl', mime: 'text/x-perl', mode: 'perl', ext: ['pl', 'pm'] },
  109. { name: 'PHP', mimes: ['text/x-php', 'application/x-httpd-php', 'application/x-httpd-php-open'], mode: 'php', ext: ['php', 'php3', 'php4', 'php5', 'php7', 'phtml'] },
  110. { name: 'Pig', mime: 'text/x-pig', mode: 'pig', ext: ['pig'] },
  111. { name: 'Plain Text', mime: 'text/plain', mode: 'null', ext: ['txt', 'text', 'conf', 'def', 'list', 'log'] },
  112. { name: 'PLSQL', mime: 'text/x-plsql', mode: 'sql', ext: ['pls'] },
  113. { name: 'PostgreSQL', mime: 'text/x-pgsql', mode: 'sql' },
  114. { name: 'PowerShell', mime: 'application/x-powershell', mode: 'powershell', ext: ['ps1', 'psd1', 'psm1'] },
  115. { name: 'Properties files', mime: 'text/x-properties', mode: 'properties', ext: ['properties', 'ini', 'in'], alias: ['ini', 'properties'] },
  116. { name: 'ProtoBuf', mime: 'text/x-protobuf', mode: 'protobuf', ext: ['proto'] },
  117. { name: 'Python', mime: 'text/x-python', mode: 'python', ext: ['BUILD', 'bzl', 'py', 'pyw'], file: /^(BUCK|BUILD)$/ },
  118. { name: 'Puppet', mime: 'text/x-puppet', mode: 'puppet', ext: ['pp'] },
  119. { name: 'Q', mime: 'text/x-q', mode: 'q', ext: ['q'] },
  120. { name: 'R', mime: 'text/x-rsrc', mode: 'r', ext: ['r', 'R'], alias: ['rscript'] },
  121. { name: 'reStructuredText', mime: 'text/x-rst', mode: 'rst', ext: ['rst'], alias: ['rst'] },
  122. { name: 'RPM Changes', mime: 'text/x-rpm-changes', mode: 'rpm' },
  123. { name: 'RPM Spec', mime: 'text/x-rpm-spec', mode: 'rpm', ext: ['spec'] },
  124. { name: 'Ruby', mime: 'text/x-ruby', mode: 'ruby', ext: ['rb'], alias: ['jruby', 'macruby', 'rake', 'rb', 'rbx'] },
  125. { name: 'Rust', mime: 'text/x-rustsrc', mode: 'rust', ext: ['rs'] },
  126. { name: 'SAS', mime: 'text/x-sas', mode: 'sas', ext: ['sas'] },
  127. { name: 'Sass', mime: 'text/x-sass', mode: 'sass', ext: ['sass'] },
  128. { name: 'Scala', mime: 'text/x-scala', mode: 'clike', ext: ['scala'] },
  129. { name: 'Scheme', mime: 'text/x-scheme', mode: 'scheme', ext: ['scm', 'ss'] },
  130. { name: 'SCSS', mime: 'text/x-scss', mode: 'css', ext: ['scss'] },
  131. { name: 'Shell', mimes: ['text/x-sh', 'application/x-sh'], mode: 'shell', ext: ['sh', 'ksh', 'bash'], alias: ['bash', 'sh', 'zsh'], file: /^PKGBUILD$/ },
  132. { name: 'Sieve', mime: 'application/sieve', mode: 'sieve', ext: ['siv', 'sieve'] },
  133. { name: 'Slim', mimes: ['text/x-slim', 'application/x-slim'], mode: 'slim', ext: ['slim'] },
  134. { name: 'Smalltalk', mime: 'text/x-stsrc', mode: 'smalltalk', ext: ['st'] },
  135. { name: 'Smarty', mime: 'text/x-smarty', mode: 'smarty', ext: ['tpl'] },
  136. { name: 'Solr', mime: 'text/x-solr', mode: 'solr' },
  137. { name: 'SML', mime: 'text/x-sml', mode: 'mllike', ext: ['sml', 'sig', 'fun', 'smackspec'] },
  138. { name: 'Soy', mime: 'text/x-soy', mode: 'soy', ext: ['soy'], alias: ['closure template'] },
  139. { name: 'SPARQL', mime: 'application/sparql-query', mode: 'sparql', ext: ['rq', 'sparql'], alias: ['sparul'] },
  140. { name: 'Spreadsheet', mime: 'text/x-spreadsheet', mode: 'spreadsheet', alias: ['excel', 'formula'] },
  141. { name: 'SQL', mime: 'text/x-sql', mode: 'sql', ext: ['sql'] },
  142. { name: 'SQLite', mime: 'text/x-sqlite', mode: 'sql' },
  143. { name: 'Squirrel', mime: 'text/x-squirrel', mode: 'clike', ext: ['nut'] },
  144. { name: 'Stylus', mime: 'text/x-styl', mode: 'stylus', ext: ['styl'] },
  145. { name: 'Swift', mime: 'text/x-swift', mode: 'swift', ext: ['swift'] },
  146. { name: 'sTeX', mime: 'text/x-stex', mode: 'stex' },
  147. { name: 'LaTeX', mime: 'text/x-latex', mode: 'stex', ext: ['text', 'ltx', 'tex'], alias: ['tex'] },
  148. { name: 'SystemVerilog', mime: 'text/x-systemverilog', mode: 'verilog', ext: ['v', 'sv', 'svh'] },
  149. { name: 'Tcl', mime: 'text/x-tcl', mode: 'tcl', ext: ['tcl'] },
  150. { name: 'Textile', mime: 'text/x-textile', mode: 'textile', ext: ['textile'] },
  151. { name: 'TiddlyWiki', mime: 'text/x-tiddlywiki', mode: 'tiddlywiki' },
  152. { name: 'Tiki wiki', mime: 'text/tiki', mode: 'tiki' },
  153. { name: 'TOML', mime: 'text/x-toml', mode: 'toml', ext: ['toml'] },
  154. { name: 'Tornado', mime: 'text/x-tornado', mode: 'tornado' },
  155. { name: 'troff', mime: 'text/troff', mode: 'troff', ext: ['1', '2', '3', '4', '5', '6', '7', '8', '9'] },
  156. { name: 'TTCN', mime: 'text/x-ttcn', mode: 'ttcn', ext: ['ttcn', 'ttcn3', 'ttcnpp'] },
  157. { name: 'TTCN_CFG', mime: 'text/x-ttcn-cfg', mode: 'ttcn-cfg', ext: ['cfg'] },
  158. { name: 'Turtle', mime: 'text/turtle', mode: 'turtle', ext: ['ttl'] },
  159. { name: 'TypeScript', mime: 'application/typescript', mode: 'javascript', ext: ['ts'], alias: ['ts'] },
  160. { name: 'TypeScript-JSX', mime: 'text/typescript-jsx', mode: 'jsx', ext: ['tsx'], alias: ['tsx'] },
  161. { name: 'Twig', mime: 'text/x-twig', mode: 'twig' },
  162. { name: 'Web IDL', mime: 'text/x-webidl', mode: 'webidl', ext: ['webidl'] },
  163. { name: 'VB.NET', mime: 'text/x-vb', mode: 'vb', ext: ['vb'] },
  164. { name: 'VBScript', mime: 'text/vbscript', mode: 'vbscript', ext: ['vbs'] },
  165. { name: 'Velocity', mime: 'text/velocity', mode: 'velocity', ext: ['vtl'] },
  166. { name: 'Verilog', mime: 'text/x-verilog', mode: 'verilog', ext: ['v'] },
  167. { name: 'VHDL', mime: 'text/x-vhdl', mode: 'vhdl', ext: ['vhd', 'vhdl'] },
  168. { name: 'Vue.js Component', mimes: ['script/x-vue', 'text/x-vue'], mode: 'vue', ext: ['vue'] },
  169. { name: 'XML', mimes: ['application/xml', 'text/xml'], mode: 'xml', ext: ['xml', 'xsl', 'xsd', 'svg'], alias: ['rss', 'wsdl', 'xsd'] },
  170. { name: 'XQuery', mime: 'application/xquery', mode: 'xquery', ext: ['xy', 'xquery'] },
  171. { name: 'Yacas', mime: 'text/x-yacas', mode: 'yacas', ext: ['ys'] },
  172. { name: 'YAML', mimes: ['text/x-yaml', 'text/yaml'], mode: 'yaml', ext: ['yaml', 'yml'], alias: ['yml'] },
  173. { name: 'Z80', mime: 'text/x-z80', mode: 'z80', ext: ['z80'] },
  174. { name: 'mscgen', mime: 'text/x-mscgen', mode: 'mscgen', ext: ['mscgen', 'mscin', 'msc'] },
  175. { name: 'xu', mime: 'text/x-xu', mode: 'mscgen', ext: ['xu'] },
  176. { name: 'msgenny', mime: 'text/x-msgenny', mode: 'mscgen', ext: ['msgenny'] },
  177. { name: 'WebAssembly', mime: 'text/webassembly', mode: 'wast', ext: ['wat', 'wast'] },
  178. ]
  179. // Ensure all modes have a mime property for backwards compatibility
  180. for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
  181. var info = CodeMirror.modeInfo[i]
  182. if (info.mimes) info.mime = info.mimes[0]
  183. }
  184. CodeMirror.findModeByMIME = function (mime) {
  185. mime = mime.toLowerCase()
  186. for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
  187. var info = CodeMirror.modeInfo[i]
  188. if (info.mime == mime) return info
  189. if (info.mimes) for (var j = 0; j < info.mimes.length; j++) if (info.mimes[j] == mime) return info
  190. }
  191. if (/\+xml$/.test(mime)) return CodeMirror.findModeByMIME('application/xml')
  192. if (/\+json$/.test(mime)) return CodeMirror.findModeByMIME('application/json')
  193. }
  194. CodeMirror.findModeByExtension = function (ext) {
  195. ext = ext.toLowerCase()
  196. for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
  197. var info = CodeMirror.modeInfo[i]
  198. if (info.ext) for (var j = 0; j < info.ext.length; j++) if (info.ext[j] == ext) return info
  199. }
  200. }
  201. CodeMirror.findModeByFileName = function (filename) {
  202. for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
  203. var info = CodeMirror.modeInfo[i]
  204. if (info.file && info.file.test(filename)) return info
  205. }
  206. var dot = filename.lastIndexOf('.')
  207. var ext = dot > -1 && filename.substring(dot + 1, filename.length)
  208. if (ext) return CodeMirror.findModeByExtension(ext)
  209. }
  210. CodeMirror.findModeByName = function (name) {
  211. name = name.toLowerCase()
  212. for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
  213. var info = CodeMirror.modeInfo[i]
  214. if (info.name.toLowerCase() == name) return info
  215. if (info.alias) for (var j = 0; j < info.alias.length; j++) if (info.alias[j].toLowerCase() == name) return info
  216. }
  217. }
  218. })