Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion apps/theming/lib/Controller/ThemingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,17 @@ public function getThemeStylesheet(string $themeId, bool $plain = false, bool $w
$css = ":root { $variables } " . $customCss;
} else {
// If not set, we'll rely on the body class
$css = "[data-theme-$themeId] { $variables $customCss }";
// We need to separate @-rules from normal selectors, as they can't be nested
// This is a replacement for the SCSS compiler that did this automatically before f1448fcf0777db7d4254cb0a3ef94d63be9f7a24
// We need a better way to handle this, but for now we just remove comments and split the at-rules
// from the rest of the CSS.
$customCssWithoutComments = preg_replace('!/\*.*?\*/!s', '', $customCss);
$customCssWithoutComments = preg_replace('!//.*!', '', $customCssWithoutComments);
preg_match_all('/(@[^{]+{(?:[^{}]*|(?R))*})/', $customCssWithoutComments, $atRules);
$atRulesCss = implode('', $atRules[0]);
$scopedCss = preg_replace('/(@[^{]+{(?:[^{}]*|(?R))*})/', '', $customCssWithoutComments);

$css = "$atRulesCss [data-theme-$themeId] { $variables $scopedCss }";
}

try {
Expand Down
Loading