From 65ea3f3124ed99751ca270fb3545659f71ba19e6 Mon Sep 17 00:00:00 2001 From: HidemaruOwO Date: Mon, 26 Aug 2024 13:29:56 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20patch=20(dev/lib/factory-name.js?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dev/lib/factory-name.js | 52 +++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/dev/lib/factory-name.js b/dev/lib/factory-name.js index 97acae1..0137e9c 100644 --- a/dev/lib/factory-name.js +++ b/dev/lib/factory-name.js @@ -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 - } + /** @type {State} */ + function start(code) { + if (asciiAlpha(code)) { + 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 - } + /** @type {State} */ + function name(code) { + if (code && code !== 10 && code > 0) { + effects.consume(code); + return name; + } - effects.exit(type) - return self.previous === codes.dash || self.previous === codes.underscore - ? nok(code) - : ok(code) - } + effects.exit(type); + return self.previous === 45 || self.previous === 95 || self.previous === 32 + ? nok(code) + : ok(code); + } }