Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gulp: Fixed language map #2283

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.