Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

carbon-now

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

carbon-now

Create beautiful images of your source code thanks to Carbon API. Typescript and Javascript support.

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Carbon API

Create beautiful images of your source code thanks to Carbon API. Typescript and Javascript support.

result.png

Options

NameTypeDefaultDescription
langstringautoLanguage to use for syntax highlighting.
themestringdraculaTheme to use for the code.
fontstringHackFont to use for the code.
windowControlsbooleantrueWhether to show window buttons on top of the window
widthAdjustmentbooleantrueWhether to adjust the width of the code to its content
lineNumbersbooleantrueWhether to show line numbers on the left of the code
firstLineNumbernumber1The number to start counting lines from
watermarkbooleanfalseWhether to show the Carbon watermark on the bottom right of the image
fontSizenumber18The font size to use for the code
lineHeightnumber169The line height to use for the code
exportSizenumber2The pixel density to export the image at

Usage

import { Carbon } from 'carbon-now';

const carbon = new Carbon({
  lang: 'javascript',
});

async () => {
  const code = `console.log('Hello world!');`;

  const imagePath = await carbon.generate(code, 'image.png');
  // imagePath = /path/to/image.png
};

Notes

  • This is an unofficial API for Carbon. It is not affiliated with Carbon in any way.
  • Check all the available themes, langs and fonts here.

FAQs

Package last updated on 10 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts