With crayon it is easy to add color to terminal output, create styles for notes, warnings, errors; and combine styles.
1 2 3 4 5 6
Strings to style.
ANSI color support is automatically detected and used. Crayon was largely inspired by chalk https://github.com/chalk/chalk.
Crayon defines several styles, that can be combined. Each style in the list has a corresponding function with the same name.
blurred (usually called ‘dim’, renamed to avoid name clash)
italic (not widely supported)
strikethrough (not widely supported)
silver (usually called ‘gray’, renamed to avoid name clash)
The styling functions take any number of character vectors as arguments, and they concatenate and style them:
Crayon defines the
%+% string concatenation operator, to make it easy
to assemble stings with different styles.
Styles can be combined using the
Styles can also be nested, and then inner style takes precedence:
1 2 3 4 5
It is easy to define your own themes:
1 2 3 4 5 6
make_style() for using the 256 ANSI colors.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
cat(blue("Hello", "world!")) cat("... to highlight the " %+% red("search term") %+% " in a block of text") cat(yellow$bgMagenta$bold('Hello world!')) cat(green( 'I am a green line ' %+% blue$underline$bold('with a blue substring') %+% ' that becomes green again!' )) error <- red $ bold warn <- magenta $ underline note <- cyan cat(error("Error: subscript out of bounds!\n")) cat(warn("Warning: shorter argument was recycled.\n")) cat(note("Note: no such directory.\n"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.