HTML-style color tags using Chalk
  • TypeScript 100%
Find a file
2025-01-19 11:06:29 +01:00
.gitignore Init 2025-01-16 11:18:32 +01:00
.npmignore Add benchmarking, improve perf & comments 2025-01-19 10:49:54 +01:00
benchmark.ts Add benchmarking, improve perf & comments 2025-01-19 10:49:54 +01:00
bun.lockb Add benchmarking, improve perf & comments 2025-01-19 10:49:54 +01:00
color.test.ts Add benchmarking, improve perf & comments 2025-01-19 10:49:54 +01:00
index.ts Use switch statement for special tags 2025-01-19 11:06:29 +01:00
LICENSE Init 2025-01-16 11:18:32 +01:00
package.json 1.1.3 2025-01-19 11:00:24 +01:00
README.md Rename functions 2025-01-16 11:31:38 +01:00

Chalk Tags

This is a collection of functions that allows parsing HTML-style color tags.

import { parseTags, stopTagParsing, resumeTagParsing, applyTagsToConsole } from "chalk-tags";

console.log(parseTags("<red>Red text</red> Normal Text")); // (In red)Red text(In white) Normal Text

stopTagParsing();
console.log(parseTags("<red>Red text</red> Normal Text")); // <red>Red text</red> Normal Text

resumeTagParsing();
console.log(parseTags("<red>Red text</red> Normal Text")); // (In red)Red text(In white) Normal Text

console.log("<red>Red text</red> Normal Text"); // <red>Red text</red> Normal Text
applyTagsToConsole();
console.log("<red>Red text</red> Normal Text"); // (In red)Red text(In white) Normal Text

// Output is what you would expect.
console.log("<red bg:blue bold>Red and bold on blue background</bg> Red and Bold</bold> Red</red>");
console.log("<#FF0000 bg:#0000FF>Red on blue background</> White on black background");

// Look in the documentation for `parseTags` for a more detailed explanation and a list of the tags.

The npm package is here. Made with chalk ❤️