colorediffs
colorediffs copied to clipboard
Highlight language syntax
The language of code should be determined (probably by file extension) and
highlighted.
Original issue reported on code.google.com by [email protected] on 14 Jul 2007 at 10:39
Original comment by [email protected] on 15 Jul 2007 at 8:30
- Added labels: Type-Enhancement
- Removed labels: Type-Defect
Many appreciations for the work, any thoughts on this issue?
I think we can use a simple regex to parse each code change line and add corresponding highlights, do you think it is feasible?
You'd need a set of regular expressions for all the main languages, I don't want to implement and maintain that. But given that we're already using a library to highlight the diff (https://highlightjs.org/) which does that already, maybe there would be a possibility to reuse it to highlight a short snippet of code. We'd have to parse the diff to reliably extract the file extension and deduce the language, then extract the portion we want to highlight (All code snippets? Just the modified lines?), then highlight them without breaking the formatting of the message (and figure out how to mark additions/deletions on top of that).
Nothing undoable, but that's more work than I can afford to spend on this add-on at the moment. You're welcome to try something if you feel like it :)