logo

- Text Formatting Package in Julia 📂Julia

- Text Formatting Package in Julia

Overview

The Crayons.jl package is known for decorating text output in Julia1.

If you want to decorate using only built-in functions, you can use printstyled().

Code

using Crayons

print(Crayon(background = :red), "빨강")
print(Crayon(foreground = :blue), "파랑")
print(Crayon(bold = true), "볼드")
print(Crayon(italics = true), "이탤릭")

print(Crayon(bold = true, italics = true), "볼드 이탤릭")

Running the above console will give the following decorated result.

20211018_095539.png

Crayon(...)

  • foreground: Changes the color of the text itself. It can be given as a symbol or an integer triple (r,g,b) or as an integer between 0 and 255.
  • background: Changes the background color of the text. The method of passing arguments is the same as for foreground.

The options that can be set as booleans are as follows. In the example above, both individual and simultaneous execution results are shown.

  • bold: Bold text.
  • italics: Italic text.
  • underline: Underlined text.

Environment

  • OS: Windows
  • julia: v1.6.3