so icon indicating copy to clipboard operation
so copied to clipboard

feature: highlight source code

Open D1mon opened this issue 4 years ago • 3 comments

D1mon avatar Jul 10 '20 12:07 D1mon

Hi @D1mon can you elaborate on what you mean by this?

samtay avatar Jul 10 '20 22:07 samtay

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=c8f1ab7357aa8359679b6a47a4ce5ca4 Press "Config" select Style to "Simple" this is without highlight code syntax. There is currently no syntax highlighting in the program ("so" program). I want syntax highlighting when viewing code. By the link above we do and switch: "Config" Style -> "Advanced" and "theme" -> "dracula" or other theme.

made some screenshots without syntax highlighting and with syntax highlighting 1 2

D1mon avatar Jul 11 '20 07:07 D1mon

Oh yes, syntax highlighting. This would be cool, but seems like a high level of effort. Maybe if I find time, or others are motivated. My initial thoughts on the approach:

  • Use the CodeBlockKind::Fenced enum variant in the markdown parser.
  • Use a lib like syntect for the actual heavy lifting. Somehow get like an AST out of it, so that the output can be coerced into a cursive SpannedString.
  • Transform the current cursive theme into a theme expected by syntect, so the colors blend in well.
  • It might be difficult to add this to the --lucky prompt, unless termimad explicitly adds this feature as well.

samtay avatar Jul 12 '20 19:07 samtay