🔧 patch (dev/lib/factory-name.js)
This commit is contained in:
parent
948ad8fbd8
commit
65ea3f3124
1 changed files with 24 additions and 28 deletions
|
@ -2,8 +2,8 @@
|
||||||
* @import {Code, Effects, State, TokenizeContext, TokenType} from 'micromark-util-types'
|
* @import {Code, Effects, State, TokenizeContext, TokenType} from 'micromark-util-types'
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {asciiAlpha, asciiAlphanumeric} from 'micromark-util-character'
|
import { asciiAlpha, asciiAlphanumeric } from "micromark-util-character";
|
||||||
import {codes} from 'micromark-util-symbol'
|
import { codes } from "micromark-util-symbol";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @this {TokenizeContext}
|
* @this {TokenizeContext}
|
||||||
|
@ -13,35 +13,31 @@ import {codes} from 'micromark-util-symbol'
|
||||||
* @param {TokenType} type
|
* @param {TokenType} type
|
||||||
*/
|
*/
|
||||||
export function factoryName(effects, ok, nok, type) {
|
export function factoryName(effects, ok, nok, type) {
|
||||||
const self = this
|
const self = this;
|
||||||
|
|
||||||
return start
|
return start;
|
||||||
|
|
||||||
/** @type {State} */
|
/** @type {State} */
|
||||||
function start(code) {
|
function start(code) {
|
||||||
if (asciiAlpha(code)) {
|
if (asciiAlpha(code)) {
|
||||||
effects.enter(type)
|
effects.enter(type);
|
||||||
effects.consume(code)
|
effects.consume(code);
|
||||||
return name
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nok(code)
|
return nok(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {State} */
|
/** @type {State} */
|
||||||
function name(code) {
|
function name(code) {
|
||||||
if (
|
if (code && code !== 10 && code > 0) {
|
||||||
code === codes.dash ||
|
effects.consume(code);
|
||||||
code === codes.underscore ||
|
return name;
|
||||||
asciiAlphanumeric(code)
|
}
|
||||||
) {
|
|
||||||
effects.consume(code)
|
|
||||||
return name
|
|
||||||
}
|
|
||||||
|
|
||||||
effects.exit(type)
|
effects.exit(type);
|
||||||
return self.previous === codes.dash || self.previous === codes.underscore
|
return self.previous === 45 || self.previous === 95 || self.previous === 32
|
||||||
? nok(code)
|
? nok(code)
|
||||||
: ok(code)
|
: ok(code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue