Skip to content

Commit 0cdae30

Browse files
committed
Fix: Ignore anything after space in code fence's language (fixes #98)
1 parent dff8e9c commit 0cdae30

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

lib/processor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function preprocess(text) {
8080
var comments = [];
8181
var index, previousNode, comment;
8282

83-
if (node.lang && SUPPORTED_SYNTAXES.indexOf(node.lang.toLowerCase()) >= 0) {
83+
if (node.lang && SUPPORTED_SYNTAXES.indexOf(node.lang.split(" ")[0].toLowerCase()) >= 0) {
8484
index = parent.children.indexOf(node) - 1;
8585
previousNode = parent.children[index];
8686
while (previousNode && previousNode.type === "html") {

tests/lib/processor.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,17 @@ describe("processor", function() {
257257
assert.equal(blocks.length, 1);
258258
});
259259

260+
it("should ignore anything after the first word of the info string", function() {
261+
var code = [
262+
"```js more words are ignored",
263+
"var answer = 6 * 7;",
264+
"```"
265+
].join("\n");
266+
var blocks = processor.preprocess(code);
267+
268+
assert.equal(blocks.length, 1);
269+
});
270+
260271
it("should find code fences not surrounded by blank lines", function() {
261272
var code = [
262273
"<!-- eslint-disable -->",

0 commit comments

Comments
 (0)