1.3.24 • Published 1 year ago

twoslash-cli v1.3.24

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

Shiki Twoslash CLI

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

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.

twoslash samples/*.ts renders 

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

twoslash --sourceAlso samples/*.ts renders 

Render a few markdown files to HTML.

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.

twoslash --samples pages/example_files.md renders

Lint all the code samples in bunch of Markdown files.

twoslash --lint pages/example_files.md

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

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

Configuring Shiki Twoslash

You can specify the TwoSlashOptions 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:

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

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

This one would do the same for a TypeScript file:

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

and you can set up the codefence settings like:

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

1 year ago

1.3.22

1 year ago

1.3.23

1 year ago

1.3.21

2 years ago

1.3.19

2 years ago

1.3.20

2 years ago

1.3.18

2 years ago

1.3.17

2 years ago

1.3.15

3 years ago

1.3.16

3 years ago

1.3.14

3 years ago

1.3.13

3 years ago

1.3.12

3 years ago

1.3.10

3 years ago

1.3.7

3 years ago

1.3.6

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.3.9

3 years ago

1.3.8

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.14

3 years ago

1.2.15

3 years ago

1.2.12

3 years ago

1.2.13

3 years ago

1.2.10

3 years ago

1.2.11

3 years ago

1.2.8

3 years ago

1.2.9

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago