Urara-Blog/node_modules/.pnpm-store/v3/files/f2/84b76e0d471fa713ee4f101b339d562b522bf752020356e17d708ad251c6647309ccfd41ee0fcd540ab94f983b7f36a1997fa17a47def0ba2de3c6207749d8
2022-08-14 01:14:53 +08:00

60 lines
1.6 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 labelStartImage = {
name: 'labelStartImage',
tokenize: tokenizeLabelStartImage,
resolveAll: labelEnd.resolveAll
}
/** @type {Tokenizer} */
function tokenizeLabelStartImage(effects, ok, nok) {
const self = this
return start
/** @type {State} */
function start(code) {
assert(code === codes.exclamationMark, 'expected `!`')
effects.enter(types.labelImage)
effects.enter(types.labelImageMarker)
effects.consume(code)
effects.exit(types.labelImageMarker)
return open
}
/** @type {State} */
function open(code) {
if (code === codes.leftSquareBracket) {
effects.enter(types.labelMarker)
effects.consume(code)
effects.exit(types.labelMarker)
effects.exit(types.labelImage)
return after
}
return nok(code)
}
/** @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)
}
}