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 🙏

© 2025 – Pkg Stats / Ryan Hefner

wbwtexit

v0.1.2

Published

A typesetting package dev by wbw121124

Readme

wbwTexit

npm license

wbwTexit 是一个可扩展的 LaTeX 解析与 HTML 转换工具,适用于网页和 Node.js 环境。它基于 KaTeX 实现数学公式渲染,并内置常用的文本、数学、环境、变量定义和包扩展支持。

主要语言:JavaScript 78.6% | HTML 18.9% | Shell 2.5%


安装

npm install wbwtexit
# 或
yarn add wbwtexit

快速使用

import katex from 'katex';
import { wbwTexit } from 'wbwtexit';

const parser = new wbwTexit();
const latexInput = `
\\section{主要功能演示}
\\textbf{支持粗体文本}\\newline
\\textit{斜体}\\newline
\\underline{下划线}\\newline
\\sout{删除线}\\newline
\\texttt{代码字体}\\newline

\\h1{标题1}
\\section{小节(h2)}
\\subsection{子节(h3)}
\\itemize{
  \\item{条目1}
  \\item{条目2}
}
\\enumerate{
  \\item{一}
  \\item{二}
}
\\p{这是一个段落。}

\\math{f(x) = x^2 + 1}
\\displaymath{f(x) = x^2 + 1}

\\textcolor[red]{彩色文本}
\\fontsize[24px]{更大的字体}

\\href[https://github.com/wbwblog/wbwtexit]{项目地址}
\\includegraphics[width=40px]{/path/to/demo.png}
`;

const html = parser.parseToHTML(latexInput);
console.log(html); // 输出对应的 HTML

Demo 示例

1. 渲染基本文本

const parser = new wbwTexit();
console.log(parser.parseToHTML('\\textbf{加粗} 和 \\textit{斜体}'));

输出:

<strong>加粗</strong> 和 <em>斜体</em>

2. 数学公式支持

console.log(parser.parseToHTML('\\math{\\frac{a}{b}}'));

输出(KaTeX 渲染片段):

<span class="katex"> ... </span>

3. 环境与列表

console.log(parser.parseToHTML(`
\\itemize{
  \\item{苹果}
  \\item{香蕉}
}
`));

输出:

<ul><li>苹果</li><li>香蕉</li></ul>

4. 变量和表达式

parser.parseToHTML('\\set[$x]{"42"}');
parser.parseToHTML('变量:\\var{$x}');

输出:

变量:42

5. 其它高级命令

  • \\textcolor[red]{红色字体}
  • \\fontsize[30px]{超大字}
  • \\href[https://example.com]{链接文本}
  • \\includegraphics[width=40px]{/path/to/image.png}

扩展包

例如注册 copytex 包(内置):

parser.parseToHTML('\\usepackage[copytex]');

会自动注入拷贝 Tex(KaTeX CopyTex 支持)脚本。


方法与自定义

  • 解析字符串: parser.parseToHTML(str)
  • 注册自定义函数: parser.registerFunction(name, fn, escape, noargs, force)

依赖

  • katex 用于数学公式渲染

License

GNU GPLv3.0