Skip to content

Commit

Permalink
fix: dont assume that all themes will highlight a token
Browse files Browse the repository at this point in the history
  • Loading branch information
ryangjchandler committed Nov 5, 2024
1 parent 1544ccc commit 2a8a474
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Generators/HtmlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -108,7 +108,7 @@ public function generate(array $tokens): string

$html[] = sprintf(
'<span class="token" style="%s">%s</span>',
implode(';', $tokenStyles),
implode(';', array_filter($tokenStyles)),
htmlspecialchars($token->token->text),
);
}
Expand Down

0 comments on commit 2a8a474

Please sign in to comment.