Skip to content

Commit 654b527

Browse files
RunDevelopmentmAAdhaTTah
authored andcommitted
Display language aliases (#1626)
Change the index and download page of the Prism website. The index page will now display the aliases (for `language-xxxx`) of languages and the download page will display all alias title of a language next to it.
1 parent 1b75da9 commit 654b527

File tree

2 files changed

+41
-10
lines changed

2 files changed

+41
-10
lines changed

download.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ for (var category in components) {
138138

139139
var info = all[id] = {
140140
title: all[id].title || all[id],
141+
aliasTitles: all[id].aliasTitles,
141142
noCSS: all[id].noCSS || all.meta.noCSS,
142143
noJS: all[id].noJS || all.meta.noJS,
143144
enabled: checked,
@@ -176,6 +177,17 @@ for (var category in components) {
176177
info.files.dev.paths.push(cssFile);
177178
}
178179

180+
function getLanguageTitle(lang) {
181+
if (!lang.aliasTitles)
182+
return lang.title;
183+
184+
var titles = [lang.title];
185+
for (var alias in lang.aliasTitles)
186+
if (lang.aliasTitles.hasOwnProperty(alias))
187+
titles.push(lang.aliasTitles[alias]);
188+
return titles.join(" + ");
189+
}
190+
179191
var label = $u.element.create('label', {
180192
attributes: {
181193
'data-id': id
@@ -230,7 +242,7 @@ for (var category in components) {
230242
properties: {
231243
className: 'name'
232244
},
233-
contents: info.title
245+
contents: getLanguageTitle(info)
234246
},
235247
' ',
236248
all[id].owner? {

index.html

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -273,21 +273,40 @@ <h1>Credits</h1>
273273
continue;
274274
}
275275
count++;
276-
var name = languages[id].title || languages[id];
276+
277+
var lang = languages[id];
278+
var name = lang.title || lang;
279+
280+
var contents = [
281+
name,
282+
' - ',
283+
{
284+
tag: 'code',
285+
contents: id
286+
}
287+
];
288+
289+
var alias = lang.alias;
290+
if (typeof alias === 'string')
291+
alias = [alias];
292+
293+
if (alias) {
294+
for (var i = 0, l = alias.length; i < l; i++) {
295+
contents.push(
296+
', ',
297+
{
298+
tag: 'code',
299+
contents: alias[i]
300+
});
301+
}
302+
}
277303

278304
languageItems.push({
279305
tag: 'li',
280306
attributes: {
281307
'data-id': id
282308
},
283-
contents: [
284-
name,
285-
' - ',
286-
{
287-
tag: 'code',
288-
contents: id
289-
}
290-
]
309+
contents: contents
291310
});
292311
}
293312
$u.element.create('ul', {

0 commit comments

Comments
 (0)