OmmlToMathml 1.2.1

dotnet add package OmmlToMathml --version 1.2.1
                    
NuGet\Install-Package OmmlToMathml -Version 1.2.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OmmlToMathml" Version="1.2.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OmmlToMathml" Version="1.2.1" />
                    
Directory.Packages.props
<PackageReference Include="OmmlToMathml" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OmmlToMathml --version 1.2.1
                    
#r "nuget: OmmlToMathml, 1.2.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OmmlToMathml@1.2.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OmmlToMathml&version=1.2.1
                    
Install as a Cake Addin
#tool nuget:?package=OmmlToMathml&version=1.2.1
                    
Install as a Cake Tool

OmmlToMathml - .NET

NuGet License

A .NET library for converting Office Math Markup Language (OMML/OMath) to MathML. This is a C# port inspired by the plurimath/omml2mathml Ruby implementation.

Features

  • XSLT-based conversion:
  • HTML processing: Converts HTML fragments containing OMML to MathML seamlessly
  • Comprehensive OMML support: Handles fractions, superscripts, subscripts, radicals, matrices, and more
  • Fallback implementation: C# implementation serves as backup if XSLT fails
  • Easy integration: Simple API designed for .NET applications

Installation

dotnet add package OmmlToMathml

Usage

Basic Conversion

using OmmlToMathml.Core;

// Convert OMML fragment to MathML
string omml = "<oMath><f><num><r><t>x</t></r></num><den><r><t>y</t></r></den></f></oMath>";
string mathml = OmmlToMathmlConverter.ConvertOmmlToMathMl(omml);
// Result: <math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mfrac><mi>x</mi><mi>y</mi></mfrac></mrow></math>

HTML Document Processing

// Convert HTML containing OMML to HTML with MathML
string htmlWithOmml = "<p>Formula: <oMath><sSup><e><r><t>x</t></r></e><sup><r><t>2</t></r></sup></sSup></oMath></p>";
string htmlWithMathml = OmmlToMathmlConverter.ReplaceOmmlWithMathMlInHtml(htmlWithOmml);
// Result: <p>Formula: <math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msup><mi>x</mi><mn>2</mn></msup></mrow></math></p>

Full Document Processing

// Process complete HTML documents
string document = OmmlToMathmlConverter.ConvertHtmlDocument(htmlContent);

Supported OMML Elements

  • Text and runs: <r>, <t><mi>, <mn>, <mo>, <mtext>
  • Fractions: <f>, <num>, <den><mfrac>
  • Scripts: <sSup>, <sSub>, <sSubSup><msup>, <msub>, <msubsup>
  • Radicals: <rad>, <deg><msqrt>, <mroot>
  • Delimiters: <d><mrow> with <mo> brackets
  • Accents: <acc><mover>
  • N-ary operators: <nary><munderover>, <munder>, <mover>
  • Matrices: <m>, <mr><mtable>, <mtr>, <mtd>
  • Box elements: <borderBox>, <bar>, etc.

Architecture

This library uses a hybrid approach:

  1. Primary: XSLT transformation using the proven stylesheet from plurimath/omml2mathml
  2. Fallback: Pure C# implementation for cases where XSLT fails
  3. HTML Processing: Converts HTML to XHTML and handles OOXML case sensitivity

Acknowledgments

  • Inspired by plurimath/omml2mathml Ruby implementation
  • Uses XSLT stylesheets originally from Microsoft Word and the TEI Consortium
  • Based on the Office Math Markup Language specification

License

BSD-2-Clause License - see LICENSE file for details.

Contributing

Issues and pull requests are welcome! Please follow the existing code style and add tests for new features.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.1 125 8/21/2025
1.2.0 129 8/13/2025
1.1.0 128 8/13/2025
1.0.0 140 8/12/2025

v1.2.1 - Critical fix for text loss in oMath elements
   • FIXED: Direct text content in <oMath> elements now correctly preserved during conversion
   • FIXED: Text like "y = ", "∙ 100 %", operators, and numbers are no longer lost
   • Improved XSLT template handling for mixed content (elements + text)
   • All previous features maintained: namespace prefix, error handling, HTML processing
   • Based on plurimath/omml2mathml Ruby implementation