|
13 | 13 |
|
14 | 14 | CodeMirror.modeInfo = [
|
15 | 15 | {name: "APL", mime: "text/apl", mode: "apl", ext: ["dyalog", "apl"]},
|
16 |
| - {name: "Asterisk", mime: "text/x-asterisk", mode: "asterisk"}, |
| 16 | + {name: "Asterisk", mime: "text/x-asterisk", mode: "asterisk", file: /^extensions\.conf$/i}, |
17 | 17 | {name: "C", mime: "text/x-csrc", mode: "clike", ext: ["c", "h"]},
|
18 |
| - {name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "hpp", "h++"], alias: ["cpp"]}, |
| 18 | + {name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"], alias: ["cpp"]}, |
19 | 19 | {name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy"]},
|
20 | 20 | {name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"], alias: ["csharp"]},
|
21 | 21 | {name: "Clojure", mime: "text/x-clojure", mode: "clojure", ext: ["clj"]},
|
22 | 22 | {name: "CoffeeScript", mime: "text/x-coffeescript", mode: "coffeescript", ext: ["coffee"], alias: ["coffee", "coffee-script"]},
|
23 | 23 | {name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp", ext: ["cl", "lisp", "el"], alias: ["lisp"]},
|
24 |
| - {name: "Cypher", mime: "application/x-cypher-query", mode: "cypher"}, |
| 24 | + {name: "Cypher", mime: "application/x-cypher-query", mode: "cypher", ext: ["cyp", "cypher"]}, |
25 | 25 | {name: "Cython", mime: "text/x-cython", mode: "python", ext: ["pyx", "pxd", "pxi"]},
|
26 | 26 | {name: "CSS", mime: "text/css", mode: "css", ext: ["css"]},
|
27 | 27 | {name: "CQL", mime: "text/x-cassandra", mode: "sql", ext: ["cql"]},
|
28 | 28 | {name: "D", mime: "text/x-d", mode: "d", ext: ["d"]},
|
29 | 29 | {name: "Dart", mimes: ["application/dart", "text/x-dart"], mode: "dart", ext: ["dart"]},
|
30 | 30 | {name: "diff", mime: "text/x-diff", mode: "diff", ext: ["diff", "patch"]},
|
31 | 31 | {name: "Django", mime: "text/x-django", mode: "django"},
|
32 |
| - {name: "Dockerfile", mime: "text/x-dockerfile", mode: "dockerfile"}, |
| 32 | + {name: "Dockerfile", mime: "text/x-dockerfile", mode: "dockerfile", file: /^Dockerfile$/}, |
33 | 33 | {name: "DTD", mime: "application/xml-dtd", mode: "dtd", ext: ["dtd"]},
|
34 | 34 | {name: "Dylan", mime: "text/x-dylan", mode: "dylan", ext: ["dylan", "dyl", "intr"]},
|
35 | 35 | {name: "EBNF", mime: "text/x-ebnf", mode: "ebnf"},
|
|
42 | 42 | {name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"], alias: ["fsharp"]},
|
43 | 43 | {name: "Gas", mime: "text/x-gas", mode: "gas", ext: ["s"]},
|
44 | 44 | {name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]},
|
45 |
| - {name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm"}, |
| 45 | + {name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm", file: /^(readme|contributing|history).md$/i}, |
46 | 46 | {name: "Go", mime: "text/x-go", mode: "go", ext: ["go"]},
|
47 | 47 | {name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy"]},
|
48 | 48 | {name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"]},
|
|
59 | 59 | {name: "JavaScript", mimes: ["text/javascript", "text/ecmascript", "application/javascript", "application/x-javascript", "application/ecmascript"],
|
60 | 60 | mode: "javascript", ext: ["js"], alias: ["ecmascript", "js", "node"]},
|
61 | 61 | {name: "JSON", mimes: ["application/json", "application/x-json"], mode: "javascript", ext: ["json", "map"], alias: ["json5"]},
|
62 |
| - {name: "JSON-LD", mime: "application/ld+json", mode: "javascript", alias: ["jsonld"]}, |
| 62 | + {name: "JSON-LD", mime: "application/ld+json", mode: "javascript", ext: ["jsonld"], alias: ["jsonld"]}, |
63 | 63 | {name: "Jinja2", mime: "null", mode: "jinja2"},
|
64 | 64 | {name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"]},
|
65 | 65 | {name: "Kotlin", mime: "text/x-kotlin", mode: "kotlin", ext: ["kt"]},
|
|
72 | 72 | {name: "Modelica", mime: "text/x-modelica", mode: "modelica", ext: ["mo"]},
|
73 | 73 | {name: "MS SQL", mime: "text/x-mssql", mode: "sql"},
|
74 | 74 | {name: "MySQL", mime: "text/x-mysql", mode: "sql"},
|
75 |
| - {name: "Nginx", mime: "text/x-nginx-conf", mode: "nginx"}, |
| 75 | + {name: "Nginx", mime: "text/x-nginx-conf", mode: "nginx", file: /nginx.*\.conf$/i}, |
76 | 76 | {name: "NTriples", mime: "text/n-triples", mode: "ntriples", ext: ["nt"]},
|
77 | 77 | {name: "Objective C", mime: "text/x-objectivec", mode: "clike", ext: ["m", "mm"]},
|
78 | 78 | {name: "OCaml", mime: "text/x-ocaml", mode: "mllike", ext: ["ml", "mli", "mll", "mly"]},
|
79 | 79 | {name: "Octave", mime: "text/x-octave", mode: "octave", ext: ["m"]},
|
80 | 80 | {name: "Pascal", mime: "text/x-pascal", mode: "pascal", ext: ["p", "pas"]},
|
81 |
| - {name: "PEG.js", mime: "null", mode: "pegjs"}, |
| 81 | + {name: "PEG.js", mime: "null", mode: "pegjs", ext: ["jsonld"]}, |
82 | 82 | {name: "Perl", mime: "text/x-perl", mode: "perl", ext: ["pl", "pm"]},
|
83 | 83 | {name: "PHP", mime: "application/x-httpd-php", mode: "php", ext: ["php", "php3", "php4", "php5", "phtml"]},
|
84 |
| - {name: "Pig", mime: "text/x-pig", mode: "pig"}, |
| 84 | + {name: "Pig", mime: "text/x-pig", mode: "pig", ext: ["pig"]}, |
85 | 85 | {name: "Plain Text", mime: "text/plain", mode: "null", ext: ["txt", "text", "conf", "def", "list", "log"]},
|
86 |
| - {name: "PLSQL", mime: "text/x-plsql", mode: "sql"}, |
| 86 | + {name: "PLSQL", mime: "text/x-plsql", mode: "sql", ext: ["pls"]}, |
87 | 87 | {name: "Properties files", mime: "text/x-properties", mode: "properties", ext: ["properties", "ini", "in"], alias: ["ini", "properties"]},
|
88 | 88 | {name: "Python", mime: "text/x-python", mode: "python", ext: ["py", "pyw"]},
|
89 | 89 | {name: "Puppet", mime: "text/x-puppet", mode: "puppet", ext: ["pp"]},
|
|
99 | 99 | {name: "Scheme", mime: "text/x-scheme", mode: "scheme", ext: ["scm", "ss"]},
|
100 | 100 | {name: "SCSS", mime: "text/x-scss", mode: "css", ext: ["scss"]},
|
101 | 101 | {name: "Shell", mime: "text/x-sh", mode: "shell", ext: ["sh", "ksh", "bash"], alias: ["bash", "sh", "zsh"]},
|
102 |
| - {name: "Sieve", mime: "application/sieve", mode: "sieve"}, |
103 |
| - {name: "Slim", mimes: ["text/x-slim", "application/x-slim"], mode: "slim"}, |
| 102 | + {name: "Sieve", mime: "application/sieve", mode: "sieve", ext: ["siv", "sieve"]}, |
| 103 | + {name: "Slim", mimes: ["text/x-slim", "application/x-slim"], mode: "slim", ext: ["slim"]}, |
104 | 104 | {name: "Smalltalk", mime: "text/x-stsrc", mode: "smalltalk", ext: ["st"]},
|
105 | 105 | {name: "Smarty", mime: "text/x-smarty", mode: "smarty", ext: ["tpl"]},
|
106 | 106 | {name: "SmartyMixed", mime: "text/x-smarty", mode: "smartymixed"},
|
|
114 | 114 | {name: "LaTeX", mime: "text/x-latex", mode: "stex", ext: ["text", "ltx"], alias: ["tex"]},
|
115 | 115 | {name: "SystemVerilog", mime: "text/x-systemverilog", mode: "verilog", ext: ["v"]},
|
116 | 116 | {name: "Tcl", mime: "text/x-tcl", mode: "tcl", ext: ["tcl"]},
|
117 |
| - {name: "Textile", mime: "text/x-textile", mode: "textile"}, |
| 117 | + {name: "Textile", mime: "text/x-textile", mode: "textile", ext: ["textile"]}, |
118 | 118 | {name: "TiddlyWiki ", mime: "text/x-tiddlywiki", mode: "tiddlywiki"},
|
119 | 119 | {name: "Tiki wiki", mime: "text/tiki", mode: "tiki"},
|
120 |
| - {name: "TOML", mime: "text/x-toml", mode: "toml"}, |
| 120 | + {name: "TOML", mime: "text/x-toml", mode: "toml", ext: ["toml"]}, |
121 | 121 | {name: "Tornado", mime: "text/x-tornado", mode: "tornado"},
|
122 | 122 | {name: "Turtle", mime: "text/turtle", mode: "turtle", ext: ["ttl"]},
|
123 | 123 | {name: "TypeScript", mime: "application/typescript", mode: "javascript", ext: ["ts"], alias: ["ts"]},
|
124 | 124 | {name: "VB.NET", mime: "text/x-vb", mode: "vb", ext: ["vb"]},
|
125 |
| - {name: "VBScript", mime: "text/vbscript", mode: "vbscript"}, |
| 125 | + {name: "VBScript", mime: "text/vbscript", mode: "vbscript", ext: ["vbs"]}, |
126 | 126 | {name: "Velocity", mime: "text/velocity", mode: "velocity", ext: ["vtl"]},
|
127 | 127 | {name: "Verilog", mime: "text/x-verilog", mode: "verilog", ext: ["v"]},
|
128 | 128 | {name: "XML", mimes: ["application/xml", "text/xml"], mode: "xml", ext: ["xml", "xsl", "xsd"], alias: ["rss", "wsdl", "xsd"]},
|
|
137 | 137 | }
|
138 | 138 |
|
139 | 139 | CodeMirror.findModeByMIME = function(mime) {
|
| 140 | + mime = mime.toLowerCase(); |
140 | 141 | for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
|
141 | 142 | var info = CodeMirror.modeInfo[i];
|
142 | 143 | if (info.mime == mime) return info;
|
|
153 | 154 | }
|
154 | 155 | };
|
155 | 156 |
|
| 157 | + CodeMirror.findModeByFileName = function(filename) { |
| 158 | + for (var i = 0; i < CodeMirror.modeInfo.length; i++) { |
| 159 | + var info = CodeMirror.modeInfo[i]; |
| 160 | + if (info.file && info.file.test(filename)) return info; |
| 161 | + } |
| 162 | + var dot = filename.lastIndexOf("."); |
| 163 | + var ext = dot > -1 && filename.substring(dot + 1, filename.length); |
| 164 | + if (ext) return CodeMirror.findModeByExtension(ext); |
| 165 | + }; |
| 166 | + |
156 | 167 | CodeMirror.findModeByName = function(name) {
|
157 | 168 | name = name.toLowerCase();
|
158 | 169 | for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
|
|
0 commit comments