Skip to content

Latest commit

 

History

History
69 lines (45 loc) · 1.99 KB

README.md

File metadata and controls

69 lines (45 loc) · 1.99 KB

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.