chatgpt-markdow-to-code
v1.0.5
Published
A tool to convert code blocks in markdown files to separate coding files.
Downloads
2
Readme
Markdown to Code Converter
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.
Features
- 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.
Installation
Clone the repository:
git clone https://github.com/your-username/your-repo.git cd your-repo
Install dependencies:
npm install
Usage
Command Line
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 File
# 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
Lint
To run ESLint:
npm run lint
To automatically fix linting issues:
npm run lint:fix
Test
To run the test suite:
npm test
Contributing
- 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.
Publishing
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.
License
This project is licensed under the MIT License - see the LICENSE file for details.