# twoslash-cli

> Lets you run Shiki Twoslash on arbitrary files via the terminal.

Latest version **1.3.24** (published 2023-04-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install twoslash-cli
pnpm add twoslash-cli
yarn add twoslash-cli
bun add twoslash-cli
```

Provides the commands `twoslash`, `twoslash-cli`.

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.24 |
| Published | 2023-04-28 |
| First published | 2021-05-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 7 |
| Unpacked size | 24.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Orta Therox |
| Maintainers | shiki-deploys |

## Links

- npm: https://www.npmjs.com/package/twoslash-cli
- npm.io page: https://npm.io/package/twoslash-cli

## Dependencies (7)

- [remark](https://npm.io/package/remark.md) ^13.0.0
- [chokidar](https://npm.io/package/chokidar.md) ^3.5.2
- [commander](https://npm.io/package/commander.md) ^7.2.0
- [unist-util-visit](https://npm.io/package/unist-util-visit.md) ^3.1.0
- [hast-util-to-html](https://npm.io/package/hast-util-to-html.md) ^7.1.2
- [mdast-util-to-hast](https://npm.io/package/mdast-util-to-hast.md) ^10.0.0
- [remark-shiki-twoslash](https://npm.io/package/remark-shiki-twoslash.md) 3.1.3

## Recent versions

- 1.3.24 (latest) — 2023-04-28
- 1.3.23 — 2023-03-28
- 1.3.22 — 2023-02-15
- 1.3.21 — 2022-07-01
- 1.3.20 — 2022-03-04
- 1.3.19 — 2022-03-01
- 1.3.18 — 2022-02-03
- 1.3.17 — 2021-11-29
- 1.3.16 — 2021-09-30
- 1.3.15 — 2021-09-30
- 1.3.14 — 2021-09-02
- 1.3.13 — 2021-08-13
- 1.3.12 — 2021-08-13
- 1.3.10 — 2021-08-07
- 1.3.9 — 2021-08-06
- … 28 more at https://npm.io/package/twoslash-cli/versions

## README

## Shiki Twoslash CLI

Lets you run Shiki Twoslash on arbitrary files via the terminal.


```sh
npm install -g twoslash-cli
```

```
❯ node twoslash packages/twoslash-cli/examples packages/twoslash-cli/examples/render
Twoslashifying 5 files:

  - packages/twoslash-cli/examples/another.js -> packages/twoslash-cli/examples/render/another.js.html 
  - packages/twoslash-cli/examples/basic.md -> packages/twoslash-cli/examples/render/basic.html 
  - packages/twoslash-cli/examples/file-with-settings.md -> packages/twoslash-cli/examples/render/file-with-settings.html 
  - packages/twoslash-cli/examples/single-with-settings.ts -> packages/twoslash-cli/examples/render/single-with-settings.ts.html 
  - packages/twoslash-cli/examples/single.ts -> packages/twoslash-cli/examples/render/single.ts.html 
```

#### Examples

> Take a bunch of .ts files and render them to HTML.

```sh
twoslash samples/*.ts renders 
```

> Take a bunch of .ts files and render them to HTML, but also render the source highlighted too.

```sh
twoslash --sourceAlso samples/*.ts renders 
```

> Render a few markdown files to HTML.

```sh
twoslash pages/one.md  pages/two.md build 
```

> Take a markdown file and split out each code sample into its own HTML. They get an index for a filename.

```sh
twoslash --samples pages/example_files.md renders
```

> Lint all the code samples in bunch of Markdown files.

```sh
twoslash --lint pages/example_files.md
```

> Create TSX files with a named `Code` export for a set of .ts files.

```sh
twoslash --reactAlso samples/*.ts components/twoslash 
```

#### Configuring Shiki Twoslash

You can specify the [TwoSlashOptions](https://github.com/shikijs/twoslash/tree/main/packages/shiki-twoslash#user-settings) settings for a render inside a HTML comment at the start of the file:

This markdown file would correctly render the code sample twice with each theme:

```md
<!-- twoslash: { themes: ["nord", "light-plus"]  } -->
## Hello

```ts twoslash
const a = 123
const b = 3456
```

This one would do the same for a TypeScript file:

```ts
// twoslash: { themes: ["nord", "light-plus"] }
const a = 123
const b = 3456
```

and you can set up the codefence settings like:

```ts
// twoslash: { themes: ["nord", "light-plus"] }
// highlight: {1}
const a = 123
const b = 3456
```

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