Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: highlight source code #6

Open
D1mon opened this issue Jul 10, 2020 · 3 comments
Open

feature: highlight source code #6

D1mon opened this issue Jul 10, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@D1mon
Copy link

D1mon commented Jul 10, 2020

No description provided.

@samtay
Copy link
Owner

samtay commented Jul 10, 2020

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

@D1mon
Copy link
Author

D1mon commented Jul 11, 2020

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

@samtay
Copy link
Owner

samtay commented Jul 12, 2020

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 samtay added the enhancement New feature or request label Jul 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants