MediaWiki:Common.css: различия между версиями
Перейти к навигации
Перейти к поиску
Admin (обсуждение | вклад) м (Защитил страницу MediaWiki:Common.css ([Редактирование=Разрешено только администраторам] (бессрочно) [Переименование=Разрешено только администраторам] (бессрочно))) |
Admin (обсуждение | вклад) Метка: отменено |
||
Строка 8: | Строка 8: | ||
display: block; font-weight: normal; font-size:85%; line-height: 1.6; | display: block; font-weight: normal; font-size:85%; line-height: 1.6; | ||
} | } | ||
use Wikimedia\CSS\Parser\Parser; | |||
use Wikimedia\CSS\Sanitizer\StylesheetSanitizer; | |||
/** Parse a stylesheet from a string **/ | |||
$parser = Parser::newFromString( $cssText ); | |||
$stylesheet = $parser->parseStylesheet(); | |||
/** Report any parser errors **/ | |||
foreach ( $parser->getParseErrors() as list( $code, $line, $pos ) ) { | |||
// $code is a string that should be suitable as a key for an i18n library. | |||
// See errors.md for details. | |||
$error = lookupI18nMessage( "css-parse-error-$code" ); | |||
echo "Parse error: $error at line $line character $pos\n"; | |||
} | |||
/** Apply sanitization to the stylesheet **/ | |||
// If you need to customize the defaults, copy the code of this method and | |||
// modify it. | |||
$sanitizer = StylesheetSanitizer::newDefault(); | |||
$newStylesheet = $sanitizer->sanitize( $stylesheet ); | |||
/** Report any sanitizer errors **/ | |||
foreach ( $sanitizer->getSanitizationErrors() as list( $code, $line, $pos ) ) { | |||
// $code is a string that should be suitable as a key for an i18n library. | |||
// See errors.md for details. | |||
$error = lookupI18nMessage( "css-sanitization-error-$code" ); | |||
echo "Sanitization error: $error at line $line character $pos\n"; | |||
} | |||
/** Convert the sanitized stylesheet back to text **/ | |||
$newText = (string)$newStylesheet; | |||
// Or if you'd rather have it minified too | |||
$minifiedText = Wikimedia\CSS\Util::stringify( $newStylesheet, [ 'minify' => true ] ); |
Версия 12:49, 25 января 2022
/* Размещённый здесь CSS будет применяться ко всем темам оформления */
body.page-Заглавная_страница.action-view h1.firstHeading, body.page-Заглавная_страница.action-submit h1.firstHeading { display: none; }
body.page-Заглавная_страница.action-view #siteSub,
body.page-Заглавная_страница.action-submit #siteSub {
display: none;
}
#siteSub {
display: block; font-weight: normal; font-size:85%; line-height: 1.6;
}
use Wikimedia\CSS\Parser\Parser;
use Wikimedia\CSS\Sanitizer\StylesheetSanitizer;
/** Parse a stylesheet from a string **/
$parser = Parser::newFromString( $cssText );
$stylesheet = $parser->parseStylesheet();
/** Report any parser errors **/
foreach ( $parser->getParseErrors() as list( $code, $line, $pos ) ) {
// $code is a string that should be suitable as a key for an i18n library.
// See errors.md for details.
$error = lookupI18nMessage( "css-parse-error-$code" );
echo "Parse error: $error at line $line character $pos\n";
}
/** Apply sanitization to the stylesheet **/
// If you need to customize the defaults, copy the code of this method and
// modify it.
$sanitizer = StylesheetSanitizer::newDefault();
$newStylesheet = $sanitizer->sanitize( $stylesheet );
/** Report any sanitizer errors **/
foreach ( $sanitizer->getSanitizationErrors() as list( $code, $line, $pos ) ) {
// $code is a string that should be suitable as a key for an i18n library.
// See errors.md for details.
$error = lookupI18nMessage( "css-sanitization-error-$code" );
echo "Sanitization error: $error at line $line character $pos\n";
}
/** Convert the sanitized stylesheet back to text **/
$newText = (string)$newStylesheet;
// Or if you'd rather have it minified too
$minifiedText = Wikimedia\CSS\Util::stringify( $newStylesheet, [ 'minify' => true ] );