mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/SyntaxHighlight_GeSHi
synced 2024-11-13 17:50:37 +00:00
Avoid PHP_EOL while generating CSS
Change-Id: I242abd8fe68fd08ddb3c6358aa88b6f3d382823b
This commit is contained in:
parent
b32859f705
commit
e45a7eac30
|
@ -153,30 +153,33 @@ class Pygmentize {
|
|||
->execute();
|
||||
self::recordShellout( 'generated_css' );
|
||||
|
||||
$lightModeOutput = $lightModeRun->getStdout();
|
||||
$lightModeOutput = trim( $lightModeRun->getStdout() );
|
||||
if ( $lightModeRun->getExitCode() != 0 ) {
|
||||
throw new PygmentsException( $lightModeOutput );
|
||||
}
|
||||
$darkModeOutput = $darkModeRun->getStdout();
|
||||
$darkModeOutput = trim( $darkModeRun->getStdout() );
|
||||
if ( $darkModeRun->getExitCode() != 0 ) {
|
||||
throw new PygmentsException( $darkModeOutput );
|
||||
}
|
||||
|
||||
$lightModeRules = explode( PHP_EOL, $lightModeOutput );
|
||||
$darkModeRules = explode( PHP_EOL, $darkModeOutput );
|
||||
$lightModeRules = explode( "\n", $lightModeOutput );
|
||||
$darkModeRules = explode( "\n", $darkModeOutput );
|
||||
$commonRules = array_intersect( $lightModeRules, $darkModeRules );
|
||||
|
||||
$nightThemeCss = implode( PHP_EOL, array_diff( $darkModeRules, $commonRules ) );
|
||||
$nightThemeCss = implode( "\n", array_diff( $darkModeRules, $commonRules ) );
|
||||
$osThemeCss = str_replace( '.skin-theme-clientpref-night',
|
||||
'.skin-theme-clientpref-os', $nightThemeCss );
|
||||
|
||||
return $lightModeOutput
|
||||
. "@media screen {" . PHP_EOL
|
||||
. $nightThemeCss . PHP_EOL
|
||||
. "}" . PHP_EOL
|
||||
. "@media screen and ( prefers-color-scheme: dark ) {" . PHP_EOL
|
||||
. $osThemeCss . PHP_EOL .
|
||||
"}" . PHP_EOL;
|
||||
return <<<EOD
|
||||
$lightModeOutput
|
||||
@media screen {
|
||||
$nightThemeCss
|
||||
}
|
||||
@media screen and ( prefers-color-scheme: dark ) {
|
||||
$osThemeCss
|
||||
}
|
||||
|
||||
EOD;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue