Skip to content

Commit

Permalink
Fix: Ignore anything after space in code fence's language (fixes #98) (
Browse files Browse the repository at this point in the history
  • Loading branch information
tolmasky authored and btmills committed Oct 18, 2018
1 parent 6fd340d commit a5d0cce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function preprocess(text) {
var comments = [];
var index, previousNode, comment;

if (node.lang && SUPPORTED_SYNTAXES.indexOf(node.lang.toLowerCase()) >= 0) {
if (node.lang && SUPPORTED_SYNTAXES.indexOf(node.lang.split(" ")[0].toLowerCase()) >= 0) {
index = parent.children.indexOf(node) - 1;
previousNode = parent.children[index];
while (previousNode && previousNode.type === "html") {
Expand Down
11 changes: 11 additions & 0 deletions tests/lib/processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,17 @@ describe("processor", function() {
assert.equal(blocks.length, 1);
});

it("should ignore anything after the first word of the info string", function() {
var code = [
"```js more words are ignored",
"var answer = 6 * 7;",
"```"
].join("\n");
var blocks = processor.preprocess(code);

assert.equal(blocks.length, 1);
});

it("should find code fences not surrounded by blank lines", function() {
var code = [
"<!-- eslint-disable -->",
Expand Down

0 comments on commit a5d0cce

Please sign in to comment.