{"id":15415726,"url":"https://github.com/inokawa/remark-docx","last_synced_at":"2026-01-03T07:20:09.397Z","repository":{"id":45097227,"uuid":"445777054","full_name":"inokawa/remark-docx","owner":"inokawa","description":"remark plugin to compile markdown to docx (Microsoft Word, Office Open XML).","archived":false,"fork":false,"pushed_at":"2025-03-03T16:52:10.000Z","size":20765,"stargazers_count":63,"open_issues_count":24,"forks_count":17,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-03-28T14:11:11.227Z","etag":null,"topics":["docx","latex","markdown","math","mdast","office","openxml","remark","remark-plugin","unified","word"],"latest_commit_sha":null,"homepage":"https://inokawa.github.io/remark-docx/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inokawa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["inokawa"]}},"created_at":"2022-01-08T09:31:03.000Z","updated_at":"2025-03-25T15:12:14.000Z","dependencies_parsed_at":"2023-12-14T21:29:00.274Z","dependency_job_id":"8fe01340-2434-43c7-adac-3abb3b6cbccf","html_url":"https://github.com/inokawa/remark-docx","commit_stats":{"total_commits":131,"total_committers":4,"mean_commits":32.75,"dds":0.3129770992366412,"last_synced_commit":"b5fa0538a92868b04870b29670db2425357f3874"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inokawa%2Fremark-docx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inokawa%2Fremark-docx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inokawa%2Fremark-docx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inokawa%2Fremark-docx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inokawa","download_url":"https://codeload.github.com/inokawa/remark-docx/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247198446,"owners_count":20900079,"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":["docx","latex","markdown","math","mdast","office","openxml","remark","remark-plugin","unified","word"],"created_at":"2024-10-01T17:09:25.287Z","updated_at":"2026-01-03T07:20:09.392Z","avatar_url":"https://github.com/inokawa.png","language":"TypeScript","funding_links":["https://github.com/sponsors/inokawa"],"categories":[],"sub_categories":[],"readme":"# remark-docx\n\n![npm](https://img.shields.io/npm/v/remark-docx) ![npm](https://img.shields.io/npm/dw/remark-docx) ![check](https://github.com/inokawa/remark-docx/workflows/check/badge.svg) ![demo](https://github.com/inokawa/remark-docx/workflows/demo/badge.svg)\n\n\u003e [remark](https://github.com/remarkjs/remark) plugin to compile markdown to docx (Microsoft Word, Office Open XML).\n\n- Uses [docx](https://github.com/dolanmiu/docx) for compilation.\n- Works in any environment (e.g. browser, Node.js).\n- Provides reasonable default style and also tunable enough (WIP).\n- Supports advanced layouts (RTL, vertical, 2 columns).\n- Has own plugin system. You can fully customize markdown to Word transformation.\n\n### Supported [mdast](https://github.com/syntax-tree/mdast) nodes\n\nCurrently, some of the default styles may not be nice. If you have feature requests or improvements, please create a [issue](https://github.com/inokawa/remark-docx/issues) or [PR](https://github.com/inokawa/remark-docx/pulls).\n\n- [x] paragraph\n- [x] heading\n- [x] thematicBreak (rendered as Page Break / Section Break / Horizontal line)\n- [x] blockquote\n- [x] list / listItem\n- [x] table / tableRow / tableCell\n- [x] definition\n- [x] text\n- [x] emphasis\n- [x] strong\n- [x] delete\n- [x] inlineCode\n- [x] break\n- [x] link / linkReference\n- [x] footnoteReference / footnoteDefinition\n- [x] image / imageReference ([plugin](#image))\n- [x] html ([plugin](#html))\n- [x] code ([plugin](#code))\n- [x] math / inlineMath ([remark-math](https://github.com/remarkjs/remark-math) and [plugin](#math))\n\n## Demo\n\nhttps://inokawa.github.io/remark-docx/\n\n## Install\n\n```sh\nnpm install remark-docx\n```\n\n## Getting started\n\n### Browser\n\n```javascript\nimport { unified } from \"unified\";\nimport markdown from \"remark-parse\";\nimport docx from \"remark-docx\";\nimport { saveAs } from \"file-saver\";\n\nconst processor = unified().use(markdown).use(docx);\n\nconst text = \"# hello world\";\n\n(async () =\u003e {\n  const doc = await processor.process(text);\n  const arrayBuffer = await doc.result;\n  saveAs(new Blob([arrayBuffer]), \"example.docx\");\n})();\n```\n\n### Node.js\n\n```javascript\nimport { unified } from \"unified\";\nimport markdown from \"remark-parse\";\nimport docx from \"remark-docx\";\nimport * as fs from \"fs\";\n\nconst processor = unified().use(markdown).use(docx);\n\nconst text = \"# hello world\";\n\n(async () =\u003e {\n  const doc = await processor.process(text);\n  const arrayBuffer = await doc.result;\n  fs.writeFileSync(\"example.docx\", Buffer.from(arrayBuffer));\n})();\n```\n\n## Plugins\n\n### Image\n\nFetch image data and embed into docx. `png`, `jpg`, `gif`, `bmp`, `svg` urls are supported.\n\n```javascript\nimport { unified } from \"unified\";\nimport markdown from \"remark-parse\";\nimport docx from \"remark-docx\";\nimport { imagePlugin } from \"remark-docx/plugins/image\";\n\nconst processor = unified()\n  .use(markdown)\n  .use(docx, { plugins: [imagePlugin()] });\n```\n\nURLs are resolved with [fetch API](https://developer.mozilla.org/docs/Web/API/Fetch_API) by default. You can use other methods such as file system.\n\n```javascript\nimport * as fs from \"fs/promises\";\n\nimagePlugin({\n  load: async (url) =\u003e {\n    return (await fs.readFile(url)).buffer;\n  },\n});\n```\n\nWhen we embed `svg` to docx, it also requires `png` image since legacy Word can't render `svg`. On browser, this plugin generate it automatically. On other enviroment like Node.js, please implement `fallbackSvg` prop.\n\n```javascript\nimport sharp from \"sharp\";\n\nimagePlugin({\n  fallbackSvg: async ({ buffer }) =\u003e {\n    return (await sharp(buffer).png().toBuffer()).buffer;\n  },\n});\n```\n\n### Code\n\n#### Syntax highlight\n\nSyntax highlighting with [shiki](https://github.com/shikijs/shiki).\n\n```javascript\nimport { unified } from \"unified\";\nimport markdown from \"remark-parse\";\nimport docx from \"remark-docx\";\nimport { shikiPlugin } from \"remark-docx/plugins/shiki\";\n\nconst processor = unified()\n  .use(markdown)\n  .use(docx, { plugins: [shikiPlugin({ theme: \"dark-plus\" })] });\n```\n\n#### Mermaid\n\nRender [Mermaid](https://mermaid.js.org/) in code blocks with `mermaid` language. It only works in browser for now.\n\n```javascript\nimport { unified } from \"unified\";\nimport markdown from \"remark-parse\";\nimport docx from \"remark-docx\";\nimport { mermaidPlugin } from \"remark-docx/plugins/mermaid\";\n\nconst processor = unified()\n  .use(markdown)\n  .use(docx, { plugins: [mermaidPlugin()] });\n```\n\n### Math\n\nRender LaTeX with [MathJax](https://github.com/mathjax/MathJax).\n\n```javascript\nimport { unified } from \"unified\";\nimport markdown from \"remark-parse\";\nimport math from \"remark-math\";\nimport docx from \"remark-docx\";\nimport { latexPlugin } from \"remark-docx/plugins/latex\";\n\nconst processor = unified()\n  .use(markdown)\n  .use(math)\n  .use(docx, { plugins: [latexPlugin()] });\n```\n\n### HTML\n\nTransform HTML to markdown.\n\n```javascript\nimport { unified } from \"unified\";\nimport markdown from \"remark-parse\";\nimport docx from \"remark-docx\";\nimport { htmlPlugin } from \"remark-docx/plugins/html\";\n\nconst processor = unified()\n  .use(markdown)\n  .use(docx, { plugins: [htmlPlugin()] });\n```\n\n## Documentation\n\n- [API reference](./docs/API.md)\n\n## Contribute\n\nAll contributions are welcome.\nIf you find a problem, feel free to create an [issue](https://github.com/inokawa/remark-docx/issues) or a [PR](https://github.com/inokawa/remark-docx/pulls).\n\n### Making a Pull Request\n\n1. Fork this repo.\n2. Run `npm install`.\n3. Commit your fix.\n4. Add tests to cover the fix.\n5. Make a PR and confirm all the CI checks passed.\n\n## Related projects\n\n- [remark-slate-transformer](https://github.com/inokawa/remark-slate-transformer)\n- [remark-pdf](https://github.com/inokawa/remark-pdf)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finokawa%2Fremark-docx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finokawa%2Fremark-docx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finokawa%2Fremark-docx/lists"}