How to use ansi-styles - 10 common examples

To help you get started, we’ve selected a few ansi-styles examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github trabus / markdown-it-terminal / index.js View on Github external
module.exports = function terminal_plugin(md,options) {
  var defaultOptions = {
    styleOptions: {
      code: styles.yellow,
      blockquote: terminal.compoundStyle(['gray','italic']),
      html: styles.gray,
      heading: terminal.compoundStyle(['green','bold']),
      firstHeading: terminal.compoundStyle(['magenta','underline','bold']),
      hr: styles.reset,
      listitem: styles.reset,
      table: styles.reset,
      paragraph: styles.reset,
      strong: styles.bold,
      em: styles.italic,
      codespan: styles.yellow,
      del: terminal.compoundStyle(['dim','gray','strikethrough']),
      link: styles.blue,
      href: terminal.compoundStyle(['blue','underline'])
    },
    unescape: true
  };

  var opts = merge(defaultOptions, options);
  terminal(md,opts);
  // console.log(styles)
};
github ant-design / ant-design / scripts / sort-api-table.js View on Github external
.then(() => {
    /* eslint-disable no-console */
    console.log(`${style.green.open}sort ant-design api successfully!${style.green.close}`);
    /* eslint-enable no-console */
  });
github kubesail / deploy-node-app / index.js View on Github external
const DNA_VERSION = '0.0.1'
const USAGE = '[env]'

const homedir = require('os').homedir()
const path = require('path')
// eslint-disable-next-line security/detect-child-process
const execSync = require('child_process').execSync
const getKubesailConfig = require('get-kubesail-config')
const inquirer = require('inquirer')
inquirer.registerPrompt('fuzzypath', require('inquirer-fuzzy-path'))
const fs = require('fs')
const program = require('commander')
const yaml = require('js-yaml')
const style = require('ansi-styles')
const errArrows = `${style.red.open}>>${style.red.close}`
const warning = `${style.green.open}!!${style.green.close}`

const NEW_KUBESAIL_CONTEXT = `KubeSail${style.gray.open} | Deploy on a free Kubernetes namespace${
  style.gray.close
}`
const KUBESAIL_REGISTRY = 'registry.kubesail.io'
const KUBE_CONFIG_PATH = path.join(homedir, '.kube', 'config')

const execToStdout = { stdio: [process.stdin, process.stdout, process.stderr] }

function fatal (message /*: string */) {
  process.stderr.write(`${errArrows} ${message}\n`)
  process.exit(1)
}

const packageJsonPath = 'package.json'
github tecfu / tty-table / dist / tty-table.devel.js View on Github external
var escapeStringRegexp = require('escape-string-regexp');
var ansiStyles = require('ansi-styles');
var stripAnsi = require('strip-ansi');
var hasAnsi = require('has-ansi');
var supportsColor = require('supports-color');
var defineProps = Object.defineProperties;
var isSimpleWindowsTerm = process.platform === 'win32' && !/^xterm/i.test(process.env.TERM);

function Chalk(options) {
	// detect mode if not set manually
	this.enabled = !options || options.enabled === undefined ? supportsColor : options.enabled;
}

// use bright blue on Windows as the normal blue color is illegible
if (isSimpleWindowsTerm) {
	ansiStyles.blue.open = '\u001b[94m';
}

var styles = (function () {
	var ret = {};

	Object.keys(ansiStyles).forEach(function (key) {
		ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');

		ret[key] = {
			get: function () {
				return build.call(this, this._styles.concat(key));
			}
		};
	});

	return ret;
github hitext / hitext / src / printer / tty.js View on Github external
return style.reduce((result, name) => {
        switch (true) {
            case name in styles.color:
                result.color = styles.color[name].open;
                break;

            case name in styles.bgColor:
                result.bgColor = styles.bgColor[name].open;
                break;

            case name === 'reset':
                result.color = '\u001B[39m';
                result.bgColor = '\u001B[49m';
                break;

            // default:
            //     console.error('Unknown modifier:', name);
        }
github hitext / hitext / src / printer / tty.js View on Github external
return style.reduce((result, name) => {
        switch (true) {
            case name in styles.color:
                result.color = styles.color[name].open;
                break;

            case name in styles.bgColor:
                result.bgColor = styles.bgColor[name].open;
                break;

            case name === 'reset':
                result.color = '\u001B[39m';
                result.bgColor = '\u001B[49m';
                break;

            // default:
            //     console.error('Unknown modifier:', name);
        }

        return result;
    }, {});
}
github trabus / markdown-it-terminal / index.js View on Github external
module.exports = function terminal_plugin(md,options) {
  var defaultOptions = {
    styleOptions: {
      code: styles.yellow,
      blockquote: terminal.compoundStyle(['gray','italic']),
      html: styles.gray,
      heading: terminal.compoundStyle(['green','bold']),
      firstHeading: terminal.compoundStyle(['magenta','underline','bold']),
      hr: styles.reset,
      listitem: styles.reset,
      table: styles.reset,
      paragraph: styles.reset,
      strong: styles.bold,
      em: styles.italic,
      codespan: styles.yellow,
      del: terminal.compoundStyle(['dim','gray','strikethrough']),
      link: styles.blue,
      href: terminal.compoundStyle(['blue','underline'])
    },
    unescape: true
  };

  var opts = merge(defaultOptions, options);
  terminal(md,opts);
  // console.log(styles)
};
github trabus / markdown-it-terminal / index.js View on Github external
module.exports = function terminal_plugin(md,options) {
  var defaultOptions = {
    styleOptions: {
      code: styles.yellow,
      blockquote: terminal.compoundStyle(['gray','italic']),
      html: styles.gray,
      heading: terminal.compoundStyle(['green','bold']),
      firstHeading: terminal.compoundStyle(['magenta','underline','bold']),
      hr: styles.reset,
      listitem: styles.reset,
      table: styles.reset,
      paragraph: styles.reset,
      strong: styles.bold,
      em: styles.italic,
      codespan: styles.yellow,
      del: terminal.compoundStyle(['dim','gray','strikethrough']),
      link: styles.blue,
      href: terminal.compoundStyle(['blue','underline'])
    },
    unescape: true
  };

  var opts = merge(defaultOptions, options);
  terminal(md,opts);
  // console.log(styles)
github trabus / markdown-it-terminal / index.js View on Github external
module.exports = function terminal_plugin(md,options) {
  var defaultOptions = {
    styleOptions: {
      code: styles.yellow,
      blockquote: terminal.compoundStyle(['gray','italic']),
      html: styles.gray,
      heading: terminal.compoundStyle(['green','bold']),
      firstHeading: terminal.compoundStyle(['magenta','underline','bold']),
      hr: styles.reset,
      listitem: styles.reset,
      table: styles.reset,
      paragraph: styles.reset,
      strong: styles.bold,
      em: styles.italic,
      codespan: styles.yellow,
      del: terminal.compoundStyle(['dim','gray','strikethrough']),
      link: styles.blue,
      href: terminal.compoundStyle(['blue','underline'])
    },
    unescape: true
  };

  var opts = merge(defaultOptions, options);
  terminal(md,opts);
  // console.log(styles)
};
github trabus / markdown-it-terminal / index.js View on Github external
module.exports = function terminal_plugin(md,options) {
  var defaultOptions = {
    styleOptions: {
      code: styles.yellow,
      blockquote: terminal.compoundStyle(['gray','italic']),
      html: styles.gray,
      heading: terminal.compoundStyle(['green','bold']),
      firstHeading: terminal.compoundStyle(['magenta','underline','bold']),
      hr: styles.reset,
      listitem: styles.reset,
      table: styles.reset,
      paragraph: styles.reset,
      strong: styles.bold,
      em: styles.italic,
      codespan: styles.yellow,
      del: terminal.compoundStyle(['dim','gray','strikethrough']),
      link: styles.blue,
      href: terminal.compoundStyle(['blue','underline'])
    },
    unescape: true
  };

  var opts = merge(defaultOptions, options);
  terminal(md,opts);
  // console.log(styles)
};