Skip to content

Commit

Permalink
Fix handling of duplicate extensions
Browse files Browse the repository at this point in the history
GitHub includes several languages that have the same extensions.
For example, `.cake` is used for CoffeeScript and for C#.
But which one is used for ` ```cake `?
The answer is complex.
But this commit solves it, it removes duplicate extensions from
languages that will not get highlighted as such if you use them.
Practically, that means `.cake` is no longer present here as an
extension for CoffeeScript.
Previously, which language was chosen was decided based on in which
order languages were loaded: later languages “won”.

There are some cases, where the common extensions, such as `.md`,
is *not* used to highlight as markdown, which one might expect.
It’s instead highlighted as Lisp.
That’s unfortunate, but it’s better to match how GitHub works, and
these cases can be fixed upstream in `github/linguist`.

Finally, an almost never used feature of fenced code blocks on GitHub,
is that you can write explicit extensions (` ```.js `).
Sometimes, when there is a dot, it maps to different languages.
This project now matches GitHub in what values without a dot, and with a
dot, map to.

More info in:
<github-linguist/linguist#6338>.
  • Loading branch information
wooorm committed Mar 24, 2023
1 parent e72a129 commit 8513679
Show file tree
Hide file tree
Showing 114 changed files with 305 additions and 215 deletions.
2 changes: 1 addition & 1 deletion lang/source.abl.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lang/source.ada.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.adb', '.ada', '.ads'],
extensions: ['.ada', '.ads'],
extensionsWithDot: ['.adb'],
names: ['ada', 'ada95', 'ada2005'],
patterns: [
{
Expand Down
2 changes: 1 addition & 1 deletion lang/source.angelscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.as', '.angelscript'],
extensions: ['.angelscript'],
names: ['angelscript'],
patterns: [
{
Expand Down
3 changes: 2 additions & 1 deletion lang/source.assembly.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.asm', '.a51', '.i', '.inc', '.nas', '.nasm'],
extensions: ['.asm', '.a51', '.i', '.nas', '.nasm'],
extensionsWithDot: ['.inc'],
names: ['assembly', 'asm', 'nasm'],
patterns: [
{
Expand Down
2 changes: 1 addition & 1 deletion lang/source.befunge.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.befunge', '.bf'],
extensions: ['.befunge'],
names: ['befunge'],
patterns: [
{match: '[0-9]', name: 'constant.numberic.bf'},
Expand Down
2 changes: 1 addition & 1 deletion lang/source.bf.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.b', '.bf'],
extensions: ['.b'],
names: ['brainfuck'],
patterns: [
{match: '[+-]', name: 'constant.character.modify-value.bf'},
Expand Down
2 changes: 1 addition & 1 deletion lang/source.brs.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.brs', '.bs'],
extensions: ['.brs'],
names: ['brighterscript', 'brightscript'],
patterns: [{include: '#entire_language'}],
repository: {
Expand Down
3 changes: 0 additions & 3 deletions lang/source.c++.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@ const grammar = {
'.cxx',
'.edc',
'.gml',
'.h',
'.h++',
'.hh',
'.hpp',
'.hxx',
'.i',
'.inc',
'.inl',
'.ino',
'.ipp',
Expand Down
4 changes: 0 additions & 4 deletions lang/source.c.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@ const grammar = {
extensions: [
'.c',
'.cats',
'.cl',
'.d',
'.h',
'.idc',
'.opencl',
'.pm',
'.upc',
'.x',
'.xbm',
'.xpm',
'.xs'
Expand Down
1 change: 0 additions & 1 deletion lang/source.clojure.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: [
'.bb',
'.boot',
'.cl2',
'.clj',
Expand Down
1 change: 0 additions & 1 deletion lang/source.coffee.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
const grammar = {
extensions: [
'._coffee',
'.cake',
'.cjsx',
'.coffee',
'.cson',
Expand Down
2 changes: 1 addition & 1 deletion lang/source.cool.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.cl'],
extensions: [],
names: ['cool'],
patterns: [
{match: '--(.*)\\n', name: 'comment.line.double-dash'},
Expand Down
3 changes: 2 additions & 1 deletion lang/source.coq.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.coq', '.v'],
extensions: ['.coq'],
extensionsWithDot: ['.v'],
names: ['coq'],
patterns: [
{include: '#multilinecomment'},
Expand Down
2 changes: 1 addition & 1 deletion lang/source.cuesheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.cue'],
extensions: [],
names: ['cue-sheet'],
patterns: [
{
Expand Down
2 changes: 1 addition & 1 deletion lang/source.denizenscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.dsc'],
extensions: [],
names: ['denizenscript'],
patterns: [
{include: '#comments'},
Expand Down
2 changes: 1 addition & 1 deletion lang/source.euphoria.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.e', '.ex'],
extensions: [],
names: ['euphoria'],
patterns: [
{include: '#comments'},
Expand Down
2 changes: 1 addition & 1 deletion lang/source.forth.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.fth', '.4th', '.f', '.for', '.forth', '.fr', '.frt', '.fs'],
extensions: ['.fth', '.4th', '.f', '.for', '.forth', '.fr', '.frt'],
names: ['forth'],
patterns: [
{
Expand Down
2 changes: 1 addition & 1 deletion lang/source.fortran.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.f', '.f77', '.for', '.fpp'],
extensions: ['.f77', '.fpp'],
injections: {
'source.fortran - (source.fortran.modern)': {
patterns: [
Expand Down
3 changes: 2 additions & 1 deletion lang/source.ftl.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.ftl'],
extensions: [],
extensionsWithDot: ['.ftl'],
names: ['fluent'],
patterns: [
{include: '#comment'},
Expand Down
2 changes: 1 addition & 1 deletion lang/source.gap.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.g', '.gap', '.gd', '.gi', '.tst'],
extensions: ['.gap', '.gd', '.gi', '.tst'],
names: ['gap'],
patterns: [
{match: '^\\s*(end|fi|od)$', name: 'invalid.illegal.end-statement.gap'},
Expand Down
2 changes: 1 addition & 1 deletion lang/source.gdscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.gd'],
extensions: [],
names: ['gdscript'],
patterns: [
{include: '#nodepath_object'},
Expand Down
3 changes: 1 addition & 2 deletions lang/source.gerber.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@ const grammar = {
'.gbp',
'.gbs',
'.gko',
'.gml',
'.gpb',
'.gpt',
'.gtl',
'.gto',
'.gtp',
'.gts',
'.ncl',
'.sol'
],
extensionsWithDot: ['.ncl'],
names: ['gerber-image', 'rs-274x'],
patterns: [
{
Expand Down
1 change: 0 additions & 1 deletion lang/source.gfm.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const grammar = {
extensions: [
'.livemd',
'.markdown',
'.md',
'.mdown',
'.mdwn',
'.mdx',
Expand Down
1 change: 0 additions & 1 deletion lang/source.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const grammar = {
'.fp',
'.frag',
'.frg',
'.fs',
'.fsh',
'.fshader',
'.geo',
Expand Down
2 changes: 1 addition & 1 deletion lang/source.gosu.2.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.gs', '.gst', '.gsx', '.vark'],
extensions: ['.gst', '.gsx', '.vark'],
names: ['gosu'],
patterns: [
{match: '\\b(List|Map)\\b', name: 'support.class.gosu.2'},
Expand Down
3 changes: 2 additions & 1 deletion lang/source.hack.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.hack', '.hh', '.hhi', '.php'],
extensions: ['.hack', '.hhi'],
extensionsWithDot: ['.php'],
names: ['hack'],
patterns: [{include: 'text.html.basic'}, {include: '#language'}],
repository: {
Expand Down
2 changes: 1 addition & 1 deletion lang/source.haskell.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.chs', '.dhall', '.fr', '.hs', '.hs-boot', '.hsc'],
extensions: ['.chs', '.dhall', '.hs', '.hs-boot', '.hsc'],
names: ['c2hs', 'c2hs-haskell', 'dhall', 'frege', 'haskell'],
patterns: [{include: '#haskell_source'}],
repository: {
Expand Down
3 changes: 2 additions & 1 deletion lang/source.hql.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.q', '.hql'],
extensions: ['.hql'],
extensionsWithDot: ['.q'],
names: ['hiveql'],
patterns: [
{include: '#comments'},
Expand Down
2 changes: 0 additions & 2 deletions lang/source.ini.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: [
'.cfg',
'.cnf',
'.dof',
'.ini',
Expand All @@ -13,7 +12,6 @@ const grammar = {
'.pcbdoc',
'.prefs',
'.prjpcb',
'.pro',
'.properties',
'.schdoc',
'.url'
Expand Down
3 changes: 2 additions & 1 deletion lang/source.jasmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.j'],
extensions: [],
extensionsWithDot: ['.j'],
names: ['jasmin'],
patterns: [
{include: '#class-def'},
Expand Down
2 changes: 1 addition & 1 deletion lang/source.java-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.properties'],
extensions: [],
names: ['java-properties'],
patterns: [
{match: '^\\s*$'},
Expand Down
3 changes: 2 additions & 1 deletion lang/source.jflex.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.flex', '.jflex'],
extensions: ['.jflex'],
extensionsWithDot: ['.flex'],
names: ['jflex'],
patterns: [
{
Expand Down
2 changes: 1 addition & 1 deletion lang/source.jq.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.jq'],
extensions: [],
names: ['jq'],
patterns: [{include: '#main'}],
repository: {
Expand Down
4 changes: 0 additions & 4 deletions lang/source.js.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ const grammar = {
'.cjs',
'.code-snippets',
'.cy',
'.es',
'.es6',
'.frag',
'.gs',
'.jake',
'.javascript',
'.js',
Expand All @@ -33,7 +30,6 @@ const grammar = {
'.mjs',
'.njs',
'.pac',
'.qs',
'.sjs',
'.ssjs',
'.sublime-build',
Expand Down
2 changes: 1 addition & 1 deletion lang/source.js.objj.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lang/source.jsoniq.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.jq'],
extensions: [],
extensionsWithDot: ['.jq'],
names: ['jsoniq'],
patterns: [{include: '#main'}],
repository: {
Expand Down
2 changes: 1 addition & 1 deletion lang/source.kickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.ks'],
extensions: [],
names: ['kickstart'],
patterns: [
{
Expand Down
2 changes: 1 addition & 1 deletion lang/source.lex.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.l', '.lex'],
extensions: ['.lex'],
names: ['lex', 'flex'],
patterns: [{include: '#main'}],
repository: {
Expand Down
2 changes: 1 addition & 1 deletion lang/source.loomscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.ls'],
extensions: [],
names: ['loomscript'],
patterns: [
{include: '#comments'},
Expand Down
Loading

0 comments on commit 8513679

Please sign in to comment.