npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

bt-md-parser

v1.0.1

Published

测试用的npm包,用于解析markdown文件

Readme

md-parser

基于 markdown-it 的 Markdown 解析器

目录结构

  • src/
    • common/:工具函数和 HTML 标识
    • fsm/:状态机,分为 coreblockinline
    • rules/:解析规则,指定 Markdown 转 HTML 的规则
    • imd:创建解析器实例
    • parser_**:三个级别的解析器
    • ruler:规则管理器,内部利用缓存机制提高性能
    • token:规定 token 格式
    • index:入口,对接编辑器接口

解析过程

根据解析选项创建规则管理器 ruler,启用或禁用规则,形成规则链。然后调用 core.process 方法,构建状态机,运用规则链解析文本,生成 tokens。最后调用 renderer.render 方法,将 tokens 渲染成 HTML 字符串。

每个规则函数的处理对象是状态机,具体来说是每个 parser 对应的 fsm/state。这样可以保证 token 和解析器实例以及一些外部注入的变量跟随状态机连续传递。

可关注的任务

  1. 目前只实现了 feature 中的几个功能。增量解析、丰富语法(如数学和嵌套表格等,可通过添加规则来实现)等加分项尚未实现。
  2. 行内规则处理逻辑不完善,inline 元素暂时没有效果,块级元素中列表的逻辑有点问题
  3. 性能优化尚未实现。
  4. 部分代码可能不够规范,目前尚未接入 eslint 和 prettier(我自己的机器上用了 prettier 插件)。
  5. 测试用例尚缺少。

使用方式

npm i

npm run build

npm start

编辑器接口处可看 useParser,对接口进行了一定程度的修改(目前集中在 feature)。