forked from EnlighterJS/EnlighterJS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added sh,zsh as shell alias; language aliases defined via static meth…
…od within support files
- Loading branch information
1 parent
d63b6c5
commit 8917577
Showing
20 changed files
with
155 additions
and
47 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,68 @@ | ||
// ---------------------------------------------------------------------- | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
// -- | ||
// Copyright 2016-2019 Andi Dittrich <https://andidittrich.de> | ||
// ---------------------------------------------------------------------- | ||
|
||
// Container of Language Engines | ||
import * as _languages from '../lang/index'; | ||
|
||
// internal alias list with default mappings | ||
const _aliasList = { | ||
'standard': 'generic' | ||
}; | ||
|
||
// flag | ||
let _aliasListGenerated = false; | ||
|
||
// helper function to process aliases | ||
function resolveAlias(lang){ | ||
// alias list generated ? | ||
if (!_aliasListGenerated){ | ||
// set flag | ||
_aliasListGenerated = true; | ||
|
||
// process each language support file | ||
for (const name in _languages){ | ||
// alias available ? | ||
if (typeof _languages[name].alias !== 'function'){ | ||
continue; | ||
} | ||
|
||
// get available aliases | ||
const aliases = _languages[name].alias(); | ||
|
||
// process | ||
for (const alias of aliases){ | ||
// assign alias to language filename | ||
_aliasList[alias] = name; | ||
} | ||
} | ||
} | ||
|
||
// resolve | ||
return _aliasList[lang]; | ||
} | ||
|
||
// lookup alias | ||
export function getLanguage(lang){ | ||
// transform to lowercase | ||
lang = (lang || '').toLowerCase(); | ||
|
||
// alias used ? | ||
lang = resolveAlias(lang) || lang; | ||
|
||
// language available ? | ||
return (_languages[lang] ? lang : null); | ||
} | ||
|
||
// create new instance | ||
export function getInstance(name1, name2){ | ||
// use given language - including generic fallback | ||
const languageIdentifier = getLanguage(name1) || getLanguage(name2) || 'generic'; | ||
|
||
// create language engine instance | ||
return new _languages[languageIdentifier]; | ||
} |
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
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
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