2015-05-27 16:15:00 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2022-03-13 00:16:29 +00:00
|
|
|
namespace MediaWiki\SyntaxHighlight;
|
|
|
|
|
2022-05-20 02:11:31 +00:00
|
|
|
use MediaWiki\ResourceLoader as RL;
|
2022-03-13 00:16:29 +00:00
|
|
|
|
2023-05-08 07:15:48 +00:00
|
|
|
class VisualEditorConfig {
|
2015-05-27 16:15:00 +00:00
|
|
|
|
|
|
|
/**
|
2022-05-20 02:11:31 +00:00
|
|
|
* @param RL\Context $context
|
2015-05-27 16:15:00 +00:00
|
|
|
* @return string JavaScript code
|
|
|
|
*/
|
2023-05-08 07:15:48 +00:00
|
|
|
public static function makeScript( RL\Context $context ) {
|
|
|
|
return 've.dm.MWSyntaxHighlightNode.static.addPygmentsLanguages('
|
|
|
|
. $context->encodeJson( self::getPygmentsLanguages() )
|
2021-02-18 04:59:40 +00:00
|
|
|
. ');'
|
|
|
|
. 've.dm.MWSyntaxHighlightNode.static.addGeshiToPygmentsMap('
|
|
|
|
. $context->encodeJson( SyntaxHighlightGeSHiCompat::getGeSHiToPygmentsMap() )
|
|
|
|
. ');'
|
|
|
|
. 've.dm.MWSyntaxHighlightNode.static.addPygmentsToAceMap('
|
|
|
|
. $context->encodeJson( SyntaxHighlightAce::getPygmentsToAceMap() )
|
|
|
|
. ');';
|
2015-05-27 16:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-10-07 15:16:00 +00:00
|
|
|
* Get a full list of available languages
|
2024-01-22 08:39:30 +00:00
|
|
|
* @return string[]
|
2015-05-27 16:15:00 +00:00
|
|
|
*/
|
2024-01-22 08:39:30 +00:00
|
|
|
private static function getPygmentsLanguages(): array {
|
2018-07-29 04:29:30 +00:00
|
|
|
return array_keys( require __DIR__ . '/../SyntaxHighlight.lexers.php' );
|
2015-05-27 16:15:00 +00:00
|
|
|
}
|
|
|
|
}
|