A Node.js tool to convert code blocks in a markdown file to separate coding files. This tool extracts code blocks from a markdown file, saves them to specified file paths, and supports multiple programming languages.
- Extracts code blocks from markdown files.
- Saves code blocks to specified file paths.
- Supports multiple programming languages.
- Automatically fixes linting issues and runs tests before committing using Husky and Lint-Staged.
- Publishes the package to npm when a new release is created.
-
Clone the repository:
git clone https://github.com/your-username/your-repo.git cd your-repo
-
Install dependencies:
npm install
Run the tool using the following command:
node dist/main.js --file <markdown-file> --output <output-directory>
Example:
node dist/main.js --file example.md --output output
# Example Markdown
Here is some JavaScript code:
**scripts/hello.js**:
```javascript
console.log('Hello, world!');
Here is some Python code:
scripts/hello.py:
print('Hello, world!')
## Development
### Build
To compile the TypeScript code to JavaScript:
```bash
npm run build
To run ESLint:
npm run lint
To automatically fix linting issues:
npm run lint:fix
To run the test suite:
npm test
- Fork the repository.
- Create a new branch for your feature or bugfix (
git checkout -b my-new-feature
). - Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin my-new-feature
). - Create a new Pull Request.
This project uses GitHub Actions to automatically publish the package to npm when a new release is created. Ensure you have the NPM_TOKEN
secret set up in your GitHub repository settings.
- Create a new release on GitHub.
- The GitHub Action will run tests, lint the code, and publish the package to npm.
This project is licensed under the MIT License - see the LICENSE file for details.