diff --git a/resources/samples/sample.php b/resources/samples/sample.php index 568b68b3..e886ba39 100644 --- a/resources/samples/sample.php +++ b/resources/samples/sample.php @@ -12,7 +12,7 @@ $sample = file_get_contents(__DIR__.'/'.$grammar.'.sample'); $tokens = (new Phiki($environment))->codeToTokens($sample, $grammar); -$html = (new Phiki($environment))->codeToHtml($sample, $grammar, ['light' => Theme::GithubLight, 'dark' => 'github-dark']); +$html = (new Phiki($environment))->codeToHtml($sample, $grammar, ['light' => Theme::OneLight, 'dark' => 'github-dark']); ?> diff --git a/src/Generators/HtmlGenerator.php b/src/Generators/HtmlGenerator.php index 17e92bc3..c8c172c0 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] ?? null)?->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), ); }