# carbon-now

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

Latest version **1.0.0** (published 2023-07-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install carbon-now
pnpm add carbon-now
yarn add carbon-now
bun add carbon-now
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2023-07-10 |
| First published | 2023-07-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 17.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | cedriking |
| Maintainers | cedriking |

## Links

- npm: https://www.npmjs.com/package/carbon-now
- npm.io page: https://npm.io/package/carbon-now

## Dependencies (2)

- [fs-extra](https://npm.io/package/fs-extra.md) ^11.1.1
- [puppeteer](https://npm.io/package/puppeteer.md) ^20.8.0

## Recent versions

- 1.0.0 (latest) — 2023-07-10

## README

# Carbon API

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

![result.png](./result.png)

## Options

| Name            | Type    | Default | Description                                                           |
| --------------- | ------- | ------- | --------------------------------------------------------------------- |
| lang            | string  | auto    | Language to use for syntax highlighting.                              |
| theme           | string  | dracula | Theme to use for the code.                                            |
| font            | string  | Hack    | Font to use for the code.                                             |
| windowControls  | boolean | true    | Whether to show window buttons on top of the window                   |
| widthAdjustment | boolean | true    | Whether to adjust the width of the code to its content                |
| lineNumbers     | boolean | true    | Whether to show line numbers on the left of the code                  |
| firstLineNumber | number  | 1       | The number to start counting lines from                               |
| watermark       | boolean | false   | Whether to show the Carbon watermark on the bottom right of the image |
| fontSize        | number  | 18      | The font size to use for the code                                     |
| lineHeight      | number  | 169     | The line height to use for the code                                   |
| exportSize      | number  | 2       | The pixel density to export the image at                              |

## Usage

```js
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](https://carbon.now.sh/). It is not affiliated with [Carbon](https://carbon.now.sh/) in any way.
- Check all the available themes, langs and fonts [here](./src/types.ts).

---
_Source: https://npm.io/package/carbon-now · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
