Skip to content

Commit

Permalink
refactor(micromark-extension-kbd-nested): separate variable marker le…
Browse files Browse the repository at this point in the history
…ngth
  • Loading branch information
shivjm committed Dec 6, 2021
1 parent 544fc06 commit df06fe2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/micromark-extension-kbd-nested/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export interface IOptions {
}

const MINIMUM_MARKER_LENGTH = 2;
const VARIABLE_MARKER_LENGTH = 2;

const KEYBOARD_TYPE = "keyboardSequence";
const KEYBOARD_TEXT_TYPE = types.codeTextData; // TODO check whether this is okay
Expand Down Expand Up @@ -335,7 +336,7 @@ function makeVariableTokenizer(delimiter: number): Tokenizer {
size++;
effects.consume(delimiter);

if (size === MINIMUM_MARKER_LENGTH) {
if (size === VARIABLE_MARKER_LENGTH) {
effects.exit(KEYBOARD_VARIABLE_MARKER_TYPE);
return gap;
}
Expand Down Expand Up @@ -400,7 +401,7 @@ function makeVariableClosingTokenizer(delimiter: number): Tokenizer {
if (code === delimiter) {
effects.consume(code);
size++;
if (size === MINIMUM_MARKER_LENGTH) {
if (size === VARIABLE_MARKER_LENGTH) {
effects.exit(KEYBOARD_VARIABLE_MARKER_TYPE);
effects.exit(KEYBOARD_VARIABLE_TYPE);

Expand Down

0 comments on commit df06fe2

Please sign in to comment.