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

@pactor-app/markdown

v1.20.0

Published

Pactor Markdown module: safe Markdown renderer (react-markdown AST, no raw HTML) and DSL Markdown component adapter

Readme

@pactor-app/markdown

Pactor 的 Markdown 模块:安全的 Markdown 渲染器(MarkdownRenderer)与 DSL Markdown 组件适配(type: Markdown)。Chat 消息与 Page/Overlay DSL 共用同一渲染器。

安装

npm install @pactor-app/markdown react
# 或
pnpm add @pactor-app/markdown react

react >= 18 为 peer dependency。开发基准:react-markdown v10(^10.1.0)+ remark-gfm v4(^4.0.1)。

安全边界

  • 不启用 raw HTML:基于 react-markdown 的 AST 渲染,Markdown 文本中的原始 HTML(<script>、事件属性、任意标签)不会渲染为元素。切勿引入 rehype-raw——该约定由测试锁定(script / onerror 注入场景)。
  • 协议白名单:链接 href 仅允许 http: / https: / mailto: 与相对路径;图片 src 仅允许 http: / https: 与相对路径。javascript: 等危险协议的链接渲染为纯文本,图片不渲染。
  • 外链安全属性:http(s) 链接自动带 target="_blank" rel="noreferrer"

独立使用

import { MarkdownRenderer } from '@pactor-app/markdown';

<MarkdownRenderer content={'### 标题\n\n- 列表项\n\n| 表 | 格 |\n| - | - |\n| 1 | 2 |'} />;

支持:标题 / 段落 / 粗体 / 斜体 / 有序与无序列表 / GFM 表格与删除线 / 围栏代码块(<pre><code class="language-xxx">,供后续语法高亮扩展)与行内代码 / 引用 / 链接 / 图片。容器带基础 class @pactor-app/markdown,样式由宿主主题决定。

DSL 使用

import { createPageRuntime, PageRuntimeView } from '@pactor-app/runtime';
import { registerMarkdownComponents } from '@pactor-app/markdown';

const runtime = createPageRuntime(pageDsl);
registerMarkdownComponents(runtime.context.components); // 注册 DSL 类型 'Markdown'

await runtime.initialized;
<PageRuntimeView runtime={runtime} />;
type: Markdown
props:
  content: '当前筛选:**${state.keyword}**'

props.content 中的表达式(${data.xxx} 等)由 Renderer 在下发前解析,组件拿到的已是最终文本。Chat 的 Safe Registry 场景可复用同一 registerMarkdownComponents

文档

完整文档见 https://github.com/426-330/pactor/tree/main/docspnpm docs:dev 本地启动文档站)。

License

MIT