{"id":27002950,"url":"https://github.com/md2docx/math","last_synced_at":"2025-08-13T07:07:18.628Z","repository":{"id":284462794,"uuid":"954879584","full_name":"md2docx/math","owner":"md2docx","description":"Plugin to convert mathematical expressions in Markdown (MDAST) to DOCX using LaTeX-style syntax. Integrates seamlessly with mdast2docx.","archived":false,"fork":false,"pushed_at":"2025-08-07T01:08:37.000Z","size":1513,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-07T03:08:54.054Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/md2docx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"contributing.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["md2docx","mayank1513"],"polar":"mayank1513","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":["https://pages.razorpay.com/mayank1513"]}},"created_at":"2025-03-25T18:56:48.000Z","updated_at":"2025-08-07T01:08:41.000Z","dependencies_parsed_at":"2025-03-26T02:41:37.576Z","dependency_job_id":"3f6c6dfe-e29a-4a85-b63a-3039b8e73425","html_url":"https://github.com/md2docx/math","commit_stats":null,"previous_names":["md2docx/math"],"tags_count":6,"template":false,"template_full_name":"md2docx/md2docx-plugin-template","purl":"pkg:github/md2docx/math","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/md2docx%2Fmath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/md2docx%2Fmath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/md2docx%2Fmath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/md2docx%2Fmath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/md2docx","download_url":"https://codeload.github.com/md2docx/math/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/md2docx%2Fmath/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270199488,"owners_count":24543658,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-13T02:00:09.904Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-04T05:14:31.724Z","updated_at":"2025-08-13T07:07:18.591Z","avatar_url":"https://github.com/md2docx.png","language":"TypeScript","funding_links":["https://github.com/sponsors/md2docx","https://github.com/sponsors/mayank1513","https://polar.sh/mayank1513","https://pages.razorpay.com/mayank1513"],"categories":[],"sub_categories":[],"readme":"# `@m2d/math` \u003cimg src=\"https://raw.githubusercontent.com/mayank1513/mayank1513/main/popper.png\" height=\"40\"/\u003e\n\n[![test](https://github.com/md2docx/math/actions/workflows/test.yml/badge.svg)](https://github.com/md2docx/math/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/md2docx/math/graph/badge.svg)](https://codecov.io/gh/md2docx/math) [![Version](https://img.shields.io/npm/v/@m2d/math?color=green)](https://www.npmjs.com/package/@m2d/math) ![Downloads](https://img.shields.io/npm/d18m/@m2d/math) ![Bundle Size](https://img.shields.io/bundlephobia/minzip/@m2d/math)\n\n\u003e A plugin that transforms LaTeX-style math (inline and block) into DOCX-compatible equations using docx.\n\n\u003e This package expects that the math nodes have already been extracted using `remark-math` plugin.\n\n---\n\n## 📦 Installation\n\n```bash\nnpm install @m2d/math\n```\n\n```bash\npnpm add @m2d/math\n```\n\n```bash\nyarn add @m2d/math\n```\n\n---\n\n## 🚀 Overview\n\nThe `@m2d/math` plugin for [`mdast2docx`](https://github.com/mayankchaudhari/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.\n\n\u003e Supports superscripts, subscripts, fractions, radicals, summations, symbols, and more.\n\n---\n\n## ✨ Features\n\n- Parses LaTeX-style math expressions\n- Converts math to `docx.MathRun`, `docx.MathFraction`, `docx.MathRadical`, etc.\n- Supports inline and block math (`$...$`, `$$...$$`)\n- Supports standard math macros like `\\frac`, `\\sqrt`, `\\sum`, `\\alpha`, and many others\n- Handles superscripts (`^`) and subscripts (`_`) intelligently\n- Gracefully ignores unsupported macros like `\\left`, `\\right`, etc.\n\n---\n\n## 🛠️ Usage\n\n```ts\nimport { toDocx } from \"@m2d/core\";\nimport { mathPlugin } from \"@m2d/math\";\n\nconst plugins = [mathPlugin()];\n\nconst buffer = await toDocx(mdastTree, {\n  plugins,\n});\n```\n\n---\n\n## 🧪 Example\n\n### Input Markdown (via MDAST)\n\n```md\nThis is inline math: $E = mc^2$\n\n$$\n\\frac{a^2 + b^2}{c^2} = 1\n$$\n```\n\n### Output DOCX\n\n- Inline math (`$E = mc^2$`) → `E = mc²` as a Word MathRun.\n- Block math renders as full equation paragraphs.\n\n---\n\n## ⚙️ Internals\n\n- Uses [`latex-math`](https://www.npmjs.com/package/latex-math) to parse LaTeX math AST.\n- Converts LaTeX nodes to `docx.MathRun[]` elements.\n- Supports common math macros with fallback to Unicode symbols via an internal symbol map.\n- Integrates seamlessly with `@m2d/core`.\n\n---\n\n## 🧩 Supported Macros\n\nIncludes (but not limited to):\n\n```\n\\frac, \\sqrt, \\sum, \\int, \\alpha, \\beta, \\theta, \\leq, \\geq, \\neq, \\infty, \\cdot\n```\n\n---\n\n## **⚠️ Limitations**\n\n- Does not support full LaTeX environments (`\\begin{align}`, etc.)\n- Complex expressions may need pre-processing\n- Does not render styled math (`\\textcolor`, etc.)\n\n---\n\n## ⭐ Support Us\n\nIf you find this useful:\n\n- ⭐ Star [mdast2docx](https://github.com/tiny-md/mdast2docx) on GitHub\n- ❤️ Consider [sponsoring](https://github.com/sponsors/mayank1513)\n\n---\n\n## 🧾 License\n\nMIT © [Mayank Chaudhari](https://github.com/mayankchaudhari)\n\n---\n\n\u003cp align=\"center\"\u003eMade with 💖 by \u003ca href=\"https://mayank-chaudhari.vercel.app\" target=\"_blank\"\u003eMayank Kumar Chaudhari\u003c/a\u003e\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmd2docx%2Fmath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmd2docx%2Fmath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmd2docx%2Fmath/lists"}