Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ntsd/svelte-tex

Svelte component to convert TeX/LaTeX to MathML or SVG
https://github.com/ntsd/svelte-tex

hacktoberfest latex math mathml svelte svg tex

Last synced: 29 days ago
JSON representation

Svelte component to convert TeX/LaTeX to MathML or SVG

Awesome Lists containing this project

README

        

# svelte-tex

[![npm version](https://badge.fury.io/js/svelte-tex.svg)](https://www.npmjs.com/package/svelte-tex)

Svelte Component to convert [TeX](https://en.wikipedia.org/wiki/TeX) to rendered SVG using [MathJax](https://github.com/mathjax/MathJax) or rendered MathML using [Temml](https://github.com/ronkok/Temml).

[Try It Online](https://ntsd.github.io/svelte-tex)

*Svelte 5 Ready*

## Features

- Convert TeX to SVG using [MathJax](https://github.com/mathjax/MathJax)
- Convert TeX to MathML using [Temml](https://github.com/ronkok/Temml)
- Support MathJax options
- Support Temml options

## Installation

`npm install svelte-tex`

## Usage

> **`MathML` is more recommended since `MathSVG` bundle size is not small.**

### MathML

```ts

import MathML from 'svelte-tex/package/MathML.svelte';

// use String.raw to escape `\`
const tex = String.raw`\frac{(n^2+n)(2n+1)}{6}`;

// or include Temml options

```

### MathSVG

```ts

import MathSVG from 'svelte-tex/package/MathSVG.svelte';

// use String.raw to escape `\`
const tex = String.raw`\frac{(n^2+n)(2n+1)}{6}`;

// or include MathJax options

```

> :warning: MathSVG is not small for bundle size.

MathJax is not supports TypeScript for options yet

check texOptions from https://docs.mathjax.org/en/latest/options/input/tex.html#tex-input-processor-options

check svgOptions from https://docs.mathjax.org/en/latest/options/output/svg.html#svg-options