2

We have files in our GitHub repo that are technically json files, but don't have a .json extension. when used in the "view" mode in GitHub, the files are treated as plain text, but some of the json files have markdown content inside fields in the json, so the "view" display will display some plain text, some markdown, etc.

like this file: IntuneAuditActivity.workbook

partial markdown

in this case, the autoformatting sees 4 space characters after a couple levels of indentation and thinks this is markdown and shows the rest of the file as code...

is there some way to configure in GitHub how file types are explicitly handled? I can't find it anywhere in the settings.

I was hoping that maybe there was something in .gitattributes for this but nothing jumps out at me so far, and just adding *.workbook text there didn't seem to have any difference in gihubs' behavior for these files.

John Gardner
  • 24,225
  • 5
  • 58
  • 76

1 Answers1

1

You can test if a .gitattributes linguistic directive, as I mentioned in "Github changes repository to wrong language", would be enough:

*.workbook linguist-detectable
*.workbook linguist-language=JSON
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • awesome, i'm trying this and will validate it, and will update here – John Gardner Feb 07 '20 at 22:34
  • @JohnGardner By the way, you left (then deleted) on https://stackoverflow.com/a/60088126/6309 an interesting comment about Linus being wrong about SHA1DC. Do you have any link/study about the vulnerability of SHA1DC in the context of a Git repository? – VonC Feb 08 '20 at 09:33
  • i left a comment about linus being wrong somewhere? if i did that it would be amazing! i don't see a comment there that i deleted, are you sure it was me? – John Gardner Feb 10 '20 at 18:33
  • also, i did the above [here](https://github.com/microsoft/Application-Insights-Workbooks/blob/master/.gitattributes) but at least in the github ui on the web it still always just formats the files as plain text instead of json. i don't think i spelled anything wrong, am i missing something? – John Gardner Feb 10 '20 at 18:36
  • in fact, in the github search UI, it somehow thinks `.workbook` files are markdown? (they sometimes *contain* markdown inside the json content...) – John Gardner Feb 10 '20 at 18:38
  • Strange, that could be a bug to report to https://github.com/github/linguist/issues. – VonC Feb 10 '20 at 19:18
  • yes, walking through repros and stuff to do that now. because this *should* be the right answer, the bounty is yours – John Gardner Feb 11 '20 at 22:18