micromark
Version:
small commonmark compliant markdown parser with positional info and concrete tokens
102 lines (91 loc) • 2.58 kB
JavaScript
/**
* @import {Extension} from 'micromark-util-types'
*/
import {
attention,
autolink,
blockQuote,
characterEscape,
characterReference,
codeFenced,
codeIndented,
codeText,
definition,
hardBreakEscape,
headingAtx,
htmlFlow,
htmlText,
labelEnd,
labelStartImage,
labelStartLink,
lineEnding,
list,
setextUnderline,
thematicBreak
} from 'micromark-core-commonmark'
import {codes} from 'micromark-util-symbol'
import {resolver as resolveText} from './initialize/text.js'
/** @satisfies {Extension['document']} */
export const document = {
[ ]: list,
[ ]: list,
[ ]: list,
[ ]: list,
[ ]: list,
[ ]: list,
[ ]: list,
[ ]: list,
[ ]: list,
[ ]: list,
[ ]: list,
[ ]: list,
[ ]: list,
[ ]: blockQuote
}
/** @satisfies {Extension['contentInitial']} */
export const contentInitial = {
[ ]: definition
}
/** @satisfies {Extension['flowInitial']} */
export const flowInitial = {
[ ]: codeIndented,
[ ]: codeIndented,
[ ]: codeIndented
}
/** @satisfies {Extension['flow']} */
export const flow = {
[ ]: headingAtx,
[ ]: thematicBreak,
[ ]: [setextUnderline, thematicBreak],
[ ]: htmlFlow,
[ ]: setextUnderline,
[ ]: thematicBreak,
[ ]: codeFenced,
[ ]: codeFenced
}
/** @satisfies {Extension['string']} */
export const string = {
[ ]: characterReference,
[ ]: characterEscape
}
/** @satisfies {Extension['text']} */
export const text = {
[ ]: lineEnding,
[ ]: lineEnding,
[ ]: lineEnding,
[ ]: labelStartImage,
[ ]: characterReference,
[ ]: attention,
[ ]: [autolink, htmlText],
[ ]: labelStartLink,
[ ]: [hardBreakEscape, characterEscape],
[ ]: labelEnd,
[ ]: attention,
[ ]: codeText
}
/** @satisfies {Extension['insideSpan']} */
export const insideSpan = {null: [attention, resolveText]}
/** @satisfies {Extension['attentionMarkers']} */
export const attentionMarkers = {null: [codes.asterisk, codes.underscore]}
/** @satisfies {Extension['disable']} */
export const disable = {null: []}