mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/SyntaxHighlight_GeSHi
synced 2024-11-15 02:24:07 +00:00
Avoid file glob in SyntaxHighlight_GeSHi::getSupportedLanguages()
Store the list of supported languages in SyntaxHighlight_GeSHi.langs.php, which is auto-generated via a maintenance script, updateLanguageList.php. Change-Id: Ie0be7c42fa6716555c3e03e3f28734d7e0302664
This commit is contained in:
parent
97a9c6e6d7
commit
168e1296db
6
README
6
README
|
@ -50,3 +50,9 @@ GeSHi is generous about creating HTML elements: highlighting large blocks of
|
|||
code can easily generate enough of them to crash a browser. As a guard, symbol
|
||||
highlighting is turned off for code fragments larger than 100 kB. For fragments
|
||||
larger than 200 kB, string highlighting is turned off as well.
|
||||
|
||||
== Note to maintainers ==
|
||||
|
||||
Whenever updating the version of GeSHi embedded in the extension, run
|
||||
maintenance/updateLanguageList.php to re-generate the list of supported
|
||||
languages.
|
||||
|
|
|
@ -482,15 +482,8 @@ class SyntaxHighlight_GeSHi {
|
|||
* @return array
|
||||
*/
|
||||
private static function getSupportedLanguages() {
|
||||
if( !is_array( self::$languages ) ) {
|
||||
self::initialise();
|
||||
self::$languages = array();
|
||||
foreach( glob( GESHI_LANG_ROOT . "/*.php" ) as $file ) {
|
||||
self::$languages[] = basename( $file, '.php' );
|
||||
}
|
||||
sort( self::$languages );
|
||||
}
|
||||
return self::$languages;
|
||||
global $wgGeSHiSupportedLanguages;
|
||||
return $wgGeSHiSupportedLanguages;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
219
SyntaxHighlight_GeSHi.langs.php
Normal file
219
SyntaxHighlight_GeSHi.langs.php
Normal file
|
@ -0,0 +1,219 @@
|
|||
<?php
|
||||
// Generated by updateLanguageList.php on Wed, 19 Nov 2014 00:27:50 +0000
|
||||
$wgGeSHiSupportedLanguages = array(
|
||||
"4cs",
|
||||
"6502acme",
|
||||
"6502kickass",
|
||||
"6502tasm",
|
||||
"68000devpac",
|
||||
"abap",
|
||||
"actionscript",
|
||||
"actionscript3",
|
||||
"ada",
|
||||
"algol68",
|
||||
"apache",
|
||||
"applescript",
|
||||
"arm",
|
||||
"asm",
|
||||
"asp",
|
||||
"asymptote",
|
||||
"autoconf",
|
||||
"autohotkey",
|
||||
"autoit",
|
||||
"avisynth",
|
||||
"awk",
|
||||
"bascomavr",
|
||||
"bash",
|
||||
"basic4gl",
|
||||
"bf",
|
||||
"bibtex",
|
||||
"blitzbasic",
|
||||
"bnf",
|
||||
"boo",
|
||||
"c",
|
||||
"caddcl",
|
||||
"cadlisp",
|
||||
"cfdg",
|
||||
"cfm",
|
||||
"chaiscript",
|
||||
"cil",
|
||||
"clojure",
|
||||
"cmake",
|
||||
"cobol",
|
||||
"coffeescript",
|
||||
"cpp",
|
||||
"csharp",
|
||||
"css",
|
||||
"cuesheet",
|
||||
"d",
|
||||
"dcl",
|
||||
"dcpu16",
|
||||
"dcs",
|
||||
"delphi",
|
||||
"diff",
|
||||
"div",
|
||||
"dos",
|
||||
"dot",
|
||||
"e",
|
||||
"ecmascript",
|
||||
"eiffel",
|
||||
"email",
|
||||
"epc",
|
||||
"erlang",
|
||||
"euphoria",
|
||||
"f1",
|
||||
"falcon",
|
||||
"fo",
|
||||
"fortran",
|
||||
"freebasic",
|
||||
"freeswitch",
|
||||
"fsharp",
|
||||
"gambas",
|
||||
"gdb",
|
||||
"genero",
|
||||
"genie",
|
||||
"gettext",
|
||||
"glsl",
|
||||
"gml",
|
||||
"gnuplot",
|
||||
"go",
|
||||
"groovy",
|
||||
"gwbasic",
|
||||
"haskell",
|
||||
"haxe",
|
||||
"hicest",
|
||||
"hq9plus",
|
||||
"html4strict",
|
||||
"html5",
|
||||
"icon",
|
||||
"idl",
|
||||
"ini",
|
||||
"inno",
|
||||
"intercal",
|
||||
"io",
|
||||
"j",
|
||||
"java",
|
||||
"java5",
|
||||
"javascript",
|
||||
"jquery",
|
||||
"kixtart",
|
||||
"klonec",
|
||||
"klonecpp",
|
||||
"latex",
|
||||
"lb",
|
||||
"ldif",
|
||||
"lisp",
|
||||
"llvm",
|
||||
"locobasic",
|
||||
"logtalk",
|
||||
"lolcode",
|
||||
"lotusformulas",
|
||||
"lotusscript",
|
||||
"lscript",
|
||||
"lsl2",
|
||||
"lua",
|
||||
"m68k",
|
||||
"magiksf",
|
||||
"make",
|
||||
"mapbasic",
|
||||
"matlab",
|
||||
"mirc",
|
||||
"mmix",
|
||||
"modula2",
|
||||
"modula3",
|
||||
"mpasm",
|
||||
"mxml",
|
||||
"mysql",
|
||||
"nagios",
|
||||
"netrexx",
|
||||
"newlisp",
|
||||
"nsis",
|
||||
"oberon2",
|
||||
"objc",
|
||||
"objeck",
|
||||
"ocaml",
|
||||
"octave",
|
||||
"oobas",
|
||||
"oorexx",
|
||||
"oracle11",
|
||||
"oracle8",
|
||||
"oxygene",
|
||||
"oz",
|
||||
"parasail",
|
||||
"parigp",
|
||||
"pascal",
|
||||
"pcre",
|
||||
"per",
|
||||
"perl",
|
||||
"perl6",
|
||||
"pf",
|
||||
"php",
|
||||
"pic16",
|
||||
"pike",
|
||||
"pixelbender",
|
||||
"pli",
|
||||
"plsql",
|
||||
"postgresql",
|
||||
"povray",
|
||||
"powerbuilder",
|
||||
"powershell",
|
||||
"proftpd",
|
||||
"progress",
|
||||
"prolog",
|
||||
"properties",
|
||||
"providex",
|
||||
"purebasic",
|
||||
"pycon",
|
||||
"pys60",
|
||||
"python",
|
||||
"q",
|
||||
"qbasic",
|
||||
"rails",
|
||||
"rebol",
|
||||
"reg",
|
||||
"rexx",
|
||||
"robots",
|
||||
"rpmspec",
|
||||
"rsplus",
|
||||
"ruby",
|
||||
"sas",
|
||||
"scala",
|
||||
"scheme",
|
||||
"scilab",
|
||||
"sdlbasic",
|
||||
"smalltalk",
|
||||
"smarty",
|
||||
"spark",
|
||||
"sparql",
|
||||
"sql",
|
||||
"stonescript",
|
||||
"systemverilog",
|
||||
"tcl",
|
||||
"teraterm",
|
||||
"text",
|
||||
"thinbasic",
|
||||
"tsql",
|
||||
"typoscript",
|
||||
"unicon",
|
||||
"upc",
|
||||
"urbi",
|
||||
"uscript",
|
||||
"vala",
|
||||
"vb",
|
||||
"vbnet",
|
||||
"vedit",
|
||||
"verilog",
|
||||
"vhdl",
|
||||
"vim",
|
||||
"visualfoxpro",
|
||||
"visualprolog",
|
||||
"whitespace",
|
||||
"whois",
|
||||
"winbatch",
|
||||
"xbasic",
|
||||
"xml",
|
||||
"xpp",
|
||||
"yaml",
|
||||
"z80",
|
||||
"zxbasic"
|
||||
);
|
|
@ -42,6 +42,8 @@ if ( version_compare( $wgVersion, '1.24', '<' ) ) {
|
|||
|
||||
define('GESHI_VERSION', '1.0.8.12');
|
||||
|
||||
include_once __DIR__ . '/SyntaxHighlight_GeSHi.langs.php';
|
||||
|
||||
$wgExtensionCredits['parserhook'][] = array(
|
||||
'path' => __FILE__,
|
||||
'name' => 'SyntaxHighlight',
|
||||
|
|
51
maintenance/updateLanguageList.php
Normal file
51
maintenance/updateLanguageList.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
/**
|
||||
* Script to update list of supported languages.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
* http://www.gnu.org/copyleft/gpl.html
|
||||
*
|
||||
* @file
|
||||
* @author Ori Livneh <ori@wikimedia.org>
|
||||
* @ingroup Maintenance
|
||||
*/
|
||||
|
||||
$IP = getenv( 'MW_INSTALL_PATH' ) ?: __DIR__ . '/../../..';
|
||||
|
||||
require_once "$IP/maintenance/Maintenance.php";
|
||||
require_once __DIR__ . "/../geshi/geshi.php";
|
||||
|
||||
class UpdateLanguageList extends Maintenance {
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->addDescription( 'Update list of languages supported by SyntaxHighlight_GeSHi' );
|
||||
}
|
||||
|
||||
public function execute() {
|
||||
global $IP;
|
||||
|
||||
$geshi = new GeSHi;
|
||||
$header = '// Generated by ' . basename( __FILE__ ) . ' on ' . date( DATE_RFC2822 ) . "\n";
|
||||
$langs = array_values( array_filter( $geshi->get_supported_languages( false ), 'ctype_alnum' ) );
|
||||
sort( $langs );
|
||||
$replace = array( '[' => "array(\n\t", ']' => "\n);\n", '",' => "\",\n\t" );
|
||||
$code = "<?php\n" . $header . '$wgGeSHiSupportedLanguages = ' . strtr( json_encode( $langs ), $replace );
|
||||
file_put_contents( __DIR__ . '/../SyntaxHighlight_GeSHi.langs.php', $code );
|
||||
$this->output( "Updated language list written to SyntaxHighlight_GeSHi.langs.php\n" );
|
||||
}
|
||||
}
|
||||
|
||||
$maintClass = "UpdateLanguageList";
|
||||
require_once( RUN_MAINTENANCE_IF_MAIN );
|
Loading…
Reference in a new issue