@buherator the accepted SO answer is wrong? Read the comments closely; they say linguist is used only for filetype detection.
The second answer says "tree-sitter" and links to a GH discussion with more implementation details from someone at GH:
https://github.com/github-linguist/linguist/discussions/5572#discussioncomment-1355712