Temml for .NET
TeX in.
MathML out.
Temml converts TeX math to MathML, which browsers display on their own. Render on the server in C# and ship pages that need a stylesheet and a small font, but no math script.
Unofficial community port of Temml by Ron Kok. Not an official Temml product.
dotnet add package TemmlIt targets net10.0 and netstandard2.0. Temml on NuGet.
using Temml;
var display = TemmlRenderer.RenderToString(
@"\sum_{k=1}^{n} k = \frac{n(n+1)}{2}",
new TemmlOptions { DisplayMode = true }
);Packages
Temml
and Temml.AngleSharp
Targets
net10.0
and netstandard2.0
Upstream
0.14.0
Ported from Temml
License
MIT
Same as upstream
Examples
Real MathML, no script on the page.
Each card is the markup upstream Temml produces for the TeX under it, styled with the stylesheet the package embeds. Your browser and its fonts do the drawing.
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}\int_{-\infty}^{\infty} e^{-x^2}\,dx = \sqrt{\pi}A = \begin{pmatrix} a & b \\ c & d \end{pmatrix}f(x) = \begin{cases} x^2 & x \ge 0 \\ -x & x < 0 \end{cases}\ce{CH4 + 2O2 -> CO2 + 2H2O}\nabla \times \mathbf{B} = \mu_0 \mathbf{J} + \mu_0 \varepsilon_0 \frac{\partial \mathbf{E}}{\partial t}
Why Temml
Upstream Temml, in the C# you already write.
TeX to MathML
QuickstartTemmlRendererreturns a string, or a tree you can change before it becomes one.Macros and extensions
Custom macros, preambles, and
Macros\gdef.mhchem,physics, andtexvcare built in.Whole pages
DOM and auto-renderTemml.AngleSharpfinds the math delimiters in a document, renders them, and resolves\ref.Untrusted input
Commands that load resources or set attributes are blocked by default, with limits on sizes and expansions.
Security
Get started
From TeX to an equation on the page, in three steps.
Install the package, render an expression, then serve the stylesheet. Each step links to the page that has the rest.
Read the quickstartInstall the package
Add
Temmlto a project that targetsnet10.0ornetstandard2.0.
Quickstartdotnet add package TemmlRender and style
Write the markup into your page, and serve one Temml stylesheet with
Temml.woff2. Both are embedded in the package.
Styles and fontsvar mathml = TemmlRenderer.RenderToString(tex);Or render a whole page
With
Temml.AngleSharp, find the delimiters in an HTML document and render them in place.
DOM and auto-renderdotnet add package Temml.AngleSharp TemmlDom.RenderMathInElement(document.Body!);