Skip to content

Commit

Permalink
feat(micromark-extension-kbd-nested)!: turn unclosed sequences into n…
Browse files Browse the repository at this point in the history
…o-ops
  • Loading branch information
shivjm committed Nov 2, 2021
1 parent 9a6a0eb commit be61d7f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/micromark-extension-kbd-nested/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ export const syntax = (options: IOptions = {}): Extension => {
function data(code: Code): void | State {
const t = makeClosingTokenizer(delimiter, size, true, insideText);

if (isEof(code)) {
effects.exit(KEYBOARD_TEXT_TYPE);
effects.enter(KEYBOARD_MARKER_TYPE);
effects.exit(KEYBOARD_MARKER_TYPE);
return nok(code);
}

if (markdownLineEndingOrSpace(code) || code === delimiter) {
return effects.attempt(
{
Expand Down
2 changes: 1 addition & 1 deletion packages/micromark-extension-kbd-nested/tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe("works for simple cases", () => {
["||Ctrl||", "|", "<p><kbd>Ctrl</kbd></p>"],
["|| Ctrl ||", "|", "<p><kbd>Ctrl</kbd></p>"],
["|| npm run build ||", undefined, "<p><kbd>npm run build</kbd></p>"],
["||a|| bc ||d", undefined, "<p><kbd>a</kbd> bc d</p>"], // remove orphans
["||a|| bc ||d", undefined, "<p><kbd>a</kbd> bc ||d</p>"],
]);
});

Expand Down

0 comments on commit be61d7f

Please sign in to comment.