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 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
diff --git a/download.js b/download.js
index 494b6e3..054da79 100644
--- a/download.js
+++ b/download.js
@@ -138,6 +138,7 @@ for (var category in components) {
var info = all[id] = {
title: all[id].title || all[id],
+ aliasTitles: all[id].aliasTitles,
noCSS: all[id].noCSS || all.meta.noCSS,
noJS: all[id].noJS || all.meta.noJS,
enabled: checked,
@@ -176,6 +177,17 @@ for (var category in components) {
info.files.dev.paths.push(cssFile);
}
+ function getLanguageTitle(lang) {
+ if (!lang.aliasTitles)
+ return lang.title;
+
+ var titles = [lang.title];
+ for (var alias in lang.aliasTitles)
+ if (lang.aliasTitles.hasOwnProperty(alias))
+ titles.push(lang.aliasTitles[alias]);
+ return titles.join(" + ");
+ }
+
var label = $u.element.create('label', {
attributes: {
'data-id': id
@@ -230,7 +242,7 @@ for (var category in components) {
properties: {
className: 'name'
},
- contents: info.title
+ contents: getLanguageTitle(info)
},
' ',
all[id].owner? {
diff --git a/index.html b/index.html
index 2d6b430..50be230 100644
--- a/index.html
+++ b/index.html
@@ -273,21 +273,40 @@ var html = Prism.highlight(code, Prism.languages.haml, 'haml');</code></pre>
continue;
}
count++;
- var name = languages[id].title || languages[id];
+
+ var lang = languages[id];
+ var name = lang.title || lang;
+
+ var contents = [
+ name,
+ ' - ',
+ {
+ tag: 'code',
+ contents: id
+ }
+ ];
+
+ var alias = lang.alias;
+ if (typeof alias === 'string')
+ alias = [alias];
+
+ if (alias) {
+ for (var i = 0, l = alias.length; i < l; i++) {
+ contents.push(
+ ', ',
+ {
+ tag: 'code',
+ contents: alias[i]
+ });
+ }
+ }
languageItems.push({
tag: 'li',
attributes: {
'data-id': id
},
- contents: [
- name,
- ' - ',
- {
- tag: 'code',
- contents: id
- }
- ]
+ contents: contents
});
}
$u.element.create('ul', {