1.0.1 • Published 4 years ago

ink.node v1.0.1

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

ink

Terminal string color for NodeJs HTML like.

Examples

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)

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.

const ink = require('ink.node')

ink.terminal.log('<red>Hello</red> %s', '<b>World</b>')

Advanced mode

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:

output

Supported Styles

License

MIT