OmmlToMathml 1.2.1
dotnet add package OmmlToMathml --version 1.2.1
NuGet\Install-Package OmmlToMathml -Version 1.2.1
<PackageReference Include="OmmlToMathml" Version="1.2.1" />
<PackageVersion Include="OmmlToMathml" Version="1.2.1" />
<PackageReference Include="OmmlToMathml" />
paket add OmmlToMathml --version 1.2.1
#r "nuget: OmmlToMathml, 1.2.1"
#:package OmmlToMathml@1.2.1
#addin nuget:?package=OmmlToMathml&version=1.2.1
#tool nuget:?package=OmmlToMathml&version=1.2.1
OmmlToMathml - .NET
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:
- Primary: XSLT transformation using the proven stylesheet from plurimath/omml2mathml
- Fallback: Pure C# implementation for cases where XSLT fails
- 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 | Versions 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. |
-
.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.
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