https://github.com/francosion042/codesnap
CodeSnap is a node.js library designed to programmatically generate images of code snippets. It provides a simple and convenient way to create beautiful snapshots of your code for further automated or programmatic usage.
https://github.com/francosion042/codesnap
code-to-image image-generation nodejs npm-package
Last synced: 6 months ago
JSON representation
CodeSnap is a node.js library designed to programmatically generate images of code snippets. It provides a simple and convenient way to create beautiful snapshots of your code for further automated or programmatic usage.
- Host: GitHub
- URL: https://github.com/francosion042/codesnap
- Owner: francosion042
- License: mit
- Created: 2024-02-07T13:02:54.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-02-10T13:19:26.000Z (over 1 year ago)
- Last Synced: 2024-11-17T02:42:12.708Z (6 months ago)
- Topics: code-to-image, image-generation, nodejs, npm-package
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/codesnap
- Size: 240 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CodeSnap
[](https://github.com/francosion042/codesnap/actions/workflows/npm-publish.yml) [](https://www.npmjs.org/package/codesnap) [](https://opensource.org/licenses/MIT) [](http://makeapullrequest.com) [](https://www.npmjs.com/package/codesnap)
CodeSnap is a node.js library designed to programmatically generate images of code snippets. It provides a simple and convenient way to create beautiful snapshots of your code for further automated or programmatic usage.
## Installation
To install CodeSnap, you can use npm or yarn:
```bash
npm install codesnap
```or
```bash
yarn add codesnap
```## Usage
```javascript
import CodeSnap from "codesnap";const config = {
theme: "Monokai",
backgroundColor: "Cyan",
numberLines: true,
};const codeSnap = new CodeSnap(config);
const code = `
function greet() {
console.log('Hello, world!');
}greet();
`;codeSnap.snap(code);
```
![]()
## Configuration
The `CodeSnap` constructor accepts a configuration object with the following properties:
- `theme`: The color theme to use for the code snippet.
- `backgroundColor`: The background color of the code snippet.
- `numberLines`: (Optional) A boolean value indicating whether to display line numbers.## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Credits
CodeSnap is powered by [Carbon.now.sh](https://carbon.now.sh/) and [Puppeteer](https://github.com/puppeteer/puppeteer).