A JavaScript LaTeX to HTML5 translator monorepo - WebTeX fork with enhanced features for modern web development.
- Complete LaTeX-to-web pipeline with support for mathematical expressions via KaTeX
- Document classes - article, book, report
- LaTeX packages - amsthm, graphicx, hyperref, and more
- Visual regression testing with Playwright for UI consistency
- TypeScript-first development with strict type safety
- Live preview VS Code extension for real-time LaTeX editing
- packages/core - WebTeX core library (
webtex
) for LaTeX to HTML5 translation - packages/app - Web-based live preview application (
webtex-app
) - packages/vscode - VS Code extension (
webtex-preview
) for live LaTeX preview
# Install as npm package
npm install webtex
# Or use with yarn
yarn add webtex
import { LaTeX } from 'webtex';
const latex = new LaTeX();
const html = latex.parse('\\documentclass{article}\\begin{document}Hello World!\\end{document}');
console.log(html);
# Install globally
npm install -g webtex
# Convert LaTeX file to HTML
webtex input.tex output.html
- Node.js >= 22.0 (required)
- npm (recommended package manager)
- VS Code (for extension development)
# Clone the repository
git clone https://github.com/tani/webtex.git
cd webtex
# Install dependencies
npm install
# Build all packages
npm run build
# Run tests
npm test
# Quality assurance (run before committing)
npm run lint
npm run typecheck
# Core library development
npm run build:core # Build core package
npm run test:core # Test core package
npm run dev:core # Watch mode for core
# VS Code extension development
npm run build:vscode # Build extension
npm run dev:vscode # Watch mode for extension
# All packages
npm run build # Build all packages
npm test # Test all packages
npm run clean # Clean build artifacts
The project includes comprehensive testing infrastructure:
# Unit and integration tests
npm test
# Visual regression tests (Playwright-powered)
npx playwright install
npm test test/visual/
# API tests
npm test test/unit/api.spec.ts
# CLI tests
npm test test/unit/cli.spec.ts
Before committing, ensure all quality checks pass:
npm run lint # Biome linting and formatting
npm run typecheck # TypeScript type checking
npm run build # Build verification
npm test # Full test suite
- TypeScript - Strict type safety and modern JavaScript features
- Vite - Fast build tool with HMR support
- Vitest - Unit testing integrated with Vite
- Biome - Lightning-fast linting and formatting
- PegJS - LaTeX grammar parser with custom Vite plugin
This monorepo uses npm workspaces for dependency management:
webtex/
├── packages/
│ ├── core/ # Core WebTeX library
│ │ ├── src/ # TypeScript source
│ │ ├── dist/ # Built output
│ │ └── test/ # Test suites
│ └── vscode/ # VS Code extension
│ ├── src/ # Extension source
│ └── out/ # Built extension
├── .github/workflows/ # CI/CD configuration
└── package-lock.json # Dependency lockfile
- Fork the repository and create a feature branch
- Make changes following the TypeScript coding standards
- Run quality checks:
npm run lint && npm run typecheck && npm run build && npm test
- Submit a pull request with a clear description
- Never use
any
- Useunknown
for unknown types - Minimize
as
casting - Prefer type guards and proper interfaces - Explicit return types for all public methods
- Strict null safety with optional chaining and nullish coalescing
MIT License - see LICENSE file for details.
- LaTeX.js - Original LaTeX.js project
- KaTeX - Mathematical notation rendering
- Playwright - Headless browser automation