github-linguist / linguist

Language Savant. If your repository's language is being reported incorrectly, send us a pull request!
MIT License
12.31k stars 4.26k forks source link

jq vs jsoniq #3693

Closed pjeby closed 7 years ago

pjeby commented 7 years ago

Hi there. I'm working on a project, jqmd, which makes use of jq blocks in markdown, meaning specifically the popular jq language for manipulating JSON data.

Unfortunately, linguist apparently interprets the jq code tag as meaning the jsoniq language, so I'm not sure what to do about it. I'd been planning to implement a jq grammar for Atom at some point anyway, but now I'm wondering whether that'll help on github if jq is going to be interpreted as jsoniq.

Doing a repository search for the JSONiq language, however, shows that many, if not most "jsoniq" code on github is in fact jq code, i.e. written in the stedolan/jq language, and unrelated to the jsoniq language. Even after you filter false positives for jquery, there are considerably more jq-related repositories to be found than jsoniq-related repositories.

jq and jsoniq do have some minor overlap in grammar, which is probably why you haven't had many (or perhaps any) reports of this issue before. In a sufficiently simple jq program (e.g. one containing only expressions), the issues would not be obvious at first glance. The big differences are that jsoniq has a lot more keywords, but doesn't grok def, elif, end, or #-comments. But for more sophisticated jq programs -- especially commented ones -- the differences are distracting and apparent.

Anyway, I guess my question is, should I take a crack at implementing a jq grammar, or is the "jq" language tag "taken" as far as github is concerned? Thanks.

pchaigno commented 7 years ago

Linguist doesn't now what jq is yet, which is why it's classifying all those files as jsoniq. The first step to have jq code snippets highlighted would be to add it to Linguist.

pjeby commented 7 years ago

Ah. Thanks for pointing me in the right direction. So I take it I should close this issue and open a PR with the grammar and some heuristic(s) for distinguishing the two?

pchaigno commented 7 years ago

Yes :-) We'll help if there's any issue with the pull request.

pjeby commented 7 years ago

Great. Thanks.

wader commented 3 years ago

@pjeby Hi, I might look into adding support. Did you make any progress?

pjeby commented 3 years ago

No. I did find this JQ grammar though, that might help as a starting point.

pjeby commented 3 years ago

There is also an atom grammar, which should also be helpful.

wader commented 3 years ago

@pjeby Ok! thanks for the references!

wader commented 3 years ago

Hi, did a first attempt here #5233