colorediffs icon indicating copy to clipboard operation
colorediffs copied to clipboard

Highlight language syntax

Open GoogleCodeExporter opened this issue 10 years ago • 4 comments

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

GoogleCodeExporter avatar Mar 16 '15 13:03 GoogleCodeExporter

Original comment by [email protected] on 15 Jul 2007 at 8:30

  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

GoogleCodeExporter avatar Mar 16 '15 13:03 GoogleCodeExporter

Many appreciations for the work, any thoughts on this issue?

tristone13th avatar Jan 07 '23 14:01 tristone13th

I think we can use a simple regex to parse each code change line and add corresponding highlights, do you think it is feasible?

tristone13th avatar Jan 07 '23 14:01 tristone13th

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 :)

Qeole avatar Jan 08 '23 22:01 Qeole