overleaf/services/web/public/js/ace/ext-modelist.js

192 lines
5.5 KiB
JavaScript
Raw Normal View History

2014-07-16 06:07:18 -04:00
ace.define("ace/ext/modelist",["require","exports","module"], function(require, exports, module) {
2014-02-12 05:23:40 -05:00
"use strict";
var modes = [];
function getModeForPath(path) {
var mode = modesByName.text;
var fileName = path.split(/[\/\\]/).pop();
for (var i = 0; i < modes.length; i++) {
if (modes[i].supportsFile(fileName)) {
mode = modes[i];
break;
}
}
return mode;
}
var Mode = function(name, caption, extensions) {
this.name = name;
this.caption = caption;
this.mode = "ace/mode/" + name;
this.extensions = extensions;
if (/\^/.test(extensions)) {
var re = extensions.replace(/\|(\^)?/g, function(a, b){
return "$|" + (b ? "^" : "^.*\\.");
}) + "$";
} else {
var re = "^.*\\.(" + extensions + ")$";
}
this.extRe = new RegExp(re, "gi");
};
Mode.prototype.supportsFile = function(filename) {
return filename.match(this.extRe);
};
var supportedModes = {
ABAP: ["abap"],
ABC: ["abc"],
2014-02-12 05:23:40 -05:00
ActionScript:["as"],
ADA: ["ada|adb"],
Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"],
AsciiDoc: ["asciidoc|adoc"],
2014-02-12 05:23:40 -05:00
Assembly_x86:["asm"],
AutoHotKey: ["ahk"],
BatchFile: ["bat|cmd"],
C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp"],
C9Search: ["c9search_results"],
2014-07-09 12:59:04 -04:00
Cirru: ["cirru|cr"],
Clojure: ["clj|cljs"],
2014-02-12 05:23:40 -05:00
Cobol: ["CBL|COB"],
coffee: ["coffee|cf|cson|^Cakefile"],
ColdFusion: ["cfm"],
CSharp: ["cs"],
CSS: ["css"],
Curly: ["curly"],
D: ["d|di"],
Dart: ["dart"],
Diff: ["diff|patch"],
2014-07-09 12:59:04 -04:00
Dockerfile: ["^Dockerfile"],
2014-02-12 05:23:40 -05:00
Dot: ["dot"],
2015-02-12 05:36:57 -05:00
Dummy: ["dummy"],
DummySyntax: ["dummy"],
Eiffel: ["e"],
2014-02-12 05:23:40 -05:00
EJS: ["ejs"],
2015-02-12 05:36:57 -05:00
Elixir: ["ex|exs"],
Elm: ["elm"],
Erlang: ["erl|hrl"],
2014-02-12 05:23:40 -05:00
Forth: ["frt|fs|ldr"],
FTL: ["ftl"],
2015-02-12 05:36:57 -05:00
Gcode: ["gcode"],
2014-07-09 12:59:04 -04:00
Gherkin: ["feature"],
Gitignore: ["^.gitignore"],
2014-02-12 05:23:40 -05:00
Glsl: ["glsl|frag|vert"],
golang: ["go"],
Groovy: ["groovy"],
HAML: ["haml"],
Handlebars: ["hbs|handlebars|tpl|mustache"],
Haskell: ["hs"],
haXe: ["hx"],
HTML: ["html|htm|xhtml"],
HTML_Ruby: ["erb|rhtml|html.erb"],
INI: ["ini|conf|cfg|prefs"],
2015-02-12 05:36:57 -05:00
Io: ["io"],
2014-02-12 05:23:40 -05:00
Jack: ["jack"],
Jade: ["jade"],
Java: ["java"],
JavaScript: ["js|jsm"],
JSON: ["json"],
JSONiq: ["jq"],
JSP: ["jsp"],
JSX: ["jsx"],
Julia: ["jl"],
LaTeX: ["tex|latex|ltx|bib"],
Lean: ["lean|hlean"],
2014-02-12 05:23:40 -05:00
LESS: ["less"],
Liquid: ["liquid"],
Lisp: ["lisp"],
LiveScript: ["ls"],
LogiQL: ["logic|lql"],
LSL: ["lsl"],
Lua: ["lua"],
LuaPage: ["lp"],
Lucene: ["lucene"],
Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],
Markdown: ["md|markdown"],
2015-02-12 05:36:57 -05:00
Mask: ["mask"],
MATLAB: ["matlab"],
Maze: ["mz"],
2014-07-09 12:59:04 -04:00
MEL: ["mel"],
2014-02-12 05:23:40 -05:00
MUSHCode: ["mc|mush"],
2015-02-12 05:36:57 -05:00
MySQL: ["mysql"],
2014-02-12 05:23:40 -05:00
Nix: ["nix"],
ObjectiveC: ["m|mm"],
OCaml: ["ml|mli"],
Pascal: ["pas|p"],
Perl: ["pl|pm"],
pgSQL: ["pgsql"],
PHP: ["php|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp"],
2014-02-12 05:23:40 -05:00
Powershell: ["ps1"],
2015-02-12 05:36:57 -05:00
Praat: ["praat|praatscript|psc|proc"],
2014-02-12 05:23:40 -05:00
Prolog: ["plg|prolog"],
Properties: ["properties"],
Protobuf: ["proto"],
Python: ["py"],
R: ["r"],
RDoc: ["Rd"],
RHTML: ["Rhtml"],
Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"],
Rust: ["rs"],
SASS: ["sass"],
SCAD: ["scad"],
Scala: ["scala"],
Scheme: ["scm|rkt"],
SCSS: ["scss"],
SH: ["sh|bash|^.bashrc"],
SJS: ["sjs"],
2015-02-12 05:36:57 -05:00
Smarty: ["smarty|tpl"],
2014-02-12 05:23:40 -05:00
snippets: ["snippets"],
Soy_Template:["soy"],
2015-02-12 05:36:57 -05:00
Space: ["space"],
2014-02-12 05:23:40 -05:00
SQL: ["sql"],
SQLServer: ["sqlserver"],
2014-02-12 05:23:40 -05:00
Stylus: ["styl|stylus"],
SVG: ["svg"],
Tcl: ["tcl"],
Tex: ["tex"],
Text: ["txt"],
Textile: ["textile"],
Toml: ["toml"],
Twig: ["twig"],
Typescript: ["ts|typescript|str"],
2014-07-09 12:59:04 -04:00
Vala: ["vala"],
2015-02-12 05:36:57 -05:00
VBScript: ["vbs|vb"],
2014-02-12 05:23:40 -05:00
Velocity: ["vm"],
Verilog: ["v|vh|sv|svh"],
2015-02-12 05:36:57 -05:00
VHDL: ["vhd|vhdl"],
XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"],
2014-02-12 05:23:40 -05:00
XQuery: ["xq"],
YAML: ["yaml|yml"],
Django: ["html"]
2014-02-12 05:23:40 -05:00
};
var nameOverrides = {
ObjectiveC: "Objective-C",
CSharp: "C#",
golang: "Go",
2015-02-12 05:36:57 -05:00
C_Cpp: "C and C++",
2014-02-12 05:23:40 -05:00
coffee: "CoffeeScript",
HTML_Ruby: "HTML (Ruby)",
FTL: "FreeMarker"
};
var modesByName = {};
for (var name in supportedModes) {
var data = supportedModes[name];
var displayName = (nameOverrides[name] || name).replace(/_/g, " ");
var filename = name.toLowerCase();
var mode = new Mode(filename, displayName, data[0]);
modesByName[filename] = mode;
modes.push(mode);
}
module.exports = {
getModeForPath: getModeForPath,
modes: modes,
modesByName: modesByName
};
});
2014-07-09 12:59:04 -04:00
(function() {
2014-07-16 06:07:18 -04:00
ace.require(["ace/ext/modelist"], function() {});
2014-07-09 12:59:04 -04:00
})();