🔧 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 {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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue