Open carnott-snap opened 4 years ago
I think this would be nice but the pretty print function I've been using is a bit of a work in progress and I'm not sure it improves things in most cases. I want to make the test suite better and I'll revisit this afterwards.
I'm a frequent jq user, but not a skilled one. Most of the time all I only use it for formatting. I know jq has powerful querying capabilities, but the formatting capability means that I can usually just use grep to meet any search/filter needs I have. That's usually enough. When necessary, very little is beyond a pipeline with multiple greps.
So 5 minutes ago I wanted to apply the same technique to HTML, Googled "like jq but for html", and here we are.
The tidy
command from htacg/tidy-html5 is another option:
curl -s https://www.w3.org/Provider/Style/URI \
| htmlq blockquote:first-of-type \
| tidy -q -f /dev/null -w 78 -i
Not saying it's as terse as what you were hoping for by making pretty-printing default for htmlq
, and it does take a bit of doing to suppress its output footer and warnings about non-conformant HTML, but piping through tidy
does fall in line with the "one thing well" philosophy.
Many users coming from
jq
will expecthtmlq
can function as a formatter for HTML. Unfortunatelyhtmlq html
does not pretty print the output. Can we deprecate the-p
flag, setting the default totrue
, and use an-c
flag that aligns with expectations?In general, it would be nice to make the flags lineup exactly with
jq
, where possible: