-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:teknologi-umum/language-detector …
…into core/refactor
- Loading branch information
Showing
17 changed files
with
674 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { LanguagePattern } from '../types'; | ||
|
||
export const CS: LanguagePattern[] = [ | ||
{ pattern: /using\sSystem(\..*)?(;)?/, points: 2 }, | ||
{ pattern: /Console\.(WriteLine|Write)(\s*)?\(/, points: 2 }, | ||
{ pattern: /(public\s)?((partial|static|delegate)\s)?class\s/, points: 2 }, | ||
// Modifiers | ||
{ pattern: /(extern|override|sealed|readonly|virtual|volatile)/, points: 2 }, | ||
{ pattern: /namespace\s(.*)(\.(.*))?(\s{)?/, points: 2 }, | ||
// Regions | ||
{ pattern: /(#region(\s.*)?|#endregion\n)/, points: 2 }, | ||
// Functions | ||
{ pattern: /(public|private|protected|internal)\s/, points: 1 }, | ||
// Variable declaration | ||
{ | ||
pattern: | ||
/(const\s)?(sbyte|byte|short|ushort|int|uint|long|ulong|float|double|decimal|bool|char|string)(\[\])?\s(.*)\s=\s(.*);/, | ||
points: 1, | ||
}, | ||
// Lists | ||
{ | ||
pattern: | ||
/(new|this\s)?(List|IEnumerable)<(sbyte|byte|short|ushort|int|uint|long|ulong|float|double|decimal|bool|char|string)>/, | ||
points: 2, | ||
}, | ||
// Macro | ||
{ pattern: /#define\s(.*)/, points: 1 }, | ||
// Plus point if you're doing PascalCase | ||
{ pattern: /\s([A-Z]([A-Z0-9]*[a-z][a-z0-9]*[A-Z]|[a-z0-9]*[A-Z][A-Z0-9]*[a-z])[A-Za-z0-9]*)\s=/, points: 1 }, | ||
// Avoiding Java confusion | ||
{ pattern: /(extends|throws|@Attribute)/, points: -1 }, | ||
{ pattern: /System\.(in|out)\.\w+/, points: -50 }, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* Returns a language string that match with Shiki's language specification, | ||
* find it here: https://github.com/shikijs/shiki/blob/main/docs/languages.md | ||
* If the name is similar, we'll just convert it to lower case. | ||
* @param {String} language Language from the list | ||
* @returns {String} Shiki acceptable language | ||
*/ | ||
export function convert(language: string): string { | ||
if (language === 'C++') return 'cpp'; | ||
if (language === 'C#') return 'csharp'; | ||
return language.toLowerCase(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.