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

Add support for syntax highlighting #17

Closed
wants to merge 2 commits into from

Conversation

jihchi
Copy link

@jihchi jihchi commented Sep 8, 2021

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
Copy link
Contributor

Alhadis commented Sep 8, 2021

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
Copy link
Author

jihchi commented Sep 8, 2021

@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
Copy link
Contributor

Alhadis commented Sep 8, 2021

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
Copy link
Author

jihchi commented Sep 9, 2021

Closing this PR in favor of #18 .

@jihchi jihchi closed this Sep 9, 2021
mgdm pushed a commit that referenced this pull request Sep 15, 2021
* Improve syntax highlighting of command examples

* Add link to JQ's homepage and tidy preamble

* Include an example showing how to highlight output

Refs: #17 (comment)

* Limit screenshot width to 700px

* Use a more reproducible highlighting example

Refs: https://github.com/mgdm/htmlq/pull/18/files#r705092112

* Align with #11 and crop command from screenshot

* Add permalinks to headings added in 014ae25

* Remove redundant trailing lines in console output
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

Successfully merging this pull request may close these issues.

2 participants