Expand description
What language a path is written in, the colour GitHub paints it, and the comment syntax the line counter needs.
Detection is a pure path function: the syntax registry already maps every extension it can highlight to a grammar, so that mapping stays the one source of truth and this module adds the languages diffler counts but does not highlight. Colours are Linguist’s own hexes, the ones a reader knows from a repository page, lifted toward the foreground when the terminal’s background would swallow them.
Structs§
- Language
- A language diffler can name, with everything the breakdown needs about it.
Functions§
- count_
lines - The
(code, comments, blanks)a source text holds. A line counts as a comment when it opens with one, so a trailing// noteafter code reads as code, the same callsccandclocmake. - of_path
- The language of
path, by extension or by whole filename. - readable_
on - Lift
coloruntil it separates frombg. Linguist’s palette is tuned for a white page, so a few entries (JSON’s#292929, C’s#555555) vanish on a dark terminal and a few of the bright ones wash out on a light one.