{"id":20962999,"url":"https://github.com/doesdev/docxmarks","last_synced_at":"2025-05-14T08:34:42.920Z","repository":{"id":57143011,"uuid":"42411480","full_name":"doesdev/docxmarks","owner":"doesdev","description":"Super simple bookmark replacement / mail merge for docx files","archived":false,"fork":false,"pushed_at":"2024-04-29T17:54:48.000Z","size":189,"stargazers_count":8,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-22T02:21:53.763Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/doesdev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2015-09-13T20:22:08.000Z","updated_at":"2024-04-29T17:54:52.000Z","dependencies_parsed_at":"2024-04-29T19:09:10.990Z","dependency_job_id":null,"html_url":"https://github.com/doesdev/docxmarks","commit_stats":null,"previous_names":["musocrat/docxmarks"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doesdev%2Fdocxmarks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doesdev%2Fdocxmarks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doesdev%2Fdocxmarks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doesdev%2Fdocxmarks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doesdev","download_url":"https://codeload.github.com/doesdev/docxmarks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254105138,"owners_count":22015598,"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":"2024-11-19T02:40:10.803Z","updated_at":"2025-05-14T08:34:42.611Z","avatar_url":"https://github.com/doesdev.png","language":"JavaScript","readme":"# docxmarks   [![npm version](https://badge.fury.io/js/docxmarks.svg)](http://badge.fury.io/js/docxmarks)   [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)   [![Dependency Status](https://dependencyci.com/github/doesdev/docxmarks/badge)](https://dependencyci.com/github/doesdev/docxmarks)\n\nReplace text in native bookmarks in Open XML Document Files (.docx).\n\nFormatting will follow the initial style inside the bookmark. That is to say,\nif you have content inside the bookmark the first character defines the styling.\nThis is the same behavior supplied in Microsoft Word's libraries.\n\nThis library exclusively manages text and includes optional functionality for adjusting the font size of bookmarks.\n\n\nI say all of that to say if you need more advanced formatting and content\noptions then you should be using\n[docxtemplater](https://github.com/open-xml-templating/docxtemplater).\n\n## Install\n`npm i docxmarks --save`\n\n## Usage\n\n```javascript\nconst docxmarks = require('docxmarks')\nconst fs = require('fs')\nconst docx = fs.readFileSync('path/to/document.docx')\n\nconst replacements = {\n  first: 'Andrew',\n  last: (val) =\u003e val || 'Carpenter',\n  maybeNoBookmark: {append: true, setter: 'There is one now'}\n}\n\n// 11 is the font size for bookamrks which is opitional\nconst font = 11;\n\ndocxmarks(docx, replacements, font).then((data) =\u003e {\n  fs.writeFileSync('path/to/newDocument.docx', data)\n})\n```\n\n## API\n\n#### Takes docx data, replaces bookmarks, returns `Promise` resolving with new docx data in the same encoding as provided in input.\n\n** omitting `replacements` will resolve with an object describing bookmarks currently in the document*\n\n#### `docxmarks(*docxData, *replacements)`\n\n- **docxData** *[base64 | Buffer | ArrayBuffer | Uint8Array - required]*\n- **replacements** *[object - optional]*\n  - **key** - Name of bookmark to replace, is case sensitive\n  - **value** *[string | function | object]* - Bookmark replacement value\n    - **string** - Replace bookmark with string's value\n    - **function** - Receives current text of bookmark, bookmark set with return value\n    - **object** - {`*setter`, `*append`}\n      - **setter** *[string | function - required]* same as string / function above\n      - **append** *[boolean - optional - false]* if bookmark not found append to document\n\n\n## Upgrading\n\nVersion 2.0.0 is a complete re-write with 100% different API. Use new API if\nupgrading from an old version, as there is no transitional API.\n\n\n## License\n\nMIT © [Andrew Carpenter](https://github.com/doesdev)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoesdev%2Fdocxmarks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoesdev%2Fdocxmarks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoesdev%2Fdocxmarks/lists"}