如何在不向 Linguist 添加新语言的情况下在 GitHub 上设置自定义扩展到语言的映射
How to set a custom extension-to-language mapping on GitHub without adding a new language to Linguist
我的仓库有几个包含 smartBASIC 源代码的 *.sb 文件。这些文件不会出现在 repo 的语言栏中(因为 smartBASIC 及其关联的文件扩展名不是默认 Linguist 定义的一部分)。
将 sb
扩展映射到 .gitattributes
文件中的 smartBASIC:
**/*.sb linguist-language=smartBASIC
并确保映射不是 "ignored":
**/*.sb linguist-vendored=false
**/*.sb linguist-generated=false
**/*.sb linguist-documentation=false
**/*.sb linguist-detectable=true
没有达到预期的效果。 sb
文件按预期处理,但 smartBASIC
不是预定义语言,因此自定义映射不会生成任何语言统计信息。 (我通过将文件映射到另一种语言 (C++) 然后让它们显示在语言栏统计信息中(如 C++)来验证这一点。
从其他问题 (, ) 看来,要将新扩展映射到新语言,需要将它们添加到 Linguist(更具体地说,至少必须添加语言)。从 Linguist 文档中可以清楚地看出,只有在 GitHub 存储库中有足够的存在时,才会添加新的 languages/extensions。这是完全有道理的。然而,这也意味着没有明显的方法将 sb
扩展映射到 smartBASIC
语言并将其显示在语言栏中(例如 repo 统计为 60% smartBASIC,30% Python , 10% 其他).
问题:是否可以在 GitHub 上使用 Linguist 覆盖将文件扩展名映射到新语言而不将新语言添加到 Linguist 本身?
是否可以使用其他方式?
(这个问题是关于 repo 的语言统计信息。语法高亮和其他自定义在这个阶段是次要的。)
目前最新的lib/linguist/languages.yml
确实没有包含smartBasic
Is it possible to map a filename extension to a new language on GitHub using Linguist overrides without adding the new language to Linguist itself
不,不支持。
您有类似 3665 的问题:"lingust-language=xyz appears to be ignored on github if 'xyz' is not a known language. Proposal: make it appear as unknown language"
但即使这样也不被接受。
Adding support for custom names in the language bar requires a lot more than a few tweaks in Linguist as the GitHub-side changes are far from trivial and would require an internally commissioned project to implement it.
我的仓库有几个包含 smartBASIC 源代码的 *.sb 文件。这些文件不会出现在 repo 的语言栏中(因为 smartBASIC 及其关联的文件扩展名不是默认 Linguist 定义的一部分)。
将 sb
扩展映射到 .gitattributes
文件中的 smartBASIC:
**/*.sb linguist-language=smartBASIC
并确保映射不是 "ignored":
**/*.sb linguist-vendored=false
**/*.sb linguist-generated=false
**/*.sb linguist-documentation=false
**/*.sb linguist-detectable=true
没有达到预期的效果。 sb
文件按预期处理,但 smartBASIC
不是预定义语言,因此自定义映射不会生成任何语言统计信息。 (我通过将文件映射到另一种语言 (C++) 然后让它们显示在语言栏统计信息中(如 C++)来验证这一点。
从其他问题 (sb
扩展映射到 smartBASIC
语言并将其显示在语言栏中(例如 repo 统计为 60% smartBASIC,30% Python , 10% 其他).
问题:是否可以在 GitHub 上使用 Linguist 覆盖将文件扩展名映射到新语言而不将新语言添加到 Linguist 本身?
是否可以使用其他方式?
(这个问题是关于 repo 的语言统计信息。语法高亮和其他自定义在这个阶段是次要的。)
目前最新的lib/linguist/languages.yml
确实没有包含smartBasic
Is it possible to map a filename extension to a new language on GitHub using Linguist overrides without adding the new language to Linguist itself
不,不支持。
您有类似 3665 的问题:"lingust-language=xyz appears to be ignored on github if 'xyz' is not a known language. Proposal: make it appear as unknown language"
但即使这样也不被接受。
Adding support for custom names in the language bar requires a lot more than a few tweaks in Linguist as the GitHub-side changes are far from trivial and would require an internally commissioned project to implement it.