{"id":27002940,"url":"https://github.com/md2docx/table","last_synced_at":"2026-04-02T01:08:47.421Z","repository":{"id":284469647,"uuid":"954883533","full_name":"md2docx/table","owner":"md2docx","description":"Plugin to convert Markdown tables (MDAST) to DOCX with support for rich formatting and seamless integration into mdast2docx.","archived":false,"fork":false,"pushed_at":"2026-03-26T09:02:35.000Z","size":2061,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-26T12:41:21.804Z","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":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-25T19:05:02.000Z","updated_at":"2026-03-26T09:02:39.000Z","dependencies_parsed_at":"2025-03-26T03:51:28.180Z","dependency_job_id":"f2c85beb-edd6-4b7d-82d4-8bc1a35ad294","html_url":"https://github.com/md2docx/table","commit_stats":null,"previous_names":["md2docx/table"],"tags_count":7,"template":false,"template_full_name":"md2docx/md2docx-plugin-template","purl":"pkg:github/md2docx/table","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/md2docx%2Ftable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/md2docx%2Ftable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/md2docx%2Ftable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/md2docx%2Ftable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/md2docx","download_url":"https://codeload.github.com/md2docx/table/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/md2docx%2Ftable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31293647,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T01:05:07.454Z","status":"ssl_error","status_checked_at":"2026-04-02T00:56:46.496Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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:30.500Z","updated_at":"2026-04-02T01:08:47.411Z","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/table` \u003cimg src=\"https://raw.githubusercontent.com/mayank1513/mayank1513/main/popper.png\" height=\"40\"/\u003e\n\n[![test](https://github.com/md2docx/table/actions/workflows/test.yml/badge.svg)](https://github.com/md2docx/table/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/md2docx/table/graph/badge.svg)](https://codecov.io/gh/md2docx/table) [![Version](https://img.shields.io/npm/v/@m2d/table?color=green)](https://www.npmjs.com/package/@m2d/table) ![Downloads](https://img.shields.io/npm/d18m/@m2d/table) ![Bundle Size](https://img.shields.io/bundlephobia/minzip/@m2d/table)\n\n\u003e A plugin that converts Markdown tables into rich, styled Word tables with full alignment, border, and header support.\n\n---\n\n## 📦 Installation\n\n```bash\nnpm install @m2d/table\n```\n\n```bash\npnpm add @m2d/table\n```\n\n```bash\nyarn add @m2d/table\n```\n\n---\n\n## 🚀 Overview\n\nThe `@m2d/table` plugin for [`mdast2docx`](https://github.com/mayankchaudhari/mdast2docx) renders Markdown tables into Word-compatible tables with customizable layout, alignment, and cell styling using the `docx` library.\n\n\u003e Automatically handles header rows, borders, shading, cell alignments, and padding — all configurable.\n\n---\n\n## ✨ Features\n\n- Transforms Markdown tables into `docx.Table` elements\n- Auto-detects column alignment from MDAST (`left`, `center`, `right`)\n- Customizable:\n  - Table width and border styles\n  - Cell padding and shading\n  - Header row formatting\n  - Horizontal and vertical alignment\n- Graceful fallback to defaults if MDAST alignment is missing\n\n---\n\n## 🛠️ Usage\n\n```ts\nimport { toDocx } from \"@m2d/core\";\nimport { tablePlugin } from \"@m2d/table\";\n\nconst plugins = [tablePlugin()];\n\nconst buffer = await toDocx(mdastTree, {\n  plugins,\n});\n```\n\n---\n\n## ⚙️ Options\n\nThe `tablePlugin` accepts an optional configuration object:\n\n```ts\ntablePlugin({\n  tableProps: { ... },\n  rowProps: { ... },\n  cellProps: {\n    ... // CellProps\n    data: { bold: true, color: \"#000000\" } // Paragraph and Run styling options\n  },\n  firstRowProps: { ... },\n  firstRowCellProps: {\n    data: { bold: true, alignment: AlignmentType.CENTER } // Header cell styling\n  },\n  alignments: {\n    defaultHorizontalAlign: AlignmentType.CENTER,\n    defaultVerticalAlign: VerticalAlign.CENTER,\n    preferMdData: true,\n  },\n});\n```\n\nAll options override the following sensible defaults:\n\n### Default Table Style\n\n| Property             | Default Value                          |\n| -------------------- | -------------------------------------- |\n| Table Width          | `100%` (percentage)                    |\n| Border Style         | `SINGLE`, size `1`                     |\n| Cell Padding         | 2–4mm margins (top/bottom/left/right)  |\n| Header Row           | Bold with shaded background `#b79c2f`  |\n| Cell Styling         | Full docx.js paragraph \u0026 run options   |\n| Vertical Alignment   | `CENTER`                               |\n| Horizontal Alignment | Based on Markdown or `CENTER` fallback |\n\n### Advanced Cell Styling with `data` Property\n\nThe `data` property provides comprehensive styling control using **docx.js** paragraph and text run options:\n\n#### Text Run Styling (`IRunOptions`)\n\n- `bold`, `italics`, `underline`, `strike`, `doubleStrike`\n- `color`, `size` (font size in half-points)\n- `font` (font family), `highlight`, `shading`\n- `superScript`, `subScript`, `smallCaps`, `allCaps`\n\n#### Paragraph Styling (`IParagraphOptions`)\n\n- `alignment` - text alignment (LEFT, CENTER, RIGHT, JUSTIFIED)\n- `spacing` - line spacing and paragraph spacing\n- `indent` - left, right, first line, hanging indents\n- `numbering`, `bullet`, `style`\n\n#### Code Block Support\n\n- `pre: true` - preserves spaces, newline for code blocks\n\n```ts\ntablePlugin({\n  cellProps: {\n    data: {\n      font: \"Arial\",\n      size: 20, // 10pt font\n      color: \"#333333\",\n      spacing: { after: 120 }, // 6pt spacing after\n    },\n  },\n  firstRowCellProps: {\n    data: {\n      bold: true,\n      alignment: AlignmentType.CENTER,\n      color: \"#ffffff\",\n      size: 24, // 12pt font\n      font: \"Calibri\",\n    },\n  },\n});\n```\n\n---\n\n## 🧪 Example\n\n### Markdown Input\n\n```md\n| Name  | Age |      City |\n| :---: | :-: | --------: |\n| Alice | 24  |  New York |\n|  Bob  | 30  | San Diego |\n```\n\n### Output DOCX\n\n- The first row is treated as a **header**, with custom shading.\n- Column alignment is preserved: center, center, right.\n\n---\n\n## 🔍 Internals\n\n- Leverages `docx.Table`, `docx.TableRow`, `docx.TableCell`, and `docx.Paragraph`\n- Dynamically maps Markdown alignment via `MDAST.align[]`\n- Uses `@m2d/core`’s block plugin API\n- Prevents re-processing of transformed nodes by setting `node.type = \"\"`\n\n---\n\n## ⚠️ Limitations\n\n- Does not support row/column spans\n- MDAST source must conform to [GFM tables](https://github.github.com/gfm/#tables-extension-)\n- Table styling is fixed to plugin options; no per-cell customization via Markdown yet\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%2Ftable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmd2docx%2Ftable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmd2docx%2Ftable/lists"}