{"_id":"@brngdsn/unmd","name":"@brngdsn/unmd","dist-tags":{"latest":"0.2.2"},"versions":{"0.2.2":{"name":"@brngdsn/unmd","version":"0.2.2","description":"A CLI tool to unpack code fences from Markdown into files.","type":"module","bin":{"unmd":"bin/unmd.js"},"repository":{"type":"git","url":"git+https://github.com/brngdsn/unmd.git"},"scripts":{"start":"node ./bin/unmd.js"},"keywords":["markdown","extract","code-fence","unmarkdown"],"author":{"name":"brn.gdsn@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/brngdsn/unmd/issues"},"homepage":"https://github.com/brngdsn/unmd#readme","dependencies":{"markdown-it":"^13.0.1"},"_id":"@brngdsn/unmd@0.2.2","gitHead":"2fcaebd62fac048f928ad11a9e2df38645d1c9e6","_nodeVersion":"20.8.0","_npmVersion":"10.1.0","dist":{"integrity":"sha512-aH63bPmBuP3A2ZPJAIrcH6DaowDxIOBSCxSPIrYUN3fOWjt+Pn5TOnzio1fqoS/E7BmZZKWvSPvDbGEWdFYeZg==","shasum":"3717e76c0d392291da25424243cf0ab6f37b26fb","tarball":"https://registry.npmjs.org/@brngdsn/unmd/-/unmd-0.2.2.tgz","fileCount":5,"unpackedSize":7654,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD2CG1TXGyWVISexh3WJyOadFKvpKO9m+sEf+5M8S0PbQIhAK4imxUCV3hJh7hOb4TsAeKK1yUdlKMptS1yjprr7UBJ"}]},"_npmUser":{"name":"brngdsn","email":"brn.gdsn@gmail.com"},"directories":{},"maintainers":[{"name":"brngdsn","email":"brn.gdsn@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/unmd_0.2.2_1739488168671_0.6216545123440729"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-13T23:09:28.577Z","0.2.2":"2025-02-13T23:09:28.838Z","modified":"2025-02-13T23:09:29.126Z"},"maintainers":[{"name":"brngdsn","email":"brn.gdsn@gmail.com"}],"description":"A CLI tool to unpack code fences from Markdown into files.","homepage":"https://github.com/brngdsn/unmd#readme","keywords":["markdown","extract","code-fence","unmarkdown"],"repository":{"type":"git","url":"git+https://github.com/brngdsn/unmd.git"},"author":{"name":"brn.gdsn@gmail.com"},"bugs":{"url":"https://github.com/brngdsn/unmd/issues"},"license":"MIT","readme":"# unmd\n\n**unmd** is a CLI tool that extracts code fences from Markdown files and writes them to disk as files. It is especially useful when working with AI chats that generate code or entire projects in Markdown format.\n\n---\n\n## Features\n\n- **Extract Code Fences:** Scans Markdown files for fenced code blocks.\n- **File Path Detection:** Expects the first line of each code block to be a comment specifying the target file path (e.g., `// src/index.js`).\n- **Automatic Directory Creation:** Creates necessary directories if they don't already exist.\n- **Seamless Integration:** Perfect for processing Markdown outputs from AI code generators.\n\n---\n\n## Requirements\n\n- **Node.js:** v20.8.0 or later (see [`.nvmrc`](./.nvmrc))\n- **npm:** Comes with Node.js\n\n---\n\n## Installation\n\nInstall **unmd** globally using npm:\n\n```bash\nnpm install -g @brngdsn/unmd\n```\n\nAlternatively, you can run it directly using [npx](https://www.npmjs.com/package/npx):\n\n```bash\nnpx @brngdsn/unmd <markdown-file>\n```\n\n---\n\n## Usage\n\nThe CLI accepts a Markdown file as an argument and processes all code fences with a file path comment on the first line.\n\n### Markdown File Format\n\nEach code fence should start with a comment that specifies the file path, followed by the code. For example:\n\n```markdown\n# My Project\n\nHere is an example of how to define a file within Markdown:\n\n\\`\\`\\`js\n// src/index.js\nconsole.log(\"Hello, world!\");\n\\`\\`\\`\n```\n\nWhen you run **unmd** on the above Markdown, it will create a file at `src/index.js` containing:\n\n```js\nconsole.log(\"Hello, world!\");\n```\n\n### Running the Tool\n\nSimply pass the Markdown file as an argument:\n\n```bash\nunmd README.md\n```\n\nIf no file is provided, the tool will display a usage message:\n\n```bash\nUsage: unmd <markdown-file>\n```\n\n---\n\n## How It Works\n\n1. **Read File:** The tool reads the specified Markdown file.\n2. **Parse Markdown:** It uses [markdown-it](https://github.com/markdown-it/markdown-it) to parse the Markdown content.\n3. **Extract Code Fences:** It scans for fenced code blocks.\n4. **Detect File Path:** It looks for a file path in the first line of each code block (formatted as `// path/to/file.ext`).\n5. **Write Files:** It writes the remaining lines of the code block to the corresponding file, creating directories as needed.\n\n---\n\n## Contributing\n\nContributions, bug reports, and feature requests are welcome! Please open an issue or submit a pull request on the [GitHub repository](https://github.com/your-repo).\n\n---\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n---\n\n## Author\n\nbrn.gdsn@gmail.com\n\nHappy coding!","readmeFilename":"README.md"}