From 2a8a47469cbfabe6d6b57d19694d4ebbd4725e3e Mon Sep 17 00:00:00 2001 From: Ryan Chandler Date: Tue, 5 Nov 2024 01:14:54 +0000 Subject: [PATCH] fix: dont assume that all themes will highlight a token --- src/Generators/HtmlGenerator.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Generators/HtmlGenerator.php b/src/Generators/HtmlGenerator.php index 17e92bc..7d48d40 100644 --- a/src/Generators/HtmlGenerator.php +++ b/src/Generators/HtmlGenerator.php @@ -95,11 +95,11 @@ public function generate(array $tokens): string } $tokenStyles = [ - $token->settings[$defaultThemeId]->toStyleString(), + $token->settings[$defaultThemeId]?->toStyleString(), ]; foreach ($token->settings as $id => $settings) { - if ($settings === $token->settings[$defaultThemeId]) { + if ($id === $defaultThemeId) { continue; } @@ -108,7 +108,7 @@ public function generate(array $tokens): string $html[] = sprintf( '%s', - implode(';', $tokenStyles), + implode(';', array_filter($tokenStyles)), htmlspecialchars($token->token->text), ); }