Skip to content

Commit

Permalink
fix: prism not working when not specified language or language's name…
Browse files Browse the repository at this point in the history
… error
  • Loading branch information
ipluser committed May 6, 2016
1 parent 85db416 commit 77b555b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "magicbook",
"version": "0.7.0",
"version": "0.7.1",
"description": "An lightweight and scalable docs system for markdown, text or other.",
"homepage": "http://ipluser.github.io/magicbook/",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<script>
var book = Magicbook.markdown('awesome', {
homeUrl: 'public/doc/quick-start.md',
urlArgs: 'ver=0.7.0'
urlArgs: 'ver=0.7.1'
});

book.agilities();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "magicbookjs",
"version": "0.7.0",
"version": "0.7.1",
"description": "An lightweight and scalable docs system for markdown, text or other.",
"author": "ipluser",
"main": "dist/magicbook.js",
Expand Down
19 changes: 12 additions & 7 deletions plugins/markdown/js/awesome.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
marked.setOptions({
langPrefix: 'language-',
highlight: function highlight(code, lang) {
return Prism.highlight(code, Prism.languages[lang]);
return Prism.highlight(code, Prism.languages[normalizeLang(lang)]);
}
});

Expand All @@ -18,20 +18,25 @@
return new Magicbook(cfg);
});

function normalizeLang(lang) {
if (!lang || !Prism.languages[lang]) {
return 'bash';
}

return lang;
}

function routeCallbackSuccessForPrismStyle() {
var $codes = $('pre > code');
var index;
var len;

for (index = 0, len = $codes.length; index < len; index++) {
var $code = $($codes[index]);
var codeClass = $code.attr('class');

if (!codeClass) {
return;
}
var codeClass = $code.attr('class') || 'language-bash';

$code.parent().addClass(codeClass);
Magicbook.addClassName($code, codeClass);
Magicbook.addClassName($code.parent(), codeClass);
}
}
})(window, jQuery, marked, Prism, Magicbook); // eslint-disable-line
2 changes: 1 addition & 1 deletion plugins/markdown/js/awesome.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 77b555b

Please sign in to comment.