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: 6 months ago
JSON representation
Terminal string color for Deno
- Host: GitHub
- URL: https://github.com/fakoua/ink
- Owner: fakoua
- License: mit
- Created: 2020-01-01T21:53:55.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-07-29T14:11:31.000Z (about 3 years ago)
- Last Synced: 2025-04-17T07:16:58.339Z (6 months ago)
- Topics: ansi-colors, cli, console, css, deno, html, style, terminal, typescript
- Language: TypeScript
- Homepage:
- Size: 189 KB
- Stars: 10
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ink
Terminal string color for deno



## 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:

## String Extension
`ink` also supports string extension:
```ts
import "https://deno.land/x/ink/mod.ts" //Import .toColor() extensionconsole.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")
```

## License
[MIT](LICENSE)
[](https://app.fossa.com/projects/git%2Bgithub.com%2Ffakoua%2Fink?ref=badge_large)