Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fakoua/ink

Terminal string color for Deno
https://github.com/fakoua/ink

ansi-colors cli console css deno html style terminal typescript

Last synced: 1 day ago
JSON representation

Terminal string color for Deno

Awesome Lists containing this project

README

        

# ink

Terminal string color for deno

![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/fakoua/ink?style=for-the-badge)
![GitHub](https://img.shields.io/github/license/fakoua/ink?style=for-the-badge)
![GitHub last commit](https://img.shields.io/github/last-commit/fakoua/ink?style=for-the-badge)
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/fakoua/ink/Deno%20CI?style=for-the-badge)

## Run the welcome page for interactive demo:

```bash
deno run -A https://deno.land/x/ink/welcome.ts
```

## Examples

```ts
import * as ink from 'https://deno.land/x/ink/mod.ts'

let text = ink.colorize('Hello World')
console.log(text)
```

Output:

```diff
- Hello World
```

You can use nested style:

```ts
import * as ink from 'https://deno.land/x/ink/mod.ts'

let text = ink.colorize('Hello World')

console.log(text)
```

## Support tags [Simple Mode]

- <b>: bold
- <i>: italic
- <u>: underline
- <s>: strikethrough
- <hidden>: hidden text
- <inv>: inverted color
- <dim>: dim light
- <u>: underline

- <red>: text red
- <green>: text green
- <blue>: text blue
- <yellow>: text yellow
- <magenta>: text magenta
- <cyan>: text cyan
- <white>: text white
- <black>: text black

- <bg-red>: background red
- <bg-green>: background green
- <bg-blue>: background blue
- <bg-yellow>: background yellow
- <bg-magenta>: background magenta
- <bg-cyan>: background cyan
- <bg-white>: background white
- <bg-black>: background black

## Alias to console

You can use the object terminal to call console.log, console.trace ... directly form ink module.

```ts
import * as ink from 'https://deno.land/x/ink/mod.ts'

ink.terminal.log('Hello %s', 'World')
```

## Advanced mode

You can use html like style for advanced and nested mode using the `ink` tag:

```ts
import * as ink from 'https://deno.land/x/ink/mod.ts'

let result = ink.html("Hello World")
console.log(result);
```

**ink** also supports nested styles:

```ts
let html = `

I'm Red, background Green, underlined and bold!

My BG is black again, but I'm italic :(

My BG is Green Again!

No Format here
`

let result = ink.html(html)
console.log(result);
```

Output:

![output](forgit/img01.png)

## String Extension

`ink` also supports string extension:

```ts
import "https://deno.land/x/ink/mod.ts" //Import .toColor() extension

console.log("Hello Deno".toColor())
```

### Supported Styles

- **color**: Hex Or RGB [#ff0000, rgb(0, 255, 0) ...]
- **background-color**: Hex Or RGB [#ff0000, rgb(0, 255, 0) ...]
- **font**: comma separated values [bold, dim, italic, underline, inverse, hidden, strikethrough]

## Draw Image

Ink module also can draw a JPEG image from local or remote source into the terminal:

```ts
import * as ink from "./mod.ts"

await ink.drawImage("https://placekitten.com/50/50")

```

![output](forgit/img02.png)

## License

[MIT](LICENSE)

[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Ffakoua%2Fink.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Ffakoua%2Fink?ref=badge_large)