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

Support syntax highlighting for <pre> blocks #36

Open
robinkrahl opened this issue Oct 3, 2020 · 2 comments
Open

Support syntax highlighting for <pre> blocks #36

robinkrahl opened this issue Oct 3, 2020 · 2 comments

Comments

@robinkrahl
Copy link
Contributor

The reason why I wanted a fix for preformatted blocks (#32) was that I wanted to implement syntax highlighting for code blocks for rusty-man. With the new release v0.2.1, I was able to implement basic syntax highlighting using syntect. My current implementation could still be improved: Context is very important for proper syntax highlighting, but I cannot identify the block a string with a preformatted annotation belongs to. Therefore I just assume that there is only one preformatted string per line, and that preformatted strings in adjacent lines belong to the same block. Of course, this does not hold for tables or for subsequent code blocks.

Do you think html2text could make it easier to highlight code blocks?

@robinkrahl
Copy link
Contributor Author

Also, I forgot to mention: As Rust doc comments mostly contain Rust code snippets, I just use the Rust syntax for syntax highlighting. But in general, HTML classes are used to identify the appropriate syntax. It would be nice if html2text would support that – see also #27.

@jugglerchris
Copy link
Owner

That sounds great - I'd definitely be interested in making it easier to do things like that, and either including syntect support in html2text (probably with a feature flag) or even better making it easier to integrate with an external highlighting crate.

If #27 were implemented I guess that means you could both have access to the class for choosing the syntax and know which block each tagged element belongs to so that would be a good start - but I'm up for improving the API in other ways to make this easier.

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

No branches or pull requests

2 participants