json is not syntax highlighted when piped in from jq
Closed this issue · 3 comments
danwt commented
json is not syntax highlighted when piped in from jq
walles commented
There are three(ish) ways to handle this:
jq < hello.json | moar --lang=json
will tellmoar
the input is JSON, andmoar
will highlight it.jq --color-output < hello.json | moar
will telljq
to send colored output tomoar
.moar hello.json
will tellmoar
the input is JSON (based on the.json
extension) andmoar
will highlight it.
The root cause is that jq
sends an untyped non-highlighted stream to moar
, so moar
doesn't know the input is JSON, and can't highlight it.
Note that when you do just jq < hello.json
, jq
will color its output because it's going to a terminal.
But if you do jq < hello.json | cat
, jq
will not color its output, because it's going to a stream.
Does this answer your question?
danwt commented
Yes thanks
I suppose you don't want to have a feature for moar to automatically check various common syntaxes for highlighting?
walles commented
Thinking about it, it should be possible to have moar
check for JSON specifically using Go's standard JSON library.
Thanks for the inspiration, let me ponder this.