Skip to content

fix: use TokyoNight config for tokyo-night code rendering - #977

Open
s3onghyun wants to merge 1 commit into
charmbracelet:masterfrom
s3onghyun:fix-tokyo-night-code-style
Open

fix: use TokyoNight config for tokyo-night code rendering#977
s3onghyun wants to merge 1 commit into
charmbracelet:masterfrom
s3onghyun:fix-tokyo-night-code-style

Conversation

@s3onghyun

Copy link
Copy Markdown

What's wrong

In GlamourStyle(style, isCode), the branch that builds a StyleConfig for rendering pure code files (non-markdown extensions, isCode == true) maps tokyo-night to the Dracula config:

case styles.TokyoNightStyle:
    styleConfig = styles.DraculaStyleConfig // wrong

So glow --style tokyo-night <codefile> renders code with Dracula colors instead of Tokyo Night. glamour exports a distinct styles.TokyoNightStyleConfig (different palette), and every other case in the switch maps to its own config — tokyo-night is the lone copy-paste mistake.

(Regular markdown rendering with tokyo-night is unaffected; it goes through glamour's WithStylePath. This bug is specific to the code-file branch.)

Fix

One line: case styles.TokyoNightStyle:styles.TokyoNightStyleConfig.

Testing

Added utils/utils_test.go: renders a code block with tokyo-night and dracula (color forced via CLICOLOR_FORCE) and asserts the output differs. Fails before the fix (identical output), passes after. go test ./utils/ green.

GlamourStyle's code-block branch mapped the tokyo-night style to
DraculaStyleConfig, so 'glow --style tokyo-night <codefile>' rendered code
with Dracula colors instead of Tokyo Night. glamour exports a distinct
TokyoNightStyleConfig; use it. Every other case maps to its own config.

Signed-off-by: Seonghyun Hong <s3onghyun.hong@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant