{"_id":"@proto-kit/remark-code-import","_rev":"2-38608799c8e7e698decc078cf99bccd4","name":"@proto-kit/remark-code-import","dist-tags":{"latest":"1.2.1"},"versions":{"1.2.0":{"name":"@proto-kit/remark-code-import","version":"1.2.0","keywords":["remark","remark-plugin","markdown","code-block","code-fence","file-system","import-code","gatsby","gatsby-plugin"],"author":{"name":"Protokit & Kai Hao"},"license":"MIT","_id":"@proto-kit/remark-code-import@1.2.0","maintainers":[{"name":"rpanic","email":"raphael.panic@gmx.at"},{"name":"maht0rz","email":"matej.sima@gmail.com"}],"homepage":"https://github.com/kevin940726/remark-code-import#readme","bugs":{"url":"https://github.com/kevin940726/remark-code-import/issues"},"dist":{"shasum":"e88fa7ed3b3290b6d958ce0e0f2ea8b3ae8a6b5a","tarball":"https://registry.npmjs.org/@proto-kit/remark-code-import/-/remark-code-import-1.2.0.tgz","fileCount":7,"integrity":"sha512-kyI4V+hDCA60x5B2DBudyHtATE5UPguXfUgCRt7CGJm3dEHqqUBA3Eqv+5K9N/3+SacfnJaAdrJcz8VFmjltAA==","signatures":[{"sig":"MEYCIQD5xVAani24XnVY+nMOkRjee9Ak0F+sjK2QCaJSeZIDdgIhANlvWWxhpEMSPCcEGhm+LRyPHB2qjaE/kQvuH7H/7n0r","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12256},"main":"index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">= 12"},"exports":"./dist/index.js","gitHead":"fb69d322f5878abe12b95b9e1cec952afb9cd7b8","scripts":{"test":"vitest","build":"tsc","prepare":"npm run build && npm test -- run","publish":"npm publish --access public"},"_npmUser":{"name":"rpanic","email":"raphael.panic@gmx.at"},"prettier":{"singleQuote":true,"trailingComma":"es5"},"repository":{"url":"git+https://github.com/kevin940726/remark-code-import.git","type":"git"},"_npmVersion":"10.8.3","description":"📝 Populate code blocks from files","directories":{"test":"test"},"_nodeVersion":"22.9.0","dependencies":{"strip-indent":"^4.0.0","unist-util-visit":"^4.1.0","to-gatsby-remark-plugin":"^0.1.0"},"_hasShrinkwrap":false,"devDependencies":{"mdast":"^3.0.0","vfile":"^5.3.0","remark":"^14.0.2","vitest":"^0.31.0","prettier":"2.5.1","typescript":"4.4.4"},"_npmOperationalInternal":{"tmp":"tmp/remark-code-import_1.2.0_1768688797855_0.670338017658805","host":"s3://npm-registry-packages-npm-production"}},"1.2.1":{"name":"@proto-kit/remark-code-import","description":"📝 Populate code blocks from files","version":"1.2.1","engines":{"node":">= 12"},"type":"module","exports":"./dist/index.js","types":"./dist/index.d.ts","author":{"name":"Protokit & Kai Hao"},"license":"MIT","homepage":"https://github.com/kevin940726/remark-code-import#readme","repository":{"type":"git","url":"git+https://github.com/kevin940726/remark-code-import.git"},"keywords":["remark","remark-plugin","markdown","code-block","code-fence","file-system","import-code","gatsby","gatsby-plugin"],"scripts":{"build":"tsc","test":"vitest","prepare":"npm run build && npm test -- run","publish":"npm publish --access public"},"dependencies":{"strip-indent":"^4.0.0","to-gatsby-remark-plugin":"^0.1.0","unist-util-visit":"^4.1.0"},"devDependencies":{"mdast":"^3.0.0","prettier":"2.5.1","remark":"^14.0.2","typescript":"4.4.4","vfile":"^5.3.0","vitest":"^0.31.0"},"prettier":{"singleQuote":true,"trailingComma":"es5"},"main":"index.js","directories":{"test":"test"},"bugs":{"url":"https://github.com/kevin940726/remark-code-import/issues"},"_id":"@proto-kit/remark-code-import@1.2.1","gitHead":"9d658f8ec88c8b1a7afecd8b4b65540c68c1eaab","_nodeVersion":"22.9.0","_npmVersion":"10.8.3","dist":{"integrity":"sha512-UJIpAu7zhNx5uNCygtGMzwe93XyQe1ywPL/y9SCtPyrOLSOn+9XAufkrJp1Qm27jS6VGyk3ypGmoLCGNXA8LGg==","shasum":"07000613761b70da2bb3229e4214dd347d3b44fe","tarball":"https://registry.npmjs.org/@proto-kit/remark-code-import/-/remark-code-import-1.2.1.tgz","fileCount":7,"unpackedSize":12508,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIC1l6dFCijqjZ4laoNwb4g7o+didkEZIVXe+A9hsKAV9AiBWDrWzAR4b53zIRfOoH7+dDpQR9AK2aMPrNbUPMAtmnw=="}]},"_npmUser":{"name":"rpanic","email":"raphael.panic@gmx.at"},"maintainers":[{"name":"rpanic","email":"raphael.panic@gmx.at"},{"name":"maht0rz","email":"matej.sima@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/remark-code-import_1.2.1_1777924503430_0.9824472250290628"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-17T22:26:37.673Z","modified":"2026-05-04T19:55:03.689Z","1.2.0":"2026-01-17T22:26:37.973Z","1.2.1":"2026-05-04T19:55:03.569Z"},"bugs":{"url":"https://github.com/kevin940726/remark-code-import/issues"},"author":{"name":"Protokit & Kai Hao"},"license":"MIT","homepage":"https://github.com/kevin940726/remark-code-import#readme","keywords":["remark","remark-plugin","markdown","code-block","code-fence","file-system","import-code","gatsby","gatsby-plugin"],"repository":{"type":"git","url":"git+https://github.com/kevin940726/remark-code-import.git"},"description":"📝 Populate code blocks from files","maintainers":[{"name":"rpanic","email":"raphael.panic@gmx.at"},{"name":"maht0rz","email":"matej.sima@gmail.com"}],"readme":"# `remark-code-import`\n\n📝 Populate code blocks from files.\n\n[![npm version](https://badge.fury.io/js/remark-code-import.svg)](https://badge.fury.io/js/remark-code-import)\n\n**Starting from v1.0.0, the plugin is now [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). Node 12+ is needed to use it and it must be `import`ed instead of `require`d.**\n\n## Installation\n\n```sh\nnpm install -D @proto-kit/remark-code-import\n```\n\n## Setup\n\nThe plugin can be imported via named export, there's no default export.\n\n```js\nimport codeImport from 'remark-code-import';\n```\n\nSee [**Using plugins**](https://github.com/remarkjs/remark/blob/master/doc/plugins.md#using-plugins) for more instructions in the official documentation.\n\nIt can also be used in various of libraries: `remark`: [MDX](https://mdxjs.com/advanced/plugins#using-remark-and-rehype-plugins), [Gatsby `gatsby-plugin-mdx`](https://www.gatsbyjs.org/docs/mdx/plugins/#remark-plugins), [Storybook docs](https://github.com/storybookjs/storybook/tree/master/addons/docs#manual-configuration).\n\n## Usage\n\nTransform:\n\n````md\n```js file=./say-hi.js\n```\n````\n\ninto:\n\n````md\n```js file=./say-hi.js\nconsole.log('Hello remark-code-import!');\n```\n````\n\nThe file path is relative to the markdown file path. You can use `<rootDir>` at the start of the path to import files relatively from the [`rootDir`](#options):\n\n````md\n```js file=<rootDir>/file-under-root-directory.js\n```\n````\n\nYou may also specify lines or ranges:\n\n````md\nOnly line 3:\n```js file=./say-hi.js#L3\n```\n\nLine 3 to line 6:\n```js file=./say-hi.js#L3-L6\n```\n\nLine 3 to the end of the file\n```js file=./say-hi.js#L3-\n```\n````\n\nFile paths with spaces should be escaped with `\\`:\n\n````md\n```js file=./file\\ with\\ spaces.js\n```\n````\n\n## Options\n\n- `async: boolean`: By default, this plugin uses `readFileSync` to read the contents of the files. Set this to `true` if you want to use `readFile` for non-blocking IO.\n- `rootDir: string`: Change what `<rootDir>` refers to. Defaults to `process.cwd()`.\n- `preserveTrailingNewline: boolean`: By default, this plugin will trim the trailing newline of the file when importing the code. You can preserve the trailing new line in the code block by setting this option to `true`.\n- `removeRedundantIndentations: boolean`: Set to `true` to remove redundant indentations for each line. For instance, the imported code of:\n  ```\n    First line\n      Second line\n  ```\n  will become...\n  ```\n  First line\n    Second line\n  ```\n- `allowImportingFromOutside: boolean`: For security reasons, by default this plugin doesn't allow importing files from outside the root directory (`rootDir`). Set this option to `true` to bypass this limit.\n\n## Use as a Gatsby remark plugin\n\nUse the `/gatsby` endpoint. It's possible through [`to-gatsby-remark-plugin`](https://github.com/kevin940726/to-gatsby-remark-plugin).\n\n```js\n{\n  resolve: 'remark-code-import/gatsby',\n  options: {}\n}\n```\n\n## Testing\n\nAfter installing dependencies with `npm install`, the tests can be run with: `npm test`\n\n## License\n\nKai Hao\n[MIT](LICENSE)\n","readmeFilename":"README.md"}