mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/SyntaxHighlight_GeSHi
synced 2024-11-23 22:13:40 +00:00
Move default CSS/JS model mapping out of extension.json
These are for MediaWiki core models, so it seems reasonable to specify them in the PHP source. Change-Id: Iab6f9969d2bf72122b2661e139aa21a3475a92a8
This commit is contained in:
parent
adb912bb3a
commit
9bdf728fc1
|
@ -102,10 +102,7 @@
|
|||
},
|
||||
"attributes": {
|
||||
"SyntaxHighlight": {
|
||||
"Models": {
|
||||
"css": "css",
|
||||
"javascript": "javascript"
|
||||
}
|
||||
"Models": {}
|
||||
},
|
||||
"VisualEditor": {
|
||||
"PluginModules": [
|
||||
|
|
|
@ -517,9 +517,14 @@ class SyntaxHighlight {
|
|||
return true;
|
||||
}
|
||||
|
||||
// Determine the language
|
||||
// Determine the SyntaxHighlight language from the page's
|
||||
// content model. Extensions can extend the default CSS/JS
|
||||
// mapping by setting the SyntaxHighlightModels attribute.
|
||||
$extension = ExtensionRegistry::getInstance();
|
||||
$models = $extension->getAttribute( 'SyntaxHighlightModels' );
|
||||
$models = $extension->getAttribute( 'SyntaxHighlightModels' ) + [
|
||||
CONTENT_MODEL_CSS => 'css',
|
||||
CONTENT_MODEL_JAVASCRIPT => 'javascript',
|
||||
];
|
||||
$model = $content->getModel();
|
||||
if ( !isset( $models[$model] ) ) {
|
||||
// We don't care about this model, carry on.
|
||||
|
@ -527,7 +532,7 @@ class SyntaxHighlight {
|
|||
}
|
||||
$lexer = $models[$model];
|
||||
|
||||
// Hope that $wgSyntaxHighlightModels does not contain silly types.
|
||||
// Hope that the "SyntaxHighlightModels" attribute does not contain silly types.
|
||||
$text = ContentHandler::getContentText( $content );
|
||||
if ( !$text ) {
|
||||
// Oops! Non-text content? Let MediaWiki handle this.
|
||||
|
|
Loading…
Reference in a new issue