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

@mini-dev/markdown-mermaid

v0.0.1

Published

minidev-markdown 的 Mermaid 渲染支持包 —— 解析 ```mermaid 块并承载外部预渲染的 SVG

Readme

@mini-dev/markdown-mermaid

@mini-dev/markdown-core 的 Mermaid 渲染支持包 —— 解析 ```mermaid 代码块,把它定向到 md-mermaid 组件段,并承载外部预渲染的 SVG。

小程序无 DOM,mermaid 无法在端内可靠布局,故 SVG 由有 DOM 的环境(构建期 / 服务端)预先渲染。

1. 安装

npm i @mini-dev/markdown-core @mini-dev/markdown-mermaid

小程序侧执行「工具 → 构建 npm」(读 "miniprogram": "dist/cjs")。

2. 用法

const { createMarkdown } = require('@mini-dev/markdown-core');
const { createWeChatAdapter } = require('@mini-dev/markdown-adapter-wechat');
const { createMermaidPlugin } = require('@mini-dev/markdown-mermaid');

const md = createMarkdown();
md.use(createMermaidPlugin({ resolveSvg }));

const adapter = createWeChatAdapter();
adapter.registry.register('md-mermaid', '/components/md-mermaid/index');

resolveSvg(source) 支持两种契约:

  • 同步返回 string —— 非空:SVG 已在手(构建期预渲染、内存缓存),直接进组件 props;空串:视作「无服务」,按 degrade 降级。
  • 返回 Promise<string> —— 由服务端渲染。块 seal 时先出降级占位(默认代码块展示源码),SVG 到位后核心发 update patch 升级为组件段;async 解析为空串则保持降级,async reject 由 StreamOptions.onDeferError 处理(默认保持占位 = 降级)。

3. 无服务降级(degrade

没有 mermaid 服务端时,可让 mermaid 块降级为普通 markdown 块展示源码,无需注册组件、无需服务

md.use(createMermaidPlugin());                  // 默认 degrade: 'code'
// 或显式:
md.use(createMermaidPlugin({ degrade: 'code' }));
  • 'code'(默认)—— mermaid 块渲染成普通 ```mermaid 代码块(pre>code 灰框 + 源码)。
  • 'blockquote' —— 代码块外再套一层 <blockquote> 引用块样式。
  • 'component' —— 兼容旧行为:仍产 md-mermaid 组件段(svg 空,组件自行展示源码),需 adapter.registry.register('md-mermaid', ...)

触发条件(任一即降级):resolveSvg 未提供 / 同步返回空串 / async 解析为空串 / async reject。resolveSvg 同步返回非空或 async resolve 非空 svg 则升级为组件段(diagram)。

服务端渲染参考实现见仓库 sample-server/(mermaid + jsdom),组件实现见 sample-wechat/miniprogram/components/md-mermaid/

4. 文档

5. License

MIT