{"id":18961628,"url":"https://github.com/trialanderrororg/reoff-parse","last_synced_at":"2026-04-01T15:30:18.568Z","repository":{"id":130692372,"uuid":"607887732","full_name":"TrialAndErrorOrg/reoff-parse","owner":"TrialAndErrorOrg","description":"Plugin for [reoff][reoff] to parse a `.docx` XML file into an `ooxast` AST. ","archived":false,"fork":false,"pushed_at":"2024-06-28T18:52:26.000Z","size":10560,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-01T04:52:43.476Z","etag":null,"topics":["docx","ooxast","reoff","unified","word"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TrialAndErrorOrg.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/funding.yml","license":null,"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":"tefkah"}},"created_at":"2023-02-28T21:57:26.000Z","updated_at":"2023-03-29T19:55:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"b8222cd3-97ca-447f-b0be-8ae180345240","html_url":"https://github.com/TrialAndErrorOrg/reoff-parse","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrialAndErrorOrg%2Freoff-parse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrialAndErrorOrg%2Freoff-parse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrialAndErrorOrg%2Freoff-parse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrialAndErrorOrg%2Freoff-parse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TrialAndErrorOrg","download_url":"https://codeload.github.com/TrialAndErrorOrg/reoff-parse/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239958283,"owners_count":19724925,"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","ooxast","reoff","unified","word"],"created_at":"2024-11-08T14:13:47.611Z","updated_at":"2026-04-01T15:30:18.529Z","avatar_url":"https://github.com/TrialAndErrorOrg.png","language":"TypeScript","funding_links":["https://github.com/sponsors/tefkah"],"categories":[],"sub_categories":[],"readme":"\u003e **Note**\n\u003e This repository is automatically generated from the [main parser monorepo](https://github.com/TrialAndErrorOrg/parsers). Please submit any issues or pull requests there.\n\n# reoff-parse\n\n[![npm version](https://badge.fury.io/js/reoff-parse.svg)](https://badge.fury.io/js/reoff-parse) [![npm downloads](https://img.shields.io/npm/dm/reoff-parse.svg)](https://www.npmjs.com/package/reoff-parse)\n\nPlugin for [reoff][reoff] to parse a `.docx` XML file into an `ooxast` AST. Ideally use `docx-to-vfile` to get to a parseable state.\n\n## Contents\n\n*   [reoff-parse](#reoff-parse)\n    *   [Contents](#contents)\n    *   [What is this?](#what-is-this)\n    *   [When should I use this?](#when-should-i-use-this)\n    *   [Install](#install)\n    *   [Use](#use)\n    *   [API](#api)\n        *   [`default()`](#default)\n            *   [Signature](#signature)\n            *   [Parameters](#parameters)\n            *   [Returns](#returns)\n        *   [`Parsed`](#parsed)\n            *   [Indexable](#indexable)\n        *   [`RootWithSource`](#rootwithsource)\n            *   [Hierarchy](#hierarchy)\n            *   [Properties](#properties)\n                *   [`children`](#children)\n                *   [`data?`](#data)\n                *   [`position?`](#position)\n                *   [`source?`](#source)\n                *   [`type`](#type)\n        *   [`Settings`](#settings)\n            *   [Properties](#properties-1)\n                *   [`fragment?`](#fragment)\n                *   [`include?`](#include)\n                    *   [Default](#default-1)\n                *   [`leaveRaw?`](#leaveraw)\n                    *   [Default](#default-2)\n                *   [`removeWhiteSpace?`](#removewhitespace)\n    *   [Syntax tree](#syntax-tree)\n    *   [Compatibility](#compatibility)\n    *   [Security](#security)\n    *   [Related](#related)\n    *   [Contribute](#contribute)\n    *   [License](#license)\n\n## What is this?\n\n## When should I use this?\n\n## Install\n\nThis package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). In Node.js (version 12.20+, 14.14+, 16.0+, 18.0+), install as\n\n```bash\npnpm add reoff-parse\n# or with yarn\n# yarn add reoff-parse\n# or with npm\n# npm install reoff-parse\n```\n\n## Use\n\n```ts\nimport { unified } from 'unified'\nimport { docxToVfile } from 'docx-to-vfile'\nimport reoffParse from 'reoff-parse'\n\nconst vfile = await docxToVfile('example.docx')\n\nconst processor = unified().use(reoffParse)\n\n```\n\nParse the document into a tree\n\n```ts\nconst tree = processor.parse(vfile)\n\n```\n\n## API\n\n***\n\n### `default()`\n\n#### Signature\n\n```ts\ndefault(options: Settings = {}): void;\n```\n\n#### Parameters\n\n| Name | Type |\n| :------ | :------ |\n| `options` | [`Settings`](modules.md#settings) |\n\n#### Returns\n\n`void`\n\nDefined in:  [src/lib/reoff-parse.ts:59](https://github.com/TrialAndErrorOrg/parsers/blob/main/libs/reoff/reoff-parse/src/lib/reoff-parse.ts#L59)\n\n***\n\n### `Parsed`\n\nThe parsed content of .xml files in the .docx file\n\n#### Indexable\n\n[`key`: `XMLOrRelsString`]: `Root` | `undefined`\n\n***\n\n### `RootWithSource`\n\n#### Hierarchy\n\n*   `Root`.**RootWithSource**\n\n#### Properties\n\n##### `children`\n\n\u003e (`Cdata` | `Comment` | `Doctype` | `Element` | `Instruction` | `Text`)[]\n\nInherited from: Root.children\n\nDefined in:  node\\_modules/.pnpm/@types+xast\\@1.0.2/node\\_modules/@types/xast/index.d.ts:58\n\n##### `data?`\n\n\u003e `Data`\n\nInformation from the ecosystem.\n\nInherited from: Root.data\n\nDefined in:  node\\_modules/.pnpm/@types+unist\\@2.0.6/node\\_modules/@types/unist/index.d.ts:27\n\n##### `position?`\n\n\u003e `Position`\n\nLocation of a node in a source document.\nMust not be present if a node is generated.\n\nInherited from: Root.position\n\nDefined in:  node\\_modules/.pnpm/@types+unist\\@2.0.6/node\\_modules/@types/unist/index.d.ts:33\n\n##### `source?`\n\n\u003e `string`\n\nThe key of the file in the VFile's `data` attribute.\nUsed to identify the file in the VFile and where to put it when stringifying.\n\nDefined in:  [src/lib/reoff-parse.ts:99](https://github.com/TrialAndErrorOrg/parsers/blob/main/libs/reoff/reoff-parse/src/lib/reoff-parse.ts#L99)\n\n##### `type`\n\n\u003e `\"root\"`\n\nInherited from: Root.type\n\nDefined in:  node\\_modules/.pnpm/@types+xast\\@1.0.2/node\\_modules/@types/xast/index.d.ts:57\n\n***\n\n### `Settings`\n\n#### Properties\n\n##### `fragment?`\n\n\u003e `boolean`\n\nDefined in:  [src/lib/reoff-parse.ts:11](https://github.com/TrialAndErrorOrg/parsers/blob/main/libs/reoff/reoff-parse/src/lib/reoff-parse.ts#L11)\n\n##### `include?`\n\n\u003e `string`[] | `RegExp`[] | `\"all\"` | (`key`: `string`) =\u003e `boolean` | `\"allXML\"`\n\nWhich files on the `data` attribute of the VFile to parse and turn into `ooxast` trees.\n\n*   `allXML` parses and appends all files that end with `.xml`.\n*   `all` parses and appends all files that end with `.xml` or `.rels`.\n*   if a string array is passed, it parses and appends all files that match the strings in the array.\n*   if a regexp array is passed, it parses and appends all files that match the regexps in the array.\n*   if a function is passed, it parses and appends all files that match the function.\n\n###### Default\n\n['word/footnotes.xml', 'word/endnotes.xml', 'customXml/item1.xml', 'word/glossary/document.xml']\n\nUse of 'all' or 'allXML' is discouraged, as it will greatly increase the size of the VFile and generally be slower.\nYou can always manually parse the files you need later. For example, if you want to find out what fonts are used in the document, you can do something like this:\n\n```ts\nimport { docxToVFile } from 'docx-to-vfile'\nimport { fromXml } from 'xast-util-from-xml'\nimport { unified } from 'unified'\nimport { reoffParse } from 'reoff-parse'\n\nconst file = await docxToVFile(docx)\n\nconst processor = unified()\n .use(reoffParse)\n .use(() =\u003e (tree, vfile) =\u003e {\n   const fontTable = fromXml(vfile.data['word/fontTable.xml'])\n   // do something with the fontTable\n\n   return tree\n })\n```\n\nDefined in:  [src/lib/reoff-parse.ts:56](https://github.com/TrialAndErrorOrg/parsers/blob/main/libs/reoff/reoff-parse/src/lib/reoff-parse.ts#L56)\n\n##### `leaveRaw?`\n\n\u003e `boolean`\n\nWhether to leave the raw XML on the data attribute of the VFile.\nThe raw XML is not needed in most cases, but can be useful for debugging.\n\nBy default, all XML files that match the include option are parsed and added to the `data.parsed` attribute of the VFile.\nAll XML are then removed from the VFile.\n\n###### Default\n\nfalse\n\nDefined in:  [src/lib/reoff-parse.ts:22](https://github.com/TrialAndErrorOrg/parsers/blob/main/libs/reoff/reoff-parse/src/lib/reoff-parse.ts#L22)\n\n##### `removeWhiteSpace?`\n\n\u003e `boolean`\n\nDefined in:  [src/lib/reoff-parse.ts:10](https://github.com/TrialAndErrorOrg/parsers/blob/main/libs/reoff/reoff-parse/src/lib/reoff-parse.ts#L10)\n\n## Syntax tree\n\n`reoff-parse` creates an `[ooxast][ooxast]` syntax tree, which is a subset of the `[xast][xast]` syntax tree specifically for Open Office XML files.\n\n## Compatibility\n\n`reoff-parse` parses everything in the `.docx` file in a rather naive way, so most things (except for scripts) are \"supported.\" However, by default only the footnotes, endnotes, customXML and glossary are parsed and therefore easy to use by plugins such as `[reoff-unified-latex][reoff-unified-latex]`.\nIf you want to use other parts of the `.docx` file, such as the `styles`, you can use the `include` option to parse and add them to the VFile.\n\nNote that all parts of the `.docx` file are included as a raw XML string in the VFile using the default settings of `docx-to-vfile`, so you can always parse them yourself using `xast-util-from-xml`, see the documentation of `Settings` above.\n\n## Security\n\n`reoff-parse` does not parse scripts, but in the future it will be able to be converted into HTML using `[ooxast-util-to-hast][ooxast-util-to-hast]`, which might allow for XSS attacks.\nUse `[rehype-raw][rehype-raw]` to be certain that no raw HTML is present in the output when converting to HTML.\n\n## Related\n\n*   [xast-util-from-xml][xast-util-from-xml]: tool used to convert XML to `[xast][xast]`\n*   [docx-to-vfile][docx-to-vfile]: tool used to convert `.docx` files to VFiles which can be fed into `reoff-parse`\n\n## Contribute\n\n## License\n\n[GPL-3.0-or-later](LICENSE) © Thomas F. K. Jorna\n\n[unified]: https://unifiedjs.com\n\n[unifiedgh]: https://github.com/unifiedjs/unified\n\n[xast-util-from-xml]: https://github.com/syntax-tree/xast-util-from-xml\n\n[rehype]: https://github.com/rehypejs/rehype\n\n[rejour]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour\n\n[rejour-parse]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour/rejour-parse\n\n[rejour-stringify]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour/rejour-stringify\n\n[rejour-move-abstract]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour/rejour-move-abstract\n\n[rejour-meta]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour/rejour-meta\n\n[rejour-relatex]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour/rejour-relatex\n\n[relatex]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/relatex\n\n[reoff-parse]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/relatex/reoff-parse\n\n[jast]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour/jast\n\n[jast-util-to-texast]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour/jast-util-to-texast\n\n[jastscript]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour/jastscript\n\n[texast]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/relatex/texast\n\n[texast-util-to-latex]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/relatex/texast-util-to-latex\n\n[hast]: https://github.com/syntax-tree/hast\n\n[xast]: https://github.com/syntax-tree/xast\n\n[mdast]: https://github.com/syntax-tree/mdast\n\n[mdast-markdown]: https://github.com/syntax-tree/mdast-util-to-markdown\n\n[latex-utensils]: https://github.com/tamuratak/latex-utensils\n\n[latexjs]: https://github.com/latexjs/latexjs\n\n[reoff]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/reoff\n\n[reoff-parse]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/reoff/reoff-parse\n\n[reoff-rejour]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/reoff/reoff-rejour\n\n[ooxast]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/ooxast/ooxast\n\n[ooxast-util-to-jast]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/ooxast/ooxast-util-to-jast\n\n[ooxast-util-to-hast]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/ooxast/ooxast-util-to-hast\n\n[rehype-raw]: https://github.com/rehypejs/rehype-raw\n\n[reoff-unifed-latex]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/reoff/reoff-unified-latex\n\n[docx-to-vfile]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/reoff/docx-to-vfile\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrialanderrororg%2Freoff-parse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrialanderrororg%2Freoff-parse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrialanderrororg%2Freoff-parse/lists"}