Deep-Symmetry / crate-digger

Java library for fetching and parsing rekordbox exports and track analysis files.
Other
137 stars 18 forks source link

Fix .ksy file syntax highlighting on GitHub #17

Closed generalmimon closed 3 years ago

generalmimon commented 3 years ago

Since GitHub recognizes the .ksy file extension out of the box (https://github.com/github/linguist/pull/4830), it is no longer needed to specify the language in .gitattributes manually.

brunchboy commented 3 years ago

Interesting. Does it do any harm to leave those set?

generalmimon commented 3 years ago

@brunchboy:

Interesting. Does it do any harm to leave those set?

It wouldn't harm anything if the linguist-language value would match an existing name in the languages.yml file. However, you call it KaitaiStruct, but it is registered under the name Kaitai Struct in the languages.yml file:

Kaitai Struct:
  type: programming
  aliases:
  - ksy
  ace_mode: yaml
  # ...

And for language names with spaces in them, the Linguist docs (docs/overrides.md#using-gitattributes) advise this:

# Replace any whitespace in the language name with hyphens:
*.glyphs linguist-language=OpenStep-Property-List

In short, you would need to change this

https://github.com/Deep-Symmetry/crate-digger/blob/e33b8ac3c5fa6a7c8072e3a88e2701d60308e1c3/.gitattributes#L1

into

*.ksy linguist-language=Kaitai-Struct

Also, I'm not 100% sure if the line

https://github.com/Deep-Symmetry/crate-digger/blob/e33b8ac3c5fa6a7c8072e3a88e2701d60308e1c3/.gitattributes#L2

would work as intended; in the Linguist docs, the linguist-detectable attribute is just included without any value (docs/overrides.md#detectable):

Use the linguist-detectable attribute to mark or unmark paths as detectable:

*.kicad_pcb linguist-detectable
*.sch linguist-detectable
tools/export_bom.py -linguist-detectable

So just to make sure it will work, I'd recommend the official approach.


Also, the basic feature of the .gitattributes file is the support of multiple attributes per path pattern, see https://git-scm.com/docs/gitattributes#_description:

A gitattributes file is a simple text file that gives attributes to pathnames.

Each line in gitattributes file is of form:

pattern attr1 attr2 ...

so you can easily merge the two attributes linguist-{language,detectable} into one line:

*.ksy linguist-language=Kaitai-Struct linguist-detectable
brunchboy commented 3 years ago

I see! Thank you for the very detailed explanation.