🔧 patch (dev/lib/factory-name.js)

This commit is contained in:
ひでまる 2024-08-26 13:29:56 +09:00
parent 948ad8fbd8
commit 65ea3f3124

View file

@ -2,8 +2,8 @@
* @import {Code, Effects, State, TokenizeContext, TokenType} from 'micromark-util-types'
*/
import {asciiAlpha, asciiAlphanumeric} from 'micromark-util-character'
import {codes} from 'micromark-util-symbol'
import { asciiAlpha, asciiAlphanumeric } from "micromark-util-character";
import { codes } from "micromark-util-symbol";
/**
* @this {TokenizeContext}
@ -13,35 +13,31 @@ import {codes} from 'micromark-util-symbol'
* @param {TokenType} type
*/
export function factoryName(effects, ok, nok, type) {
const self = this
const self = this;
return start
return start;
/** @type {State} */
function start(code) {
if (asciiAlpha(code)) {
effects.enter(type)
effects.consume(code)
return name
effects.enter(type);
effects.consume(code);
return name;
}
return nok(code)
return nok(code);
}
/** @type {State} */
function name(code) {
if (
code === codes.dash ||
code === codes.underscore ||
asciiAlphanumeric(code)
) {
effects.consume(code)
return name
if (code && code !== 10 && code > 0) {
effects.consume(code);
return name;
}
effects.exit(type)
return self.previous === codes.dash || self.previous === codes.underscore
effects.exit(type);
return self.previous === 45 || self.previous === 95 || self.previous === 32
? nok(code)
: ok(code)
: ok(code);
}
}