From cf79c02d17abb20540405bce175a003b729d4f19 Mon Sep 17 00:00:00 2001 From: Jordan Scales Date: Thu, 24 Dec 2015 15:47:42 -0500 Subject: [PATCH] Protect against missing languages in code blocks - Fixes #142 --- lib/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 44be77d..ee4c0b4 100644 --- a/lib/index.js +++ b/lib/index.js @@ -62,7 +62,11 @@ function Cleaver(document, options, includePath) { marked.setOptions({ gfm: true, highlight: function (code, lang) { - return (lang) ? hljs.highlight(lang, code).value : code; + try { + return hljs.highlight(lang, code).value; + } catch (e) { + return code; + } } }); }