Skip to content

Commit 0a85455

Browse files
committed
Merge pull request #4 from GitbookIO/fix/unrecognized-languages
Fix/unrecognized languages
2 parents a6261ad + fb819b4 commit 0a85455

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ function highlight(lang, code) {
2929
return hljs.highlight(lang, code).value;
3030
} catch(e) { }
3131

32-
return code;
32+
return {
33+
body: code,
34+
html: false
35+
};
3336
}
3437

3538

test/highlight.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,19 @@ describe("Detect breaking changes in highlight.js", function() {
2121
.then(done)
2222
.done();
2323
});
24+
25+
it('should return a safe code block for unrecognized languages', function (done) {
26+
tester.builder()
27+
.withContent('```foo\nif (foo <= bar) { console.log(\'Too bad, foo...\'); }\n```')
28+
.withLocalPlugin(pluginDir)
29+
.create()
30+
.then(function(result) {
31+
var expected = '<pre><code class="lang-foo">if (foo &lt;= bar) { console.log(&apos;Too bad, foo...&apos;); }\n</code></pre>';
32+
if (result.get('index.html').content !== expected) {
33+
throw new Error('Found ' + result[0].content + ' instead of ' + expected);
34+
}
35+
})
36+
.then(done)
37+
.done();
38+
});
2439
});

0 commit comments

Comments
 (0)