Skip to content
This repository was archived by the owner on Mar 16, 2023. It is now read-only.

Commit c36e838

Browse files
committed
Merge pull request #34 from JohnDittmar/manual-code-highl
Language override for highlighting codeblocks.
2 parents fadc84a + 52687bc commit c36e838

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

assets/js/app.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,20 @@ marked.setOptions(
105105
sanitize: false,
106106
smartLists: true,
107107
smartypants: true,
108-
highlight: function(code) //use highlight.js for syntax highlighting.
109-
{
110-
return highlight.highlightAuto(code).value;
111-
}
108+
highlight: function(code, lang) //use highlight.js for syntax highlighting.
109+
{
110+
if (!lang) return highlight.highlightAuto(code).value;
111+
112+
try
113+
{
114+
content = highlight.highlight(lang, code).value;
115+
}
116+
catch (err)
117+
{
118+
content = highlight.highlightAuto(code).value;
119+
}
120+
return content;
121+
}
112122
});
113123

114124
$(document).on("click", "list-item", function()

0 commit comments

Comments
 (0)