mirror of
https://github.com/Sevichecc/Urara-Blog.git
synced 2025-05-03 05:19:30 +08:00
39 lines
955 B
Text
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)
|
|
}
|
|
}
|