PageRenderTime 42ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/files/ace/1.1.5/noconflict/ext-modelist.js

https://gitlab.com/Mirros/jsdelivr
JavaScript | 178 lines | 170 code | 8 blank | 0 comment | 6 complexity | 5c53a082dbdc3e0dc4d5ec472b022df8 MD5 | raw file
  1. ace.define("ace/ext/modelist",["require","exports","module"], function(require, exports, module) {
  2. "use strict";
  3. var modes = [];
  4. function getModeForPath(path) {
  5. var mode = modesByName.text;
  6. var fileName = path.split(/[\/\\]/).pop();
  7. for (var i = 0; i < modes.length; i++) {
  8. if (modes[i].supportsFile(fileName)) {
  9. mode = modes[i];
  10. break;
  11. }
  12. }
  13. return mode;
  14. }
  15. var Mode = function(name, caption, extensions) {
  16. this.name = name;
  17. this.caption = caption;
  18. this.mode = "ace/mode/" + name;
  19. this.extensions = extensions;
  20. if (/\^/.test(extensions)) {
  21. var re = extensions.replace(/\|(\^)?/g, function(a, b){
  22. return "$|" + (b ? "^" : "^.*\\.");
  23. }) + "$";
  24. } else {
  25. var re = "^.*\\.(" + extensions + ")$";
  26. }
  27. this.extRe = new RegExp(re, "gi");
  28. };
  29. Mode.prototype.supportsFile = function(filename) {
  30. return filename.match(this.extRe);
  31. };
  32. var supportedModes = {
  33. ABAP: ["abap"],
  34. ActionScript:["as"],
  35. ADA: ["ada|adb"],
  36. Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"],
  37. AsciiDoc: ["asciidoc"],
  38. Assembly_x86:["asm"],
  39. AutoHotKey: ["ahk"],
  40. BatchFile: ["bat|cmd"],
  41. C9Search: ["c9search_results"],
  42. C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp"],
  43. Cirru: ["cirru|cr"],
  44. Clojure: ["clj|cljs"],
  45. Cobol: ["CBL|COB"],
  46. coffee: ["coffee|cf|cson|^Cakefile"],
  47. ColdFusion: ["cfm"],
  48. CSharp: ["cs"],
  49. CSS: ["css"],
  50. Curly: ["curly"],
  51. D: ["d|di"],
  52. Dart: ["dart"],
  53. Diff: ["diff|patch"],
  54. Dockerfile: ["^Dockerfile"],
  55. Dot: ["dot"],
  56. Erlang: ["erl|hrl"],
  57. EJS: ["ejs"],
  58. Forth: ["frt|fs|ldr"],
  59. FTL: ["ftl"],
  60. Gherkin: ["feature"],
  61. Gitignore: ["^.gitignore"],
  62. Glsl: ["glsl|frag|vert"],
  63. golang: ["go"],
  64. Groovy: ["groovy"],
  65. HAML: ["haml"],
  66. Handlebars: ["hbs|handlebars|tpl|mustache"],
  67. Haskell: ["hs"],
  68. haXe: ["hx"],
  69. HTML: ["html|htm|xhtml"],
  70. HTML_Ruby: ["erb|rhtml|html.erb"],
  71. INI: ["ini|conf|cfg|prefs"],
  72. Jack: ["jack"],
  73. Jade: ["jade"],
  74. Java: ["java"],
  75. JavaScript: ["js|jsm"],
  76. JSON: ["json"],
  77. JSONiq: ["jq"],
  78. JSP: ["jsp"],
  79. JSX: ["jsx"],
  80. Julia: ["jl"],
  81. LaTeX: ["tex|latex|ltx|bib"],
  82. LESS: ["less"],
  83. Liquid: ["liquid"],
  84. Lisp: ["lisp"],
  85. LiveScript: ["ls"],
  86. LogiQL: ["logic|lql"],
  87. LSL: ["lsl"],
  88. Lua: ["lua"],
  89. LuaPage: ["lp"],
  90. Lucene: ["lucene"],
  91. Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],
  92. MATLAB: ["matlab"],
  93. Markdown: ["md|markdown"],
  94. MEL: ["mel"],
  95. MySQL: ["mysql"],
  96. MUSHCode: ["mc|mush"],
  97. Nix: ["nix"],
  98. ObjectiveC: ["m|mm"],
  99. OCaml: ["ml|mli"],
  100. Pascal: ["pas|p"],
  101. Perl: ["pl|pm"],
  102. pgSQL: ["pgsql"],
  103. PHP: ["php|phtml"],
  104. Powershell: ["ps1"],
  105. Prolog: ["plg|prolog"],
  106. Properties: ["properties"],
  107. Protobuf: ["proto"],
  108. Python: ["py"],
  109. R: ["r"],
  110. RDoc: ["Rd"],
  111. RHTML: ["Rhtml"],
  112. Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"],
  113. Rust: ["rs"],
  114. SASS: ["sass"],
  115. SCAD: ["scad"],
  116. Scala: ["scala"],
  117. Smarty: ["smarty|tpl"],
  118. Scheme: ["scm|rkt"],
  119. SCSS: ["scss"],
  120. SH: ["sh|bash|^.bashrc"],
  121. SJS: ["sjs"],
  122. Space: ["space"],
  123. snippets: ["snippets"],
  124. Soy_Template:["soy"],
  125. SQL: ["sql"],
  126. Stylus: ["styl|stylus"],
  127. SVG: ["svg"],
  128. Tcl: ["tcl"],
  129. Tex: ["tex"],
  130. Text: ["txt"],
  131. Textile: ["textile"],
  132. Toml: ["toml"],
  133. Twig: ["twig"],
  134. Typescript: ["ts|typescript|str"],
  135. Vala: ["vala"],
  136. VBScript: ["vbs"],
  137. Velocity: ["vm"],
  138. Verilog: ["v|vh|sv|svh"],
  139. XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl"],
  140. XQuery: ["xq"],
  141. YAML: ["yaml|yml"]
  142. };
  143. var nameOverrides = {
  144. ObjectiveC: "Objective-C",
  145. CSharp: "C#",
  146. golang: "Go",
  147. C_Cpp: "C/C++",
  148. coffee: "CoffeeScript",
  149. HTML_Ruby: "HTML (Ruby)",
  150. FTL: "FreeMarker"
  151. };
  152. var modesByName = {};
  153. for (var name in supportedModes) {
  154. var data = supportedModes[name];
  155. var displayName = (nameOverrides[name] || name).replace(/_/g, " ");
  156. var filename = name.toLowerCase();
  157. var mode = new Mode(filename, displayName, data[0]);
  158. modesByName[filename] = mode;
  159. modes.push(mode);
  160. }
  161. module.exports = {
  162. getModeForPath: getModeForPath,
  163. modes: modes,
  164. modesByName: modesByName
  165. };
  166. });
  167. ;
  168. (function() {
  169. ace.require(["ace/ext/modelist"], function() {});
  170. })();