cablehead / stacks

clip clip, pew pew
https://stacks.cross.stream
MIT License
92 stars 5 forks source link

fix: syntax highlighting doesn't switch dark / light mode when the UI does #51

Open cablehead opened 7 months ago

cablehead commented 7 months ago
image


Currently, markdown rendering and syntax highlighting are handled in the Rust backend. This might be a mistake, and potentially we should move this responsibility to the webview / Javascript.

Syntax highlighting leverages syntext, as detailed here: https://github.com/cablehead/stacks/blob/main/src-tauri/src/ui.rs#L304-L313

The implementation "bakes" the color scheme directly into the generated HTML. The frontend, which caches this content, doesn't update the syntax highlighting color scheme when the main UI toggles between light and dark modes.

I think there's ~2 solutions:

  1. Use classes for syntax highlighting elements, avoiding hardcoded color values. This way, CSS classes with variables can adjust to light/dark mode changes in the main UI.

Possible approaches for this solution include:

  1. Invalidate the frontend's content cache when toggling between light and dark modes.
cablehead commented 6 months ago

This'll be nice to fix

image