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

@dayinxisheng/check-mermaid

v0.2.0

Published

检查 Markdown 文件中的 Mermaid 代码块语法

Readme

@dayinxisheng/check-mermaid

检查 Markdown 文件中的 Mermaid 代码块语法。

安装

npm install -g @dayinxisheng/check-mermaid

或使用 npx:

npx @dayinxisheng/check-mermaid <dir>

更新

npm update -g @dayinxisheng/check-mermaid

或重新安装:

npm install -g @dayinxisheng/check-mermaid@latest

使用

check-mermaid <dir> [options]

参数

| 参数 | 说明 | |------|------| | <dir> | 要扫描的目录路径 |

选项

| 选项 | 说明 | |------|------| | -v, --version | 显示版本号 | | -o, --output <file> | 输出报告到 Markdown 文件 |

示例

# 检查 docs 目录中的 Markdown 文件
check-mermaid ./docs

# 检查并输出报告到文件
check-mermaid ./docs -o report.md

# 使用 npx
npx @dayinxisheng/check-mermaid ./docs

输出示例

控制台输出

File: docs/example.md
  Lines: 10-15
  Error: Parse error on line 3:
  expecting 'SEMI', got '}'

Markdown 报告

# Mermaid 检查报告

共发现 2 个错误,分布在 1 个文件中。

## docs/example.md

| 行号 | 错误信息 |
|------|----------|
| 10-15 | Parse error on line 3... |

退出码

| 退出码 | 说明 | |--------|------| | 0 | 未发现错误 | | 1 | 发现错误或参数无效 |

API

也可以作为模块使用:

import { scanMarkdownFiles, parseFile, validateBlocks } from '@dayinxisheng/check-mermaid'

// 扫描目录中的 Markdown 文件
const files = scanMarkdownFiles('./docs')

// 解析文件中的 mermaid 代码块
const blocks = parseFile('./docs/example.md')

// 验证代码块
const errors = await validateBlocks(blocks)

浏览器渲染验证(高级)

除了基于 jsdom 的语法检查,还提供基于真实浏览器渲染的验证,能捕获渲染阶段的错误(如 subgraph 与节点同名导致的 cycle 错误):

import { browserValidateBlock, browserValidateBlocks, closeBrowser } from '@dayinxisheng/check-mermaid'

// 验证单个代码块(使用系统 Chrome 渲染)
const error = await browserValidateBlock(block)

// 批量验证
const errors = await browserValidateBlocks(blocks)

// 使用完毕后关闭浏览器
await closeBrowser()

需要系统已安装 Chrome 浏览器,并安装 playwright-core 依赖。

License

MIT