Urara-Blog/node_modules/.pnpm-store/v3/files/77/846ea08b87a461d40fbad8b8e5162837af173ad5d0e0366b786608748c19749b8236914459ce0e9ef421f6de87e5561879d43c220e134c1476d661ac8fb0f7
2022-08-14 01:14:53 +08:00

48 lines
1.3 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @typedef {import('micromark-util-types').Construct} Construct
* @typedef {import('micromark-util-types').Tokenizer} Tokenizer
* @typedef {import('micromark-util-types').State} State
*/
import {ok as assert} from 'uvu/assert'
import {codes} from 'micromark-util-symbol/codes.js'
import {types} from 'micromark-util-symbol/types.js'
import {labelEnd} from './label-end.js'
/** @type {Construct} */
export const labelStartLink = {
name: 'labelStartLink',
tokenize: tokenizeLabelStartLink,
resolveAll: labelEnd.resolveAll
}
/** @type {Tokenizer} */
function tokenizeLabelStartLink(effects, ok, nok) {
const self = this
return start
/** @type {State} */
function start(code) {
assert(code === codes.leftSquareBracket, 'expected `[`')
effects.enter(types.labelLink)
effects.enter(types.labelMarker)
effects.consume(code)
effects.exit(types.labelMarker)
effects.exit(types.labelLink)
return after
}
/** @type {State} */
function after(code) {
/* To do: remove in the future once weve switched from
* `micromark-extension-footnote` to `micromark-extension-gfm-footnote`,
* which doesnt need this */
/* Hidden footnotes hook. */
/* c8 ignore next 3 */
return code === codes.caret &&
'_hiddenFootnoteSupport' in self.parser.constructs
? nok(code)
: ok(code)
}
}