Parcol is a utility for parsing all Chalk methods in a string.
~(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("...")
.
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
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);
Below are some usage examples for Parcol.
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~");
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");
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.
parcol | ansi colors |
---|---|
bc |
black |
bl |
blue |
c |
cyan |
g |
green |
m |
magenta |
r |
red |
y |
yellow |
w |
white |
parcol | ansi colors |
---|---|
bcb |
blackBright |
blb |
blueBright |
cb |
cyanBright |
gb |
greenBright |
mb |
magentaBright |
rb |
redBright |
yb |
yellowBright |
wb |
whiteBright |
parcol | ansi colors |
---|---|
bgbc |
bgBlack |
bgbl |
bgBlue |
bgc |
bgCyan |
bgg |
bgGreen |
bgm |
bgMagenta |
bgr |
bgRed |
bgy |
bgYellow |
bgw |
bgWhite |
parcol | ansi colors |
---|---|
bbcb |
bgBlackBright |
bblb |
bgBlueBright |
bcb |
bgCyanBright |
bgb |
bgGreenBright |
bmb |
bgMagentaBright |
brb |
bgRedBright |
byb |
bgYellowBright |
bwb |
bgWhiteBright |
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