1 Star 0 Fork 0

bear / markdown-it

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
parser_core.mjs 1.47 KB
一键复制 编辑 原始数据 按行查看 历史
Vitaly Puzrin 提交于 2023-12-02 04:13 . lint: reduce empty lines
/** internal
* class Core
*
* Top-level rules executor. Glues block/inline parsers and does intermediate
* transformations.
**/
import Ruler from './ruler.mjs'
import StateCore from './rules_core/state_core.mjs'
import r_normalize from './rules_core/normalize.mjs'
import r_block from './rules_core/block.mjs'
import r_inline from './rules_core/inline.mjs'
import r_linkify from './rules_core/linkify.mjs'
import r_replacements from './rules_core/replacements.mjs'
import r_smartquotes from './rules_core/smartquotes.mjs'
import r_text_join from './rules_core/text_join.mjs'
const _rules = [
['normalize', r_normalize],
['block', r_block],
['inline', r_inline],
['linkify', r_linkify],
['replacements', r_replacements],
['smartquotes', r_smartquotes],
// `text_join` finds `text_special` tokens (for escape sequences)
// and joins them with the rest of the text
['text_join', r_text_join]
]
/**
* new Core()
**/
function Core () {
/**
* Core#ruler -> Ruler
*
* [[Ruler]] instance. Keep configuration of core rules.
**/
this.ruler = new Ruler()
for (let i = 0; i < _rules.length; i++) {
this.ruler.push(_rules[i][0], _rules[i][1])
}
}
/**
* Core.process(state)
*
* Executes core chain rules.
**/
Core.prototype.process = function (state) {
const rules = this.ruler.getRules('')
for (let i = 0, l = rules.length; i < l; i++) {
rules[i](state)
}
}
Core.prototype.State = StateCore
export default Core
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/bear-vic/markdown-it.git
git@gitee.com:bear-vic/markdown-it.git
bear-vic
markdown-it
markdown-it
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891