Skip to content

Commit

Permalink
gulp: Fixed language map (#2283)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed Apr 5, 2020
1 parent 0cfb6c5 commit 1105319
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
20 changes: 17 additions & 3 deletions gulpfile.js/index.js
Expand Up @@ -88,6 +88,7 @@ function watchComponentsAndPlugins() {

async function languagePlugins() {
const data = await componentsPromise;
/** @type {Record<string, string | null>} */
const languagesMap = {};
const dependenciesMap = {};
const aliasMap = {};
Expand All @@ -112,8 +113,12 @@ async function languagePlugins() {
* @param {string} title
*/
function addLanguageTitle(key, title) {
if (!languagesMap[key] && guessTitle(key) !== title) {
languagesMap[key] = title;
if (!(key in languagesMap)) {
if (guessTitle(key) === title) {
languagesMap[key] = null;
} else {
languagesMap[key] = title;
}
}
}

Expand Down Expand Up @@ -150,7 +155,16 @@ async function languagePlugins() {
return JSON.stringify(json, null, '\t').replace(/\n/g, '\n\t');
}

const jsonLanguagesMap = formattedStringify(languagesMap);
/** @type {Record<string, string>} */
const nonNullLanguageMap = {};
for (const id in languagesMap) {
const title = languagesMap[id];
if (title) {
nonNullLanguageMap[id] = title;
}
}

const jsonLanguagesMap = formattedStringify(nonNullLanguageMap);
const jsonDependenciesMap = formattedStringify(dependenciesMap);
const jsonAliasMap = formattedStringify(aliasMap);

Expand Down
3 changes: 0 additions & 3 deletions plugins/show-language/prism-show-language.js
Expand Up @@ -33,10 +33,8 @@
"aspnet": "ASP.NET (C#)",
"autohotkey": "AutoHotkey",
"autoit": "AutoIt",
"shell": "Bash",
"basic": "BASIC",
"bbcode": "BBcode",
"shortcode": "BBcode",
"bnf": "Backus–Naur form",
"rbnf": "Routing Backus–Naur form",
"conc": "Concurnas",
Expand All @@ -57,7 +55,6 @@
"dockerfile": "Docker",
"ebnf": "Extended Backus–Naur form",
"ejs": "EJS",
"eta": "EJS",
"etlua": "Embedded Lua templating",
"erb": "ERB",
"excel-formula": "Excel Formula",
Expand Down
2 changes: 1 addition & 1 deletion plugins/show-language/prism-show-language.min.js

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

0 comments on commit 1105319

Please sign in to comment.