Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tex2typst

Package Overview
Dependencies
Maintainers
0
Versions
31
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.2.13
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
25
increased by177.78%
Maintainers
0
Weekly downloads
 
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

Installing it in a Node.js project

npm install tex2typst

Or just loading it in a web page

<script src="https://cdn.jsdelivr.net/npm/tex2typst@0.2.7/dist/tex2typst.min.js"></script>
<!-- or  -->
<script src="https://unpkg.com/tex2typst@0.2.7/dist/tex2typst.min.js"></script>

Replace 0.2.7 with the latest version number in case this README is outdated.

The size of minimized library tex2typst.min.js is about 23 KB.

Usage

Basic usage

import { 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)

If you are using the library in a web page via a <script> tag, you don't need the line of import, function tex2typst should be available in the global scope.

Advanced options

  • custom TeX macros/commands

For example,

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

How it works

graph LR
    tex[TeX code] --parser--> tex_ast[TeX AST] --converter--> typst_ast[Typst AST] --writer--> typst[Typst code]
  • parser: Implemented in class LatexParser.
  • converter: Implemented in function convertTree.
  • writer: Implemented in class TypstWriter.

Contributing

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

Keywords

FAQs

Package last updated on 16 Dec 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