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

@jared-ye/markdown-tex

v1.0.3

Published

Markdown ⇄ LaTeX conversion library with unified AST

Readme

📄 markdown-tex

Markdown ⇄ LaTeX conversion library with a unified AST. Round-trip safe for headings, paragraphs, lists, code blocks, math, links, images, tables, blockquotes, and inline formatting.

npm GitHub


🚀 Install

npm install @jared-ye/markdown-tex

✨ Features

  • 🔄 Bidirectional — Convert Markdown → LaTeX body and LaTeX body → Markdown
  • 🌳 Unified AST — Single intermediate representation for both directions
  • ✅ Round-trip safe — Supported constructs survive MD → LaTeX → MD
  • 📦 Zero config — Works out of the box, no document preamble (use your own \documentclass and packages)

📖 API

| Method | Description | |--------|-------------| | markdownToLatex(md) | Markdown string → LaTeX body (no \documentclass) | | latexToMarkdown(latex) | LaTeX body → Markdown string | | markdownToAST(md) | Markdown → unified AST | | latexToAST(latex) | LaTeX → unified AST | | normalizeAST(ast) | Normalize AST for round-trip comparison | | escapeLatex(str) | Escape # $ % & _ { } etc. for preamble/titlepage |

Types: AST, BlockNode, InlineNode (exported for TypeScript).


💡 Examples

Basic conversion

import { markdownToLatex, latexToMarkdown } from '@jared-ye/markdown-tex'

// Markdown → LaTeX body
const latex = markdownToLatex('# Hello **world**\n\n- item one\n- item two')
// → \section{Hello \textbf{world}}
//   \begin{itemize}
//   \item item one
//   \item item two
//   \end{itemize}

// LaTeX → Markdown
const md = latexToMarkdown('\\section{Foo}\n\nBar with \\textbf{bold}.')
// → # Foo
//   Bar with **bold**.

Math & code

const latex = markdownToLatex('Inline $E=mc^2$ and block:\n\n$$\n\\int_0^1 x\\,dx\n$$')
// Inline math → $...$; block math → \[ ... \]

const code = markdownToLatex('```js\nconst x = 1\n```')
// → \begin{verbatim} ... \end{verbatim}

Escape for titlepage / headers

import { escapeLatex } from '@jared-ye/markdown-tex'

const title = escapeLatex('Price: 100% & "quoted"')
// → Price: 100\% \& \"quoted\"
// Use in \title{}, \lhead{}, etc.

🔗 Links

📄 markdown-tex

基于统一 ASTMarkdown ⇄ LaTeX 转换库。支持标题、段落、列表、代码块、数学、链接、图片、表格、引用及行内格式的往返转换。

npm GitHub


🚀 安装

npm install @jared-ye/markdown-tex

✨ 特性

  • 🔄 双向转换 — Markdown → LaTeX 正文、LaTeX 正文 → Markdown
  • 🌳 统一 AST — 单一中间表示,双向共用
  • ✅ 往返安全 — 支持的语法在 MD → LaTeX → MD 后保持一致
  • 📦 开箱即用 — 仅输出正文,不包含 \documentclass 与宏包(可自建前言)

📖 API

| 方法 | 说明 | |------|------| | markdownToLatex(md) | Markdown 字符串 → LaTeX 正文(无 \documentclass) | | latexToMarkdown(latex) | LaTeX 正文 → Markdown 字符串 | | markdownToAST(md) | Markdown → 统一 AST | | latexToAST(latex) | LaTeX → 统一 AST | | normalizeAST(ast) | 规范化 AST,用于往返比较 | | escapeLatex(str) | 转义 # $ % & _ { } 等,用于前言/标题页 |

类型: ASTBlockNodeInlineNode(TypeScript 导出)。


💡 示例

基础转换

import { markdownToLatex, latexToMarkdown } from '@jared-ye/markdown-tex'

// Markdown → LaTeX 正文
const latex = markdownToLatex('# 你好 **世界**\n\n- 第一项\n- 第二项')
// → \section{你好 \textbf{世界}}
//   \begin{itemize}
//   \item 第一项
//   \item 第二项
//   \end{itemize}

// LaTeX → Markdown
const md = latexToMarkdown('\\section{标题}\n\n内容与\\textbf{加粗}。')
// → # 标题
//   内容与**加粗**。

数学与代码

const latex = markdownToLatex('行内 $E=mc^2$,块级:\n\n$$\n\\int_0^1 x\\,dx\n$$')
// 行内公式 → $...$;块级公式 → \[ ... \]

const code = markdownToLatex('```js\nconst x = 1\n```')
// → \begin{verbatim} ... \end{verbatim}

标题页/页眉转义

import { escapeLatex } from '@jared-ye/markdown-tex'

const title = escapeLatex('价格:100% & “引号”')
// → 价格:100\% \& \"引号\"
// 用于 \title{}、\lhead{} 等

🔗 链接