New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tex2typst

Package Overview
Dependencies
Maintainers
0
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tex2typst

JavaScript library for converting TeX code to Typst

  • 0.0.10
  • unpublished
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

tex2typst

JavaScript library for converting TeX / LaTeX math formula code to Typst

Try it online

A Web UI wrapper is available at https://qwinsi.github.io/tex2typst-webapp/.

Installation

npm install tex2typst

Usage

Basic usage

import { parseTex, tex2typst } from 'tex2typst';

let output = tex2typst("\\zeta(s) = \\sum_{n=1}^{\\infty}\\frac{1}{n^s}");
console.log(output);
// zeta(s) = sum_(n = 1)^infinity frac(1, n^s)

Advanced settings

  • custom TeX macros/commands

For example,

let macros = {
    "\\sgn": "\\operatorname{sgn}"
};
let input = "y = \\sgn(x)";
const output = tex2typst(input, {customTexMacros: macros});
console.log(output);
// y = op("sgn")(x)

How it works

graph LR
    tex[TeX code] --parser--> ast[TeX AST] --writer--> typst[Typst code]
  • parser: Implemented in function parseTex(). At present, it depends on the parser implemented by KaTeX.
  • writer: Implemented in class TypstWriter()

Contributing

Feel free to open an issue or submit a pull request.

Keywords

FAQs

Package last updated on 31 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc