Terminal string color for NodeJs HTML like.
const ink = require('ink.node')
let text = ink.colorize('<red>Hello World</red>')
console.log(text)
Output:
- Hello World
You can use nested style:
const ink = require('ink.node')
let text = ink.colorize('<bg-blue><red>Hello World</bg-blue></red>')
console.log(text)
-
<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
You can use the object terminal to call console.log, console.trace ... directly form ink module.
const ink = require('ink.node')
ink.terminal.log('<red>Hello</red> %s', '<b>World</b>')
You can use html like style for advanced and nested mode using the ink
tag:
const ink = require('ink.node')let result = ink.html("<ink style='color: #ff0000;font:bold;'>Hello World</ink>")
console.log(result);
Ink also supports nested styles:
let html = `
<ink style="color: rgb(255, 0, 0); background-color: #00ff00;font: underline, bold">
I'm Red, background Green, underlined and bold!
<ink style="background-color: rgb(0, 0, 0); font: italic;">
My BG is black again, but I'm italic :(
</ink>
My BG is Green Again!
</ink>
No Format here
`
let result = ink.html(html)
console.log(result);
Output:
- 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]