
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Plugin to convert mathematical expressions in Markdown (MDAST) to DOCX using LaTeX-style syntax. Integrates seamlessly with mdast2docx.
@m2d/math
A plugin that transforms LaTeX-style math (inline and block) into DOCX-compatible equations using docx.
This package expects that the math nodes have already been extracted using
remark-math
plugin.
npm install @m2d/math
pnpm add @m2d/math
yarn add @m2d/math
The @m2d/math
plugin for mdast2docx
enables support for LaTeX math rendering in DOCX exports. It parses inline and block-level math expressions written in LaTeX syntax and converts them into proper Word-compatible Math elements using the docx
library.
Supports superscripts, subscripts, fractions, radicals, summations, symbols, and more.
docx.MathRun
, docx.MathFraction
, docx.MathRadical
, etc.$...$
, $$...$$
)\frac
, \sqrt
, \sum
, \alpha
, and many others^
) and subscripts (_
) intelligently\left
, \right
, etc.import { toDocx } from "@m2d/core";
import { mathPlugin } from "@m2d/math";
const plugins = [mathPlugin()];
const buffer = await toDocx(mdastTree, {
plugins,
});
This is inline math: $E = mc^2$
$$
\frac{a^2 + b^2}{c^2} = 1
$$
$E = mc^2$
) → E = mc²
as a Word MathRun.latex-math
to parse LaTeX math AST.docx.MathRun[]
elements.@m2d/core
.Includes (but not limited to):
\frac, \sqrt, \sum, \int, \alpha, \beta, \theta, \leq, \geq, \neq, \infty, \cdot
\begin{align}
, etc.)\textcolor
, etc.)If you find this useful:
MIT © Mayank Chaudhari
Made with 💖 by Mayank Kumar Chaudhari
FAQs
Plugin to convert mathematical expressions in Markdown (MDAST) to DOCX using LaTeX-style syntax. Integrates seamlessly with mdast2docx.
The npm package @m2d/math receives a total of 4,277 weekly downloads. As such, @m2d/math popularity was classified as popular.
We found that @m2d/math demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.