parcol
TypeScript icon, indicating that this package has built-in type declarations

0.1.5 • Public • Published

Parcol Parse ANSI Colors

Parcol is a utility for parsing all Chalk methods in a string.

Table of Contents


Syntax

~(color_key) (your_text)~

We refer to the text enclosed between ~ ~ as parcol. Instead of the color key in the syntax above, you can find a table of color key methods converted to Parcol keys below ANSI colors.

The simplest usage example is bl for blue. So when you type ~bl ...~, Parcol will convert your code to c.blue("...").


Installation

You can install Parcol into your project using your package manager like npm, yarn, pnpm, etc. Below is an example using Yarn.

yarn add parcol

Usage

The following code demonstrates how Parcol converts text to specific ANSI colors. It will convert the text "blue" to c.blue("blue"), so the blue text will remain blue while other texts will not be modified.

import parcol from "parcol";

const my_text = "this is a ~bl blue~ message";

parcol.pit(my_text);

Examples

Below are some usage examples for Parcol.

Using Parcol Multiple Times in a String

It is possible to use Parcol multiple times in a single string expression.

import parcol from "parcol";

parcol.pit("~y hi~ ~r red~, my favorite color is ~bl blue~ but I also love ~m purple~");

Using Multiple Methods

To apply more than one method, separate them with a comma (,). Here is an example using bl,d:

import parcol from "parcol";

// It sets the text to both blue and dim (bl,d).
parcol.pit("this is a ~bl,d blue~ message", "and this is ~d dim~ text");

All Color Keys

You can find all Parcol color keys below. The tables consist of two columns: the first column lists the color keys available in Parcol, and the second column shows the corresponding method names in ANSI colors.

Basic Colors

parcol ansi colors
bc black
bl blue
c cyan
g green
m magenta
r red
y yellow
w white

Bright (Hightlight) Colors

parcol ansi colors
bcb blackBright
blb blueBright
cb cyanBright
gb greenBright
mb magentaBright
rb redBright
yb yellowBright
wb whiteBright

Background Colors

parcol ansi colors
bgbc bgBlack
bgbl bgBlue
bgc bgCyan
bgg bgGreen
bgm bgMagenta
bgr bgRed
bgy bgYellow
bgw bgWhite

Bright Background Colors

parcol ansi colors
bbcb bgBlackBright
bblb bgBlueBright
bcb bgCyanBright
bgb bgGreenBright
bmb bgMagentaBright
brb bgRedBright
byb bgYellowBright
bwb bgWhiteBright

Modifiers

parcol ansi colors
b bold
d dim
h hidden
in inverse
it italic
l terminalLink
o overline
rs reset
st strikethrough
u underline
v visible
hex hex
rgb rgb
ans ansi256
bgans bgAnsi256
bghex hex background
bgrgb rgb background

LICENSE : MIT

Package Sidebar

Install

npm i parcol

Weekly Downloads

18

Version

0.1.5

License

MIT

Unpacked Size

15.2 kB

Total Files

5

Last publish

Collaborators

  • ahmetcanisik