{"id":27002970,"url":"https://github.com/md2docx/core","last_synced_at":"2025-04-04T05:14:34.879Z","repository":{"id":284310197,"uuid":"954504144","full_name":"md2docx/core","owner":"md2docx","description":"The core engine that powers `mdast2docx` — convert Markdown Abstract Syntax Trees (MDAST) into DOCX effortlessly.","archived":false,"fork":false,"pushed_at":"2025-04-01T08:33:41.000Z","size":782,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-01T09:31:56.244Z","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},"funding":{"github":["tiny-md","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-25T07:24:40.000Z","updated_at":"2025-04-01T08:33:44.000Z","dependencies_parsed_at":"2025-03-25T08:39:14.391Z","dependency_job_id":"b151c855-4c21-480d-a0db-6f97e0f74c2f","html_url":"https://github.com/md2docx/core","commit_stats":null,"previous_names":["md2docx/core"],"tags_count":1,"template":false,"template_full_name":"md2docx/md2docx-plugin-template-archived","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/md2docx%2Fcore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/md2docx%2Fcore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/md2docx%2Fcore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/md2docx%2Fcore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/md2docx","download_url":"https://codeload.github.com/md2docx/core/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247123083,"owners_count":20887261,"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","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:34.290Z","updated_at":"2025-04-04T05:14:34.865Z","avatar_url":"https://github.com/md2docx.png","language":"TypeScript","funding_links":["https://github.com/sponsors/tiny-md","https://github.com/sponsors/mayank1513","https://polar.sh/mayank1513","https://pages.razorpay.com/mayank1513"],"categories":[],"sub_categories":[],"readme":"# **@m2d/core** \u003cimg src=\"https://raw.githubusercontent.com/mayank1513/mayank1513/main/popper.png\" style=\"height: 40px\"/\u003e\n\n[![test](https://github.com/md2docx/core/actions/workflows/test.yml/badge.svg)](https://github.com/md2docx/core/actions/workflows/test.yml) [![Maintainability](https://api.codeclimate.com/v1/badges/aa896ec14c570f3bb274/maintainability)](https://codeclimate.com/github/md2docx/core/maintainability) [![codecov](https://codecov.io/gh/md2docx/core/graph/badge.svg)](https://codecov.io/gh/md2docx/core) [![Version](https://img.shields.io/npm/v/@m2d/core.svg?colorB=green)](https://www.npmjs.com/package/@m2d/core) [![Downloads](https://img.jsdelivr.com/img.shields.io/npm/d18m/@m2d/core.svg)](https://www.npmjs.com/package/@m2d/core) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@m2d/core)\n\n\u003e The core engine that powers `mdast2docx` — convert Markdown Abstract Syntax Trees (MDAST) into DOCX effortlessly.\n\n## ✨ Features\n\n- ✅ Lightweight and fast MDAST to DOCX conversion\n- ✅ Works on both **client-side** and **server-side** environments\n- ✅ Built-in support for section-based rendering\n- ✅ Plugin-friendly architecture\n\n\u003e **Note:** With a lean core, functionality can be extended via plugins such as `@m2d/html`, `@m2d/image`, `@m2d/table`, etc.\n\n---\n\n## 📦 Installation\n\n```bash\npnpm install @m2d/core\n```\n\n**_or_**\n\n```bash\nyarn add @m2d/core\n```\n\n**_or_**\n\n```bash\nnpm add @m2d/core\n```\n\n---\n\n## 🚀 Usage\n\n```ts\nimport { toDocx } from \"@m2d/core\";\n\nconst docxBlob = await toDocx(mdast, docxProps, sectionProps);\n```\n\n---\n\n## 🔌 Plugins\n\n`@m2d/core` supports both official and community plugins to extend its capabilities. For example:\n\n```ts\nimport { toDocx } from \"@m2d/core\";\nimport { imagePlugin } from \"@m2d/image\";\n\nawait toDocx(mdast, docxProps, {\n  plugins: [imagePlugin()],\n});\n```\n\n\u003e 🔍 Use only the plugins you need for better performance and bundle size.\n\u003e 🧠 You can use official plugins, or build your own custom ones to keep the bundle size minimal and functionality scoped.\n\n### `@m2d/core` official plugins:\n\n| Plugin         | Package                                                  | Purpose                  |\n| -------------- | -------------------------------------------------------- | ------------------------ |\n| HTML           | [`@m2d/html`](https://www.npmjs.com/package/@m2d/html)   | Handle raw HTML nodes    |\n| Image          | [`@m2d/image`](https://www.npmjs.com/package/@m2d/image) | Embed images in DOCX     |\n| Math           | [`@m2d/math`](https://www.npmjs.com/package/@m2d/math)   | Render LaTeX math        |\n| Table          | [`@m2d/table`](https://www.npmjs.com/package/@m2d/table) | Markdown tables          |\n| List           | [`@m2d/list`](https://www.npmjs.com/package/@m2d/list)   | Advanced list formatting |\n| Extended MDAST | [`@m2d/mdast`](https://www.npmjs.com/package/@m2d/mdast) | Extended mdast types     |\n\n---\n\n## 📜 API\n\n### `toDocx(astInputs, docxProps, defaultSectionProps, outputType?)`\n\n| Param                              | Type                                               | Description                               |\n| ---------------------------------- | -------------------------------------------------- | ----------------------------------------- |\n| `astInputs`                        | `Root` or `{ ast: Root; props?: ISectionProps }[]` | The parsed Markdown AST                   |\n| `docxProps` _(optional)_           | `IDocxProps`                                       | Document metadata and style               |\n| `defaultSectionProps` _(optional)_ | `ISectionProps`                                    | Default layout configuration for sections |\n| `outputType` _(optional)_          | `OutputType`                                       | (defaults to `'blob'`)                    |\n\nReturns a `Promise` resolving to a DOCX Blob, Buffer, or Base64 string.\n\n## 🤖 Generative AI Use-case\n\nAI tools often generate Markdown — `@m2d/core` helps convert them into rich DOCX reports or presentations. This is useful in:\n\n- AI-generated blogs, documentation, and research reports\n- Client-side and server-side rendering of AI-generated content\n- Integrating in GenAI pipelines with format export capabilities\n\n---\n\n## 💡 Inspiration \u0026 Relevance\n\nThis library is especially useful in:\n\n- **Generative AI** — Convert Markdown outputs (e.g., from ChatGPT, LLMs) to downloadable DOCX reports\n- **Developer Tools** — Export Markdown-based documentation or changelogs as DOCX\n- **Education** — Convert notes, quizzes, or assignments authored in Markdown\n\n\u003e ✅ Works both on **client side** and **server side** — offload to browser or use high-performance Node.js.\n\n## 🛠️ Development\n\n```bash\ngit clone https://github.com/tiny-md/mdast2docx\ncd mdast2docx/m2d/core\npnpm install\npnpm dev\n```\n\n---\n\n## 📄 License\n\nLicensed under the **MPL-2.0** License.\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\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\n\u003e _with `@m2d/core`, bring structure, style, and extensibility to your Markdown-to-DOCX pipeline._\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmd2docx%2Fcore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmd2docx%2Fcore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmd2docx%2Fcore/lists"}