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

hwp-eqn-ts

v1.1.0

Published

HWP <-> LaTeX parser library

Readme

🌟 HwpLatex Parser

한글(HWP) 수식LaTeX를 상호 변환하고,
AST(Abstract Syntax Tree) 형태로 조작할 수 있는 TypeScript 라이브러리입니다.

🍀 소개 (Introduction)

HwpLatex Parser는 다음과 같은 기능을 제공합니다:

  1. 토큰화 (Tokenizing)

    • hwpeqn 문법(한글 수식) → 토큰 배열
    • latex 문법(LaTeX) → 토큰 배열
  2. 파싱 (Parsing)

    • 문법별 전용 파서를 통해 공통 AST를 생성
    • int_1^2 / \int_{1}^2 / pmatrix{...} / \begin{pmatrix}...\end{pmatrix} 등 지원
  3. 코드 변환 (Decoding)

    • 공통 AST → 한글 수식 문법(hwpeqn)
    • 공통 AST → LaTeX 문법(latex)
  4. 불필요한 괄호/중첩을 자동으로 완화 (Flattening)

    • 예: 중첩된 { { ... } }{ ... }

(\Rightarrow) 한글(HWP) 수식LaTeX 간 상호 변환을 유연하게 해주는 라이브러리입니다.


📦 설치 (Installation)

npm install hwp-eqn-ts
# 또는
yarn add hwp-eqn-ts

⚙️ 사용 방법 (Usage)

import { Tokenizer, Parser } from "hwp-eqn-ts"; 

// 1) 한글(HWP) 수식 예시
const hwpeqnInput = `
  x times 3 + y^2 over z + int_1^2 { x^3 }
  + pmatrix{1 & 2 # 3 & 4}
  + cases { x=1 # y=2 }
`;

// 1-1) 토큰화
const hwpTokens = Tokenizer.tokenize(hwpeqnInput, "hwpeqn");

// 1-2) 파싱 -> AST
const hwpAst = Parser.parseExpression(hwpTokens, "hwpeqn");

// 1-3) AST -> LaTeX
const latexStr = Tokenizer.decode(hwpAst, "latex")
console.log("Converted to LaTeX:\n", latexStr);

// 2) LaTeX 예시
const latexInput = String.raw`
  x \times 3 + \frac{y^2}{z} + \int_{1}^{2} {x^3}
  + \pmatrix{1 & 2 \\ 3 & 4} + \begin{cases} x=1 \\ y=2 \end{cases}
`;

// 2-1) 토큰화
const latexTokens = Tokenizer.tokenize(latexInput, "latex");

// 2-2) 파싱 -> AST
const latexAst = Parser.parseExpression(latexTokens, "latex");

// 2-3) AST -> 한글(HWP) 수식
const hwpEqnStr = Tokenizer.decode(latexAst, "hwpeqn")
console.log("Converted back to HWP:\n", hwpEqnStr);

📄 라이선스 (License)

이 프로젝트는 MIT License를 따릅니다.
자유롭게 사용, 수정, 배포하실 수 있습니다.