GithubHelp home page GithubHelp logo

ansistyles's Introduction

Ansistyles

Functions that surround a string with ansistyle codes so it prints in style.

In case you need colors, like red, have a look at ansicolors.

Usage

var styles = require('ansistyles');

console.log(styles.bright('hello world'));    // prints hello world in 'bright' white
console.log(styles.underline('hello world')); // prints hello world underlined
console.log(styles.inverse('hello world'));   // prints hello world black on white

Combining with ansicolors

var styles = require('ansistyles')
  , colors = require('ansicolors');

  console.log(
    // prints hello world underlined in blue on a green background
    colors.bgGreen(colors.blue(styles.underline('hello world'))) 
  );

Tests

Look at the tests to see more examples and/or run them via:

js test/ansistyles.js

More Styles

As you can see from here, more styles are available, but didn't have any effect on the terminals that I tested on Mac Lion and Ubuntu Linux.

I included them for completeness, but didn't show them in the examples because they seem to have no effect.

reset

A style reset function is also included, please note however that this is not nestable.

Therefore the below only underlines hell only, but not world.

console.log(styles.underline('hell' + styles.reset('o') + ' world'));

It is essentially the same as:

console.log(styles.underline('hell') + styles.reset('') + 'o world');

ansistyles's People

Contributors

ngot avatar thlorenz avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.