format-txt

Terminal text formatting


Keywords
terminal, color, colour, format, formatting, text, ansi
License
MIT
Install
npm install format-txt@1.0.2

Documentation

Format text when printing to the terminal!

/*
 *  Examples
 */
const { logln } = require("format-txt");

logln("Text with no formatting");
logln("<red>Red text</red>");
logln("<red;ul>Underlined red text</red;ul>");
logln("<blue;ul>Underlined blue text</blue> Underlined text</ul>");
logln("--\\> <yellow>Yellow text</yellow> \\<--");

Every > or < which isn't being used for formatting must be prefixed with \\

Functions:

  • formatTxt(txt)
    Formats then returns the supplied text.
  • log(txt)
    Formats then logs the supplied text.
  • logln(txt)
    Formats then logs the supplied text with a newline.

Available formats:

Text Formats:

  • bold
  • dim
  • italic
  • underline / ul
  • flashing / flash
  • strikethrough / st

Text Colours:

  • black
  • red
  • green
  • yellow
  • blue
  • purple
  • cyan
  • white

Hight Intensity Text Colours:

  • blackH
  • redH
  • greenH
  • yellowH
  • blueH
  • purpleH
  • cyanH
  • whiteH

Background colours:

  • blackB
  • redB
  • greenB
  • yellowB
  • blueB
  • purpleB
  • cyanB
  • whiteB

High Intensity Background Colours:

  • blackHB
  • redHB
  • greenHB
  • yellowHB
  • blueHB
  • purpleHB
  • cyanHB
  • whiteHB