30 private readonly array $textModelsToParse;
47 return JavaScriptContent::class;
69 $redirectContent =
'/* #REDIRECT */mw.loader.load('
70 . json_encode(
$url, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE )
72 return new $class( $redirectContent );
79 '@phan-var JavascriptContent $content';
83 if ( !$this->userOptionsLookup->getBoolOption( $pstParams->
getUser(),
'pst-cssjs' ) ) {
85 $parserOptions = clone $parserOptions;
86 $parserOptions->setPreSaveTransform(
false );
89 $text = $content->getText();
90 $pst = $this->parserFactory->getInstance()->preSaveTransform(
98 return new $contentClass( $pst );
122 '@phan-var JavaScriptContent $content';
123 if ( in_array( $content->
getModel(), $this->textModelsToParse ) ) {
125 $output = $this->parserFactory->getInstance()
129 WikiPage::makeParserOptionsFromTitleAndModel(
142 language:
'javascript',
143 classes: [
'mw-js' ],
144 includeLineNumbers:
true,
145 includeLineLinks:
true,
147 $html = $highlightOutput->getHtml();
148 $highlightOutput->getMetadata()->addToParserOutput( $output );
161class_alias( JavaScriptContentHandler::class,
'JavaScriptContentHandler' );
const CONTENT_FORMAT_JAVASCRIPT
For JS pages.
Content handler for pages with source code as content (e.g.
Service for syntax highlighting.
Content handler for JavaScript pages.
makeRedirectContent(Title $destination, $text='')
Create a redirect that is also valid JavaScript.
supportsRedirects()
Returns true if this content model supports redirects.This default implementation returns false....
preSaveTransform(Content $content, PreSaveTransformParams $pstParams)
Returns a $content object with pre-save transformations applied (or the same object if no transformat...
__construct(string $modelId, Config $config, private readonly ParserFactory $parserFactory, private readonly UserOptionsLookup $userOptionsLookup, private readonly CodeHighlighter $codeHighlighter,)
fillParserOutput(Content $content, ContentParseParams $cpoParams, ParserOutput &$output)
Fills the provided ParserOutput object with information derived from the content.
A class containing constants representing the names of configuration variables.
const TextModelsToParse
Name constant for the TextModelsToParse setting, for use with Config::get()
Base representation for an editable wiki page.
Content objects represent page content, e.g.
getModel()
Get the content model ID.