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

koishi-plugin-latex-render

v1.1.6

Published

ChatLuna 专用 - 将 AI 返回的 LaTeX 公式渲染为图片

Readme

koishi-plugin-latex-render

npm

简介

本插件专为 ChatLuna 设计,用于将 AI 返回的 LaTeX 公式渲染为图片并发送。

当 ChatLuna 的 AI 返回包含 LaTeX 公式的消息时,本插件会自动:

  1. 拦截消息
  2. 使用 KaTeX 解析并渲染公式
  3. 使用 Puppeteer 截图生成图片
  4. 将图片发送给用户

特性

  • 整条消息渲染为一张图片 - 不是每个公式单独一张
  • 支持多种 LaTeX 格式 - $$...$$, \[...\], \(...\), $...$, \begin{}...\end{}
  • 中文支持 - 使用微软雅黑字体
  • 可自定义样式 - 支持配置背景色、文字颜色、图片宽度

依赖

本插件依赖以下 Koishi 插件:

  • koishi-plugin-puppeteer - 用于浏览器截图
  • koishi-plugin-assets-local - 用于图片上传托管(可选)

安装

# 使用 yarn
yarn add koishi-plugin-latex-render

# 或使用 npm
npm install koishi-plugin-latex-render

配置

koishi.yml 中配置插件:

latex-render:
  width: 800          # 图片宽度,默认 800
  backgroundColor: "#ffffff"  # 背景色,默认白色
  textColor: "#333333"        # 文字颜色,默认深灰色

# 必须启用 puppeteer 插件
puppeteer: {}

# 建议配置 assets-local 的 selfUrl
assets-local:5fyoiw:
  selfUrl: http://127.0.0.1:5140

工作原理

  1. 监听 chatluna/after-chat 事件
  2. 检测消息中是否包含 LaTeX 公式
  3. 使用 KaTeX 将公式渲染为 HTML
  4. 使用 Puppeteer 打开 HTML 并截图
  5. 通过 assets 服务上传图片
  6. 发送图片消息给用户

支持的 LaTeX 格式

| 格式 | 示例 | 类型 | |------|------|------| | 行内公式 | $x^2$ | inline | | 行内公式 | \(x^2\) | inline | | 块级公式 | $$x^2$$ | display | | 块级公式 | \[x^2\] | display | | 环境 | \begin{cases}...\end{cases} | display |

注意事项

  • 本插件极度特化于 ChatLuna - 仅监听 ChatLuna 的消息事件
  • 需要网络访问 cdn.jsdelivr.net 加载 KaTeX CSS
  • Puppeteer 插件必须在插件列表中启用

开发

# 构建
yarn build

# 或在项目根目录
npm run build latex-render

License

MIT