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.
To install CodeSnap, you can use npm or yarn:
npm install codesnap
or
yarn add codesnap
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);
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.
This project is licensed under the MIT License - see the LICENSE file for details.
CodeSnap is powered by Carbon.now.sh and Puppeteer.