You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're using a stripped-down version of the highlight.js library that doesn't include the needed code to do C syntax highlighting, and the right library isn't being dynamically loaded.
Notice that there is no c.min.js file in static/js/highlightjs/, so a WriteFreely post like this attempts to load it, but fails.
Solution
Instead of loading c.min.js when we encounter a code block labeled as c, we should load cpp.min.js. It lists c as an alias (among others, which we should probably do the same for):
For the https://qua.name instance I have local quick patch in place just for this:
diff --git a/templates/include/post-render.tmpl b/templates/include/post-render.tmpl
index b0e8582..6b5f6a7 100644
--- a/templates/include/post-render.tmpl+++ b/templates/include/post-render.tmpl@@ -9,10 +9,20 @@
// Set langs to the langs that are included by default (for now: 'common set' on CDN)
var langs = [];
+ // Custom aliasmap+ var aliasmap = {+ 'elisp' :'lisp','emacs-lisp': 'lisp',+ 'sh' : 'bash'};+
// Given a set of nodes, run highlighting on them
function highlight(nodes) {
for (i=0; i < nodes.length; i++) {
- hljs.highlightBlock(nodes[i]);+ lang = nodes[i].className.replace('language-','');+ if (aliasmap[lang]) {+ lo = hljs.getLanguage(aliasmap[lang]);+ hljs.registerLanguage(lang, function() {return lo;});+ }+ hljs.highlightBlock(nodes[i]);
}
}
@@ -46,12 +56,16 @@
// Check what we need to load
for (i=0; i < lb.length; i++) {
lang = lb[i].className.replace('language-','');
++ // Support a couple specific aliases+ if(aliasmap[lang]) lang = aliasmap[lang];+
lurl = hlbaseUri + "highlightjs/" + lang + ".min.js";
if (!(langs.includes(lang) || jss.includes(lurl))) {
jss.push(lurl);
}
}
Describe the bug
We're using a stripped-down version of the highlight.js library that doesn't include the needed code to do C syntax highlighting, and the right library isn't being dynamically loaded.
Notice that there is no
c.min.js
file instatic/js/highlightjs/
, so a WriteFreely post like this attempts to load it, but fails.Solution
Instead of loading
c.min.js
when we encounter a code block labeled asc
, we should loadcpp.min.js
. It listsc
as an alias (among others, which we should probably do the same for):(from cpp.js)
Application configuration
Version or last commit: v0.9.1
The text was updated successfully, but these errors were encountered: