Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
SyntaxHighlightAce | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
30 | |
0.00% |
0 / 1 |
getPygmentsToAceMap | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
30 |
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 | // HTML with Rcode, not ruby |
125 | 'RHTML' => [], |
126 | 'RST' => [ 'rst', 'rest', 'restructuredtext' ], |
127 | 'Ruby' => [ 'ruby', 'rb', 'duby' ], |
128 | 'Rust' => [ 'rust' ], |
129 | 'SASS' => [ 'sass' ], |
130 | 'SCAD' => [], |
131 | 'Scala' => [ 'scala' ], |
132 | 'Scheme' => [ 'scheme', 'scm' ], |
133 | 'SCSS' => [ 'scss' ], |
134 | 'SH' => [ 'sh', 'bash', 'ksh', 'shell' ], |
135 | 'SJS' => [], |
136 | 'Smarty' => [ 'smarty', 'html+smarty' ], |
137 | 'snippets' => [], |
138 | 'Soy_Template' => [], |
139 | 'Space' => [], |
140 | 'SQL' => [ 'sql' ], |
141 | 'SQLServer' => [], |
142 | 'Stylus' => [], |
143 | 'SVG' => [], |
144 | 'Swift' => [ 'swift' ], |
145 | 'Tcl' => [ 'tcl' ], |
146 | 'Tex' => [ 'tex' ], |
147 | 'Text' => [ 'text' ], |
148 | 'Textile' => [], |
149 | 'Toml' => [], |
150 | 'Twig' => [ 'html+twig', 'twig' ], |
151 | 'Typescript' => [ 'typescript', 'ts' ], |
152 | 'Vala' => [ 'vala', 'vapi' ], |
153 | 'VBScript' => [], |
154 | 'Velocity' => [ 'velocity', 'html+velocity' ], |
155 | 'Verilog' => [ 'verilog', 'v', 'systemverilog', 'sv' ], |
156 | 'VHDL' => [ 'vhdl' ], |
157 | 'Wollok' => [], |
158 | 'XML' => [ 'xml' ], |
159 | 'XQuery' => [ 'xquery', 'xqy', 'xq', 'xql', 'xqm' ], |
160 | 'YAML' => [ 'yaml' ], |
161 | ]; |
162 | |
163 | /** |
164 | * @return array<string,string> |
165 | */ |
166 | public static function getPygmentsToAceMap(): array { |
167 | $result = []; |
168 | foreach ( self::$aceLexers as $aceName => $pygmentsLexers ) { |
169 | foreach ( $pygmentsLexers as $lexer ) { |
170 | if ( strcasecmp( $lexer, $aceName ) === 0 ) { |
171 | continue; |
172 | } |
173 | if ( !array_key_exists( $lexer, $result ) ) { |
174 | $result[ $lexer ] = $aceName; |
175 | } |
176 | } |
177 | } |
178 | return $result; |
179 | } |
180 | } |