Convert TeX math to MathML, in C#.
It is an unofficial community port of Temml by Ron Kok. It ports upstream 0.14.0. The output is MathML, which browsers display without any script.
To learn more, read the documentation.
Preview the docs site locally:
cd docs-site && npm ci && npm run api && npm run devOpen http://localhost:4321/temml-dotnet/ . That URL is the marketing page. Documentation starts at http://localhost:4321/temml-dotnet/docs/ . Article sources stay in docs/articles/. See docs-site/README.md.
The packages target net10.0 and netstandard2.0.
| Package | What it has |
|---|---|
Temml |
TeX to MathML, macros, the stylesheets and font. No third-party runtime dependencies. |
Temml.AngleSharp |
Rendering into an AngleSharp document, auto-render, and \ref post-processing. |
Run dotnet add package Temml. To render into an HTML document, run dotnet add package Temml.AngleSharp.
var mathml = TemmlRenderer.RenderToString(@"c = \pm\sqrt{a^2 + b^2}");
Console.WriteLine(mathml); // <math>...</math>var display = TemmlRenderer.RenderToString(
@"\sum_{k=1}^{n} k = \frac{n(n+1)}{2}",
new TemmlOptions { DisplayMode = true }
);
Console.WriteLine(display); // <math display="block" ...>...</math>Invalid TeX comes back as error markup unless you set ThrowOnError. See Errors.
try
{
TemmlRenderer.RenderToString(@"\sqrt{", new TemmlOptions { ThrowOnError = true });
}
catch (ParseError error)
{
Console.WriteLine(error.Message); // the message upstream Temml reports
Console.WriteLine(error.RawMessage);
Console.WriteLine(error.Position); // 6, the offset in the input
}var options = new TemmlOptions
{
Macros = new TemmlMacroDictionary
{
[@"\RR"] = @"\mathbb{R}",
[@"\norm"] = @"\lVert #1 \rVert",
},
};
Console.WriteLine(TemmlRenderer.RenderToString(@"\norm{x} \in \RR", options));See Macros and extensions. mhchem, physics, and texvc are built in.
With Temml.AngleSharp:
var document = parser.ParseDocument(
@"<!DOCTYPE html><body><p>Euler: \(e^{i\pi} + 1 = 0\)</p><p>$$\int_0^1 x^2\,dx$$</p></body>"
);
TemmlDom.RenderMathInElement(document.Body!);
Console.WriteLine(document.Body!.InnerHtml);See DOM and auto-render.
Include one Temml stylesheet and serve Temml.woff2 next to it. Both are embedded in the package. See Styles and fonts.
Commands that load resources or set HTML attributes are blocked by default. Read Security before rendering TeX from users.
Migrating from upstream maps the JavaScript names to the C# ones. Compatibility records the ported version.
See CONTRIBUTING.md.
MIT. Temml is Copyright (c) 2020 Ron Kok. The .NET port is Copyright (c) 2026 Darío Kondratiuk. See LICENSE and NOTICE.