{"_id":"@acdvorak/myst-to-docx","_rev":"2-c1252c10f65d89fe342b3aba553f0309","name":"@acdvorak/myst-to-docx","dist-tags":{"latest":"1.0.14"},"versions":{"1.0.12":{"name":"@acdvorak/myst-to-docx","version":"1.0.12","keywords":["myst-plugin","docx","word","export"],"author":{"name":"Rowan Cockett","email":"rowan@curvenote.com"},"license":"MIT","_id":"@acdvorak/myst-to-docx@1.0.12","maintainers":[{"name":"acdvorak","email":"acdvorak@gmail.com"}],"homepage":"https://github.com/acdvorak/mystmd/tree/feat/docx-upgrade","bugs":{"url":"https://github.com/jupyter-book/mystmd/issues"},"dist":{"shasum":"687fe213fa9e44f58bca83994d49e6466830ca51","tarball":"https://registry.npmjs.org/@acdvorak/myst-to-docx/-/myst-to-docx-1.0.12.tgz","fileCount":23,"integrity":"sha512-v/YQ4Djj+Zvp9ZhOtTeA+weFCff4ZYUghSq1TRojQVybCjF5sXlM1ykfky2VD3cRgwkUSPfXclywT4nSZlna3w==","signatures":[{"sig":"MEYCIQCNRa0xcBBzo+FljxV8mV7e0Az6CJx+fN+pba0iNE9OpgIhAIThLbMJz3vTNDQXYpOnAUuAvatzbtVqt7JHRmHuCF+M","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":50132},"type":"module","types":"./dist/index.d.ts","exports":"./dist/index.js","gitHead":"1b5712a5c8a2e866a309c97eecd2ef043e8b45a2","scripts":{"lint":"eslint \"src/**/*.ts\" -c .eslintrc.cjs","test":"vitest run","build":"npm-run-all -l clean -p build:dts build:js","clean":"rimraf dist","build:js":"esbuild src/index.ts --bundle --outfile=dist/index.js --platform=node --external:fsevents --loader:.node=binary --target=node14","build:dts":"tsc","test:watch":"vitest watch","lint:format":"prettier --check \"src/**/*.ts\""},"_npmUser":{"name":"acdvorak","email":"acdvorak@gmail.com"},"repository":{"url":"git+https://github.com/acdvorak/mystmd.git","type":"git"},"_npmVersion":"10.7.0","description":"Export from a MyST Markdown document to Microsoft Word (*.docx)","directories":{},"_nodeVersion":"20.15.1","dependencies":{"docx":"^9.0.3","myst-spec":"^0.0.5","image-size":"^1.1.1","myst-common":"^1.7.2","myst-spec-ext":"^1.7.2","@resvg/resvg-js":"^2.6.2","myst-frontmatter":"^1.7.2","unist-util-select":"^4.0.3"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/myst-to-docx_1.0.12_1731474724241_0.7206528946489752","host":"s3://npm-registry-packages"}},"1.0.13":{"name":"@acdvorak/myst-to-docx","version":"1.0.13","keywords":["myst-plugin","docx","word","export"],"author":{"name":"Rowan Cockett","email":"rowan@curvenote.com"},"license":"MIT","_id":"@acdvorak/myst-to-docx@1.0.13","maintainers":[{"name":"acdvorak","email":"acdvorak@gmail.com"}],"homepage":"https://github.com/acdvorak/mystmd/tree/feat/docx-upgrade","bugs":{"url":"https://github.com/jupyter-book/mystmd/issues"},"dist":{"shasum":"a6098c419d7e44a82c86ca518c4512c176c50535","tarball":"https://registry.npmjs.org/@acdvorak/myst-to-docx/-/myst-to-docx-1.0.13.tgz","fileCount":23,"integrity":"sha512-CwVFLMbLySLuQoEmvHe8Azz4u8l1hw+06jcN9eUF7SCGF3OqAoVDojoJVvqHFz7bynBH/v97O+chNxWnUUdksw==","signatures":[{"sig":"MEYCIQDx1UIxkwSLgeZZ8NxpwyuShiWgyJcyH3WIvxvWeO9oSwIhAPlBmvMjuAH+sOkASdxdsTg5+/did4LyM/fyYdFD3Ors","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":50228},"type":"module","types":"./dist/index.d.ts","exports":"./dist/index.js","gitHead":"1b5712a5c8a2e866a309c97eecd2ef043e8b45a2","scripts":{"lint":"eslint \"src/**/*.ts\" -c .eslintrc.cjs","test":"vitest run","build":"npm-run-all -l clean -p build:dts build:js","clean":"rimraf dist","build:js":"esbuild src/index.ts --bundle --outfile=dist/index.js --platform=node --external:fsevents --loader:.node=binary --target=node14","build:dts":"tsc","test:watch":"vitest watch","lint:format":"prettier --check \"src/**/*.ts\""},"_npmUser":{"name":"acdvorak","email":"acdvorak@gmail.com"},"repository":{"url":"git+https://github.com/acdvorak/mystmd.git","type":"git"},"_npmVersion":"10.7.0","description":"Export from a MyST Markdown document to Microsoft Word (*.docx)","directories":{},"_nodeVersion":"20.15.1","dependencies":{"docx":"^9.0.3","myst-spec":"^0.0.5","image-size":"^1.1.1","myst-common":"^1.7.2","myst-spec-ext":"^1.7.2","@resvg/resvg-js":"^2.6.2","myst-frontmatter":"^1.7.2","unist-util-select":"^4.0.3"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/myst-to-docx_1.0.13_1731475231251_0.6901075688644693","host":"s3://npm-registry-packages"}},"1.0.14":{"name":"@acdvorak/myst-to-docx","version":"1.0.14","description":"Export from a MyST Markdown document to Microsoft Word (*.docx)","author":{"name":"Rowan Cockett","email":"rowan@curvenote.com"},"license":"MIT","type":"module","exports":"./dist/index.js","types":"./dist/index.d.ts","keywords":["myst-plugin","docx","word","export"],"repository":{"type":"git","url":"git+https://github.com/acdvorak/mystmd.git"},"bugs":{"url":"https://github.com/jupyter-book/mystmd/issues"},"homepage":"https://github.com/acdvorak/mystmd/tree/feat/docx-upgrade","scripts":{"clean":"rimraf dist","lint":"eslint \"src/**/*.ts\" -c .eslintrc.cjs","lint:format":"prettier --check \"src/**/*.ts\"","test":"vitest run","test:watch":"vitest watch","build:esm":"tsc","build":"npm-run-all -l clean -p build:esm"},"dependencies":{"docx":"^9.0.3","image-size":"^1.1.1","myst-common":"^1.7.2","myst-frontmatter":"^1.7.2","myst-spec":"^0.0.5","myst-spec-ext":"^1.7.2","unist-util-select":"^4.0.3"},"_id":"@acdvorak/myst-to-docx@1.0.14","gitHead":"f058c906b403160516819a46f755147178c2b343","_nodeVersion":"20.15.1","_npmVersion":"10.7.0","dist":{"integrity":"sha512-hERctFJ5gp5dvSdDdJ7cJO8VFPdLD8DPkiQka+UIIpmjtOdkege66Sdgy3lV3q52Ou/capUL2yXcRh1QyLK6jw==","shasum":"02cdd1b9172e09e590c355842a9bca3b205d2cb5","tarball":"https://registry.npmjs.org/@acdvorak/myst-to-docx/-/myst-to-docx-1.0.14.tgz","fileCount":23,"unpackedSize":51154,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCJxktgqkr4wkHqSEqYIcVKdcWK1XgTi29JbG6xBDHezwIhAN91EGxI/DFQQGXPPhtryEz64klWukPgSHqBphWX9H15"}]},"_npmUser":{"name":"acdvorak","email":"acdvorak@gmail.com"},"directories":{},"maintainers":[{"name":"acdvorak","email":"acdvorak@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/myst-to-docx_1.0.14_1731514570121_0.33607723946374346"},"_hasShrinkwrap":false}},"time":{"created":"2024-11-13T05:12:04.141Z","modified":"2024-11-13T16:16:10.575Z","1.0.12":"2024-11-13T05:12:04.439Z","1.0.13":"2024-11-13T05:20:31.497Z","1.0.14":"2024-11-13T16:16:10.373Z"},"bugs":{"url":"https://github.com/jupyter-book/mystmd/issues"},"author":{"name":"Rowan Cockett","email":"rowan@curvenote.com"},"license":"MIT","homepage":"https://github.com/acdvorak/mystmd/tree/feat/docx-upgrade","keywords":["myst-plugin","docx","word","export"],"repository":{"type":"git","url":"git+https://github.com/acdvorak/mystmd.git"},"description":"Export from a MyST Markdown document to Microsoft Word (*.docx)","maintainers":[{"name":"acdvorak","email":"acdvorak@gmail.com"}],"readme":"# `myst-to-docx`\n\nExport a MyST document to a Microsoft Word file, using [docx](https://docx.js.org/).\n\n## Overview\n\n`myst-to-docx` has a `DocxSerializer` object that you write to as you walk the MyST document. It is a light wrapper around <https://docx.js.org/>, which actually does the export. `myst-to-docx` is write only (i.e. can export to, but can’t read from `*.docx`), and has all standard MyST nodes covered (see below).\n\n`myst-to-docx` can be used in the browser or in node. This library currently only has dependence on `docx`, `myst-frontmatter` and `buffer-image-size` - and the serialization handlers can be edited externally (see `Extended Usage` below).\n\nThe AST should be transformed through `myst-transforms` to ensure that all nodes are enumerated.\n\n## Basic usage in browser\n\nThe utility `fetchImagesAsBuffers` walks the AST and downloads images into buffers to be used by docx, it also figures out the size and returns an object with `getImageBuffer` and `getImageDimensions`, which need to be passed to the options. If your images are more complex (e.g. they are mermaid diagrams, or Jupyter Outputs), you will need to do more complex preprocessing to create these two functions.\n\nA `Blob` is returned, which can be downloaded client side.\n\n```typescript\nimport { unified } from 'unified';\nimport { mystToDocx, fetchImagesAsBuffers, DocxResult } from 'myst-to-docx';\n\nconst opts = await fetchImagesAsBuffers(tree);\nconst file = unified().use(mystToDocx, opts).stringify(tree);\nconst blob = await (file.result as DocxResult);\n```\n\n## Basic usage in node\n\nIn node, the image dimensions are discovered using a node-only package, and don't need to be provided. The result of the conversion in node is a `Buffer` as the `file.result`, which can be saved to disk.\n\n```typescript\nimport { unified } from 'unified';\nimport { mystToDocx, DocxResult } from 'myst-to-docx';\n\nconst file = unified()\n  .use(mystToDocx, {\n    getImageBuffer(url) {\n      return fs.readFileSync(url).buffer;\n    };\n  })\n  .stringify(tree);\nconst buffer = await (file.result as DocxResult);\n```\n\n## Extended usage\n\nInstead of using the `defaultDocxSerializer` you can override or provide cusome serializers.\n\n```ts\nimport { DocxSerializer, defaultNodes, defaultMarks } from 'myst-to-docx';\n\nconst nodeSerializer = {\n  ...defaultNodes,\n  my_paragraph(state, node) {\n    state.renderInline(node);\n    state.closeBlock(node);\n  },\n};\n\nexport const myDocxSerializer = new DocxSerializer(nodeSerializer, defaultMarks);\n```\n\nThe `state` is the `DocxSerializerState` and has helper methods to interact with `docx`.\n\n## Supported Block Nodes\n\n- text\n- link\n- paragraph\n- heading (levels)\n  - Including numbering of headings\n- blockquote\n- code\n  - TODO: No styles supported\n- thematicBreak\n- break\n- list\n- listItem\n- image\n- math\n  - Including numbering\n- inlineMath\n- crossReference\n- abbreviation\n- block\n- definitionList\n- definitionTerm\n- definitionDescription\n- container\n- caption\n- captionNumber\n- tables\n\n## Supported Style Nodes\n\n- emphasis\n- strong\n- inlineCode\n- subscript\n- superscript\n- delete (strikethrough)\n- underline\n- smallcaps\n\n## Resources\n\n- [docx](https://docx.js.org/)\n- [myst-spec](https://github.com/jupyter-book/myst-spec)\n","readmeFilename":"README.md"}