tomnomnom / gron

Make JSON greppable!
MIT License
13.73k stars 325 forks source link

Colour - Support Highlighting when Ungronning from grep. #110

Open stellarpower opened 1 year ago

stellarpower commented 1 year ago

image

Removal of ANSI escape codes was discussed in #47, as these cause parse errors.

I'd like to highlight one area where they're very useful - when using coloured output from grep to highlight incidents of the search term. When grepping for plain text, it's a very useful feature, especially if the input lines are very long, as it makes it easy to find the actual pattern within that text.

Gron's colour output when ungronning is nice, and makes JSON easy to scan, but I'd like to suggest adding the ability to colourise the search term within that output so that it is also easy to see it in the subset that is returned from a search:

image

If it would be possible to parse the input properly when it includes escape codes in it (I don't know if some corner cases mean this could break things), and a boolean flag indicating the portion of the input that is the search result when escape codes are seen, and then colourise the portions of the output in a similar way, I think that would be a potential way to implement this, and help make gron quicker to use.

Thanks!!