Fix #124 according to the snippet by @mrvdb
I changed the sh alias to shell instead of bash. The additions to the `highlight(nodes)` function look redundant. It works for me without them but maybe they cover an edge case I cannot think about?
This commit is contained in:
parent
86a128483b
commit
c2d7c2c8b7
1 changed files with 19 additions and 1 deletions
|
@ -9,6 +9,22 @@
|
||||||
// Set langs to the langs that are included by default (for now: 'common set' on CDN)
|
// Set langs to the langs that are included by default (for now: 'common set' on CDN)
|
||||||
var langs = [];
|
var langs = [];
|
||||||
|
|
||||||
|
// Custom aliasmap
|
||||||
|
var aliasmap = {
|
||||||
|
"elisp" : "lisp",
|
||||||
|
"emacs-lisp" : "lisp",
|
||||||
|
"c" : "cpp",
|
||||||
|
"cc" : "cpp",
|
||||||
|
"h" : "cpp",
|
||||||
|
"c++" : "cpp",
|
||||||
|
"h++" : "cpp",
|
||||||
|
"hpp" : "cpp",
|
||||||
|
"hh" : "cpp",
|
||||||
|
"hxx" : "cpp",
|
||||||
|
"cxx" : "cpp",
|
||||||
|
"sh" : "shell"
|
||||||
|
};
|
||||||
|
|
||||||
// Given a set of nodes, run highlighting on them
|
// Given a set of nodes, run highlighting on them
|
||||||
function highlight(nodes) {
|
function highlight(nodes) {
|
||||||
for (i=0; i < nodes.length; i++) {
|
for (i=0; i < nodes.length; i++) {
|
||||||
|
@ -46,6 +62,8 @@
|
||||||
// Check what we need to load
|
// Check what we need to load
|
||||||
for (i=0; i < lb.length; i++) {
|
for (i=0; i < lb.length; i++) {
|
||||||
lang = lb[i].className.replace('language-','');
|
lang = lb[i].className.replace('language-','');
|
||||||
|
// Support the aliases specified above
|
||||||
|
if (aliasmap[lang]) lang = aliasmap[lang];
|
||||||
lurl = hlbaseUri + "highlightjs/" + lang + ".min.js";
|
lurl = hlbaseUri + "highlightjs/" + lang + ".min.js";
|
||||||
if (!(langs.includes(lang) || jss.includes(lurl))) {
|
if (!(langs.includes(lang) || jss.includes(lurl))) {
|
||||||
jss.push(lurl);
|
jss.push(lurl);
|
||||||
|
|
Loading…
Add table
Reference in a new issue