Urara-Blog/node_modules/.pnpm-store/v3/files/b1/ca7eb8c6686b9365e19c4a0a39103253344c305cea01ac03afd45991d8ceaeb3c3d380a2b7fc76f803856d4ec4b55525b4d14967f11a6c5cf07e02585c774e
2022-08-14 01:14:53 +08:00

75 lines
1.8 KiB
Text

/**
* @typedef {import('micromark-util-types').Construct} Construct
* @typedef {import('micromark-util-types').Tokenizer} Tokenizer
* @typedef {import('micromark-util-types').Exiter} Exiter
* @typedef {import('micromark-util-types').State} State
*/
import {factorySpace} from 'micromark-factory-space'
import {markdownSpace} from 'micromark-util-character'
/** @type {Construct} */
export const blockQuote = {
name: 'blockQuote',
tokenize: tokenizeBlockQuoteStart,
continuation: {
tokenize: tokenizeBlockQuoteContinuation
},
exit
}
/** @type {Tokenizer} */
function tokenizeBlockQuoteStart(effects, ok, nok) {
const self = this
return start
/** @type {State} */
function start(code) {
if (code === 62) {
const state = self.containerState
if (!state.open) {
effects.enter('blockQuote', {
_container: true
})
state.open = true
}
effects.enter('blockQuotePrefix')
effects.enter('blockQuoteMarker')
effects.consume(code)
effects.exit('blockQuoteMarker')
return after
}
return nok(code)
}
/** @type {State} */
function after(code) {
if (markdownSpace(code)) {
effects.enter('blockQuotePrefixWhitespace')
effects.consume(code)
effects.exit('blockQuotePrefixWhitespace')
effects.exit('blockQuotePrefix')
return ok
}
effects.exit('blockQuotePrefix')
return ok(code)
}
}
/** @type {Tokenizer} */
function tokenizeBlockQuoteContinuation(effects, ok, nok) {
return factorySpace(
effects,
effects.attempt(blockQuote, ok, nok),
'linePrefix',
this.parser.constructs.disable.null.includes('codeIndented') ? undefined : 4
)
}
/** @type {Exiter} */
function exit(effects) {
effects.exit('blockQuote')
}