7namespace MediaWiki\Content;
9use MediaWiki\Config\Config;
10use MediaWiki\Content\Renderer\ContentParseParams;
11use MediaWiki\Content\Transform\PreSaveTransformParams;
12use MediaWiki\MainConfigNames;
13use MediaWiki\MediaWikiServices;
14use MediaWiki\Page\WikiPage;
15use MediaWiki\Parser\ParserFactory;
16use MediaWiki\Parser\ParserOutput;
17use MediaWiki\Parser\ParserOutputFlags;
18use MediaWiki\Title\Title;
19use MediaWiki\User\Options\UserOptionsLookup;
20use Wikimedia\Minify\CSSMin;
30 private readonly array $textModelsToParse;
47 return CssContent::class;
68 return new $class(
'/* #REDIRECT */@import ' . CSSMin::buildUrlValue(
$url ) .
';' );
75 '@phan-var CssContent $content';
78 if ( !$this->userOptionsLookup->getBoolOption( $pstParams->
getUser(),
'pst-cssjs' ) ) {
81 $popts->setPreSaveTransform(
false );
84 $text = $content->getText();
85 $pst = $this->parserFactory->getInstance()->preSaveTransform(
93 return new $class( $pst );
104 '@phan-var CssContent $content';
107 $parserOptions = WikiPage::makeParserOptionsFromTitleAndModel(
113 $content, $cpoParams, $output, $this->textModelsToParse, $this->parserFactory,
114 $parsoidParserFactory, $parserOptions
120 classes: [
'mw-css' ],
121 includeLineNumbers:
true,
122 includeLineLinks:
true,
124 $html = $highlightOutput->getHtml();
125 $highlightOutput->getMetadata()->addToParserOutput( $output );
138class_alias( CssContentHandler::class,
'CssContentHandler' );
const CONTENT_FORMAT_CSS
For CSS pages.
Content handler for pages with source code as content (e.g.
Service for syntax highlighting.
Content handler for CSS pages.
preSaveTransform(Content $content, PreSaveTransformParams $pstParams)
Returns a $content object with pre-save transformations applied (or the same object if no transformat...
supportsRedirects()
Returns true if this content model supports redirects.This default implementation returns false....
fillParserOutput(Content $content, ContentParseParams $cpoParams, ParserOutput &$output)
Fills the provided ParserOutput object with information derived from the content.Unless $generateHtml...
__construct(string $modelId, Config $config, private readonly ParserFactory $parserFactory, private readonly UserOptionsLookup $userOptionsLookup, private readonly CodeHighlighter $codeHighlighter,)
makeRedirectContent(Title $destination, $text='')
Create a redirect that is also valid CSS.
collectMetadata(TextContent $content, ContentParseParams $cpoParams, ParserOutput $output, array $textModelsToParse, ParserFactory $parserFactory, ParsoidParserFactory $parsoidParserFactory, ParserOptions $parserOptions)
const TextModelsToParse
Name constant for the TextModelsToParse setting, for use with Config\get().
Content objects represent page content, e.g.
getModel()
Get the content model ID.