Debian Codegraph @

extensions/SyntaxHighlight_GeSHi/includes/SyntaxHighlightAce.php

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