Urara-Blog/node_modules/.pnpm-store/v3/files/c6/9f52216b3e543a3ab855b383dfdf0a5edd68f30d6f54ca4aee62eb549443d64b8957623c8a2197f19b039651dfb5a6a2d122b1e4e837029c4fd10a297228ca
2022-08-14 01:14:53 +08:00

39 lines
955 B
Text

/**
* @typedef {import('micromark-util-types').Construct} Construct
* @typedef {import('micromark-util-types').Tokenizer} Tokenizer
* @typedef {import('micromark-util-types').State} State
*/
import {asciiPunctuation} from 'micromark-util-character'
/** @type {Construct} */
export const characterEscape = {
name: 'characterEscape',
tokenize: tokenizeCharacterEscape
}
/** @type {Tokenizer} */
function tokenizeCharacterEscape(effects, ok, nok) {
return start
/** @type {State} */
function start(code) {
effects.enter('characterEscape')
effects.enter('escapeMarker')
effects.consume(code)
effects.exit('escapeMarker')
return open
}
/** @type {State} */
function open(code) {
if (asciiPunctuation(code)) {
effects.enter('characterEscapeValue')
effects.consume(code)
effects.exit('characterEscapeValue')
effects.exit('characterEscape')
return ok
}
return nok(code)
}
}