Skip to content

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.

License

Notifications You must be signed in to change notification settings

francosion042/codesnap

Repository files navigation

CodeSnap

Publish Package to npmjs npm version License: MIT PRs Welcome Downloads

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:

npm install codesnap

or

yarn add codesnap

Usage

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);
example image

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 file for details.

Credits

CodeSnap is powered by Carbon.now.sh and Puppeteer.

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published