mgdm / htmlq

Like jq, but for HTML.
MIT License
7k stars 107 forks source link

Add support for syntax highlighting #17

Closed jihchi closed 2 years ago

jihchi commented 2 years ago

It would be useful for people to interact with the CLI.

For example:

curl -sL google.com | htmlq -h -p html body \#gbar

2021-09-08 20-09-51

Alhadis commented 2 years ago

This is arguably the domain of a dedicated syntax highlighter (e.g., bat):

$ curl -sL google.com | htmlq -p html body div | bat -lhtml

I mean, it looks nice out-of-the-box, but what if users want to post-process the output and highlight it?

Just some food for thought.

jihchi commented 2 years ago

@Alhadis I wasn’t aware of that we can utilize bat to do the syntax highlighting!

I am adding a new argument (e.g. -h/—syntax-highlighting) to enable the feature and disable it by default.

Thanks for the comments/thoughts! This is why I created this draft PR!

Alhadis commented 2 years ago

No problem. IMHO, it might be better to recommend tools like bat (or any others you know of) in the readme (with links and examples), which would spare you the burdens of keeping htmlq's highlighting on par with other tools for highlighting source code.

jihchi commented 2 years ago

Closing this PR in favor of #18 .