-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* eslint-env mocha */ | ||
|
||
import chai, {expect} from 'chai'; | ||
import chaiString from 'chai-string'; | ||
import markdownit from 'markdown-it'; | ||
import markdownItKbd from './index'; | ||
import fs from 'fs'; | ||
|
||
chai.use(chaiString); | ||
|
||
const read = path => fs.readFileSync(`testdata/${path}`).toString(); | ||
|
||
describe('markdown-it-kbd', () => { | ||
|
||
const md = markdownit() | ||
.use(markdownItKbd); | ||
|
||
it('renders [[x]] as <kbd>x</kbd>', () => { | ||
expect(md.render(read('input/kbd.md'))) | ||
.to.equalIgnoreSpaces(read('expected/kbd.html')); | ||
}); | ||
|
||
it('does not harm link rendering', () => { | ||
expect(md.render(read('input/kbdwithlink.md'))) | ||
.to.equalIgnoreSpaces(read('expected/kbdwithlink.html')); | ||
}); | ||
|
||
it('ignores [[ and ]] if not forming a keystroke.', () => { | ||
expect(md.render(read('input/dangling.md'))) | ||
.to.equalIgnoreSpaces(read('expected/dangling.html')); | ||
}); | ||
|
||
it('allows markup within [[ and ]]', () => { | ||
expect(md.render(read('input/markupwithin.md'))) | ||
.to.equalIgnoreSpaces(read('expected/markupwithin.html')); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<h1>Test</h1> | ||
|
||
<p> | ||
Here are some combinations to confuse the parser: | ||
<kbd>foo</kbd> [[ | ||
<kbd>bar</kbd> ]] hey | ||
<kbd>this</kbd> [[ <kbd>and that</kbd> | ||
<kbd>that</kbd> ]] <kbd>and this</kbd> | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1>Test</h1> | ||
|
||
<p> | ||
This combination is cool: <kbd>alt</kbd>+<kbd>f4</kbd>. | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1>Test</h1> | ||
|
||
<p> | ||
This combination is cool: <kbd>alt</kbd>+<kbd>f4</kbd>. This link still works: <a href="http://google.com">Google</a>. | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1>Test</h1> | ||
|
||
<p> | ||
We can do markup within tags: <kbd><em>i</em></kbd> <kbd><code>foo</code></kbd>. | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Test | ||
|
||
Here are some combinations to confuse the parser: | ||
[[foo]] [[ | ||
[[bar]] ]] hey | ||
[[this]] [[ [[and that]] | ||
[[that]] ]] [[and this]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Test | ||
|
||
This combination is cool: [[alt]]+[[f4]]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Test | ||
|
||
This combination is cool: [[alt]]+[[f4]]. This link still works: [Google](http://google.com). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Test | ||
|
||
We can do markup within tags: [[*i*]] [[`foo`]]. |