mirror of
https://github.com/Sevichecc/Urara-Blog.git
synced 2025-05-02 07:09:30 +08:00
43 lines
1.1 KiB
Text
43 lines
1.1 KiB
Text
/**
|
||
* @typedef {import('micromark-util-types').Construct} Construct
|
||
* @typedef {import('micromark-util-types').Tokenizer} Tokenizer
|
||
* @typedef {import('micromark-util-types').State} State
|
||
*/
|
||
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) {
|
||
effects.enter('labelLink')
|
||
effects.enter('labelMarker')
|
||
effects.consume(code)
|
||
effects.exit('labelMarker')
|
||
effects.exit('labelLink')
|
||
return after
|
||
}
|
||
/** @type {State} */
|
||
|
||
function after(code) {
|
||
/* To do: remove in the future once we’ve switched from
|
||
* `micromark-extension-footnote` to `micromark-extension-gfm-footnote`,
|
||
* which doesn’t need this */
|
||
|
||
/* Hidden footnotes hook. */
|
||
|
||
/* c8 ignore next 3 */
|
||
return code === 94 && '_hiddenFootnoteSupport' in self.parser.constructs
|
||
? nok(code)
|
||
: ok(code)
|
||
}
|
||
}
|