]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - extensions/SyntaxHighlight_GeSHi/SyntaxHighlight.ace.php
MediaWiki 1.30.2-scripts
[autoinstalls/mediawiki.git] / extensions / SyntaxHighlight_GeSHi / SyntaxHighlight.ace.php
1 <?php
2 /**
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16  * http://www.gnu.org/copyleft/gpl.html
17  */
18
19 /**
20  * Class provides functionality to map Ace lexer definitions
21  */
22 class SyntaxHighlightAce {
23         /** @var array This map is inverted, because it is easier to maintain this way */
24         private static $aceLexers = [
25                 'ABAP'         => [ 'abap' ],
26                 'ABC'          => [],
27                 'ActionScript' => [ 'actionscript', 'actionscript3' ],
28                 'ADA'          => [ 'ada', 'ada2005', 'ada95' ],
29                 'Apache_Conf'  => [ 'apache', 'apacheconf', 'aconf' ],
30                 'AsciiDoc'     => [],
31                 'Assembly_x86' => [ 'nasm' ],
32                 'AutoHotKey'   => [ 'autohotkey', 'ah' ],
33                 'BatchFile'    => [ 'bat', 'batch', 'dosbatch', 'winbatch' ],
34                 'C_Cpp'        => [ 'cpp', 'c++' ],
35                 'C9Search'     => [],
36                 'Cirru'        => [ 'cirru' ],
37                 'Clojure'      => [ 'clojure', 'clj' ],
38                 'Cobol'        => [ 'cobol' ],
39                 'coffee'       => [ 'coffee', 'coffeescript', 'coffee-script' ],
40                 'ColdFusion'   => [ 'cfm' ],
41                 'CSharp'       => [ 'csharp', '#' ],
42                 'CSS'          => [ 'css' ],
43                 'Curly'        => [],
44                 'D'            => [ 'd' ],
45                 'Dart'         => [ 'dart' ],
46                 'Diff'         => [ 'diff', 'udiff' ],
47                 'Django'       => [ 'django', 'html+django', 'html+jinja', 'htmldjango' ],
48                 'Dockerfile'   => [ 'Dockerfile', 'docker' ],
49                 'Dot'          => [],
50                 'Dummy'        => [],
51                 'DummySyntax'  => [],
52                 'Eiffel'       => [ 'eiffel' ],
53                 'EJS'          => [],
54                 'Elixir'       => [ 'elixer', 'ex', 'exs' ],
55                 'Elm'          => [ 'elm' ],
56                 'Erlang'       => [ 'erlang' ],
57                 'Forth'        => [],
58                 'Fortran'      => [ 'fortran' ],
59                 'FTL'          => [],
60                 'Gcode'        => [],
61                 'Gherkin'      => [ 'cucumber', 'gherkin' ],
62                 'Gitignore'    => [],
63                 'Glsl'         => [ 'glsl' ],
64                 'Gobstones'    => [],
65                 'golang'       => [ 'go' ],
66                 'Groovy'       => [ 'groovy' ],
67                 'HAML'         => [ 'haml' ],
68                 'Handlebars'   => [ 'html+handlebars' ],
69                 'Haskell'      => [ 'haskell', 'hs' ],
70                 'haXe'         => [ 'hx', 'haxe', 'hxsl' ],
71                 'HTML'         => [ 'html' ],
72                 'HTML_Elixir'  => [],
73                 'HTML_Ruby'    => [ 'rhtml', 'html+erb', 'html+ruby' ],
74                 'INI'          => [ 'ini', 'cfg', 'dosini' ],
75                 'Io'           => [ 'io' ],
76                 'Jack'         => [ '' ],
77                 'Jade'         => [ 'jade' ],
78                 'Java'         => [ 'java' ],
79                 'JavaScript'   => [ 'Javascript', 'js' ],
80                 'JSON'         => [ 'json' ],
81                 'JSONiq'       => [],
82                 'JSP'          => [ 'jsp' ],
83                 'JSX'          => [],
84                 'Julia'        => [ 'julia', 'jl' ],
85                 'LaTeX'        => [ 'latex' ],
86                 'Lean'         => [ 'lean' ],
87                 'LESS'         => [ 'less' ],
88                 'Liquid'       => [ 'liquid' ],
89                 'Lisp'         => [ 'lisp', 'common-lisp', 'cl' ],
90                 'LiveScript'   => [ 'Livescript', 'live-script' ],
91                 'LogiQL'       => [],
92                 'LSL'          => [ 'lsl' ],
93                 'Lua'          => [ 'lua' ],
94                 'LuaPage'      => [],
95                 'Lucene'       => [],
96                 'Makefile'     => [ 'make', 'makefile', 'mf', 'bsdmake' ],
97                 'Markdown'     => [],
98                 'Mask'         => [ 'mask' ],
99                 'MATLAB'       => [ 'matlab' ],
100                 'Maze'         => [],
101                 'MEL'          => [],
102                 'MUSHCode'     => [],
103                 'MySQL'        => [ 'mysql' ],
104                 'Nix'          => [ 'nix', 'nixos' ],
105                 'NSIS'         => [ 'nsis', 'nsi', 'nsh' ],
106                 'ObjectiveC'   => [ 'objectivec', 'objective-c', 'obj-c', 'objc',
107                         'objective-c++', 'objectivec++', 'obj-c++', 'objc++' ],
108                 'OCaml'        => [ 'ocaml' ],
109                 'Pascal'       => [ 'pascal', 'delphi', 'pas', 'objectpascal' ],
110                 'Perl'         => [ 'perl', 'pl', 'perl6', 'pl6' ],
111                 'pgSQL'        => [ 'postgresql', 'postgres' ],
112                 'PHP'          => [ 'php', 'php3', 'php4', 'php5', 'html+php' ],
113                 'Powershell'   => [ 'powershell', 'posh', 'ps1', 'psm1' ],
114                 'Praat'        => [ 'praat' ],
115                 'Prolog'       => [ 'prolog' ],
116                 'Properties'   => [ 'properties', 'jproperties' ],
117                 'Protobuf'     => [ 'protobuf', 'proto' ],
118                 'Python'       => [ 'python', 'py', 'sage', 'pyton3', 'py3' ],
119                 'R'            => [],
120                 'Razor'        => [],
121                 'RDoc'         => [],
122                 'RHTML'        => [], // HTML with Rcode, not ruby
123                 'RST'          => [ 'rst', 'rest', 'restructuredtext' ],
124                 'Ruby'         => [ 'ruby', 'rb', 'duby' ],
125                 'Rust'         => [ 'rust' ],
126                 'SASS'         => [ 'sass' ],
127                 'SCAD'         => [],
128                 'Scala'        => [ 'scala' ],
129                 'Scheme'       => [ 'scheme', 'scm' ],
130                 'SCSS'         => [ 'scss' ],
131                 'SH'           => [ 'sh', 'bash', 'ksh', 'shell' ],
132                 'SJS'          => [],
133                 'Smarty'       => [ 'smarty', 'html+smarty' ],
134                 'snippets'     => [],
135                 'Soy_Template' => [],
136                 'Space'        => [],
137                 'SQL'          => [ 'sql' ],
138                 'SQLServer'    => [],
139                 'Stylus'       => [],
140                 'SVG'          => [],
141                 'Swift'        => [ 'swift' ],
142                 'Tcl'          => [ 'tcl' ],
143                 'Tex'          => [ 'tex' ],
144                 'Text'         => [ 'text' ],
145                 'Textile'      => [],
146                 'Toml'         => [],
147                 'Twig'         => [ 'html+twig', 'twig' ],
148                 'Typescript'   => [ 'typescript', 'ts' ],
149                 'Vala'         => [ 'vala', 'vapi' ],
150                 'VBScript'     => [],
151                 'Velocity'     => [ 'velocity', 'html+velocity' ],
152                 'Verilog'      => [ 'verilog', 'v', 'systemverilog', 'sv' ],
153                 'VHDL'         => [ 'vhdl' ],
154                 'Wollok'       => [],
155                 'XML'          => [ 'xml' ],
156                 'XQuery'       => [ 'xquery', 'xqy', 'xq', 'xql', 'xqm' ],
157                 'YAML'         => [ 'yaml' ],
158         ];
159
160         public static function getPygmentsToAceMap() {
161                 $result = [];
162                 foreach ( self::$aceLexers as $aceName => $pygmentsLexers ) {
163                         foreach ( $pygmentsLexers as $lexer ) {
164                                 if ( strcasecmp( $lexer, $aceName ) === 0 ) {
165                                         continue;
166                                 }
167                                 if ( !array_key_exists( $lexer, $result ) ) {
168                                         $result[ $lexer ] = $aceName;
169                                 }
170                         }
171                 }
172                 return $result;
173         }
174 }