Skip to content

Commit

Permalink
test parent mode closes propertly
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgoebel committed Apr 4, 2021
1 parent 287421d commit 657521a
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions test/api/multiClassMatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ describe('multi-class matchers', () => {
}
]
},
{
className: "carrot",
begin: /\^\^\^/,
end: /\^\^\^/,
contains: [
{
begin: ["a", "b", "c"],
className: {
1: "a",
3: "c"
}
}
]
},
{
match: [
/func/,
Expand All @@ -33,8 +47,8 @@ describe('multi-class matchers', () => {
}
}
]
}
}
};
};
hljs.registerLanguage("test", grammar);
});
after(() => {
Expand All @@ -44,14 +58,23 @@ describe('multi-class matchers', () => {
const code = "abcdef";
const result = hljs.highlight(code, { language: 'test' });

result.relevance.should.equal(2);
result.value.should.equal(`<span class="hljs-a">a</span>b<span class="hljs-c">c</span><span class="hljs-def">def</span>`);
})
result.relevance.should.equal(2);
});
it('basic functionality', () => {
const code = "func(){ test }";
const result = hljs.highlight(code, { language: 'test' });

result.relevance.should.equal(1);
result.value.should.equal(`<span class="hljs-keyword">func</span><span class="hljs-params">()</span><span class="hljs-body">{ test }</span>`);
result.relevance.should.equal(1);
});
it('works inside a classified parent mode', () => {
const code = "^^^what abc now^^^";
const result = hljs.highlight(code, { language: 'test' });

result.value.should.equal(
`<span class="hljs-carrot">^^^what ` +
`<span class="hljs-a">a</span>b<span class="hljs-c">c</span>` +
` now^^^</span>`);
})
});

0 comments on commit 657521a

Please sign in to comment.