R语言cli——ansi_html_style():对ansi_html()的结果设置CSS格式

Package cli version 3.6.0


Usage

ansi_html_style(
  colors = TRUE,
  palette = c("vscode", "dichro", "vga", "winxp", "win10", "macos", "putty", "mirc",
    "xterm", "ubuntu", "eclipse", "iterm", "iterm-pastel", "iterm-smoooooth",
    "iterm-snazzy", "iterm-solarized", "iterm-tango")
)

Arguments

参数【colors】:是否包含颜色。FALSE将不包括颜色,TRUE或8将包括8种颜色(加上它们的明亮变体),256将包括256种颜色。

参数【palette】:字符标量,用于前八种颜色及其明亮变体的调色板。终端对这些颜色的定义不同,cli包含了几个示例。调色板的来源:

  • https://en.wikipedia.org/wiki/ANSI_escape_code#3-bit_and_4-bit

  • iTerm2 builtin palettes

  • https://github.com/sindresorhus/iterm2-snazzy


Value

CSS声明块的命名列表,其中的名称是CSS选择器。它具有format()和print()方法,您可以使用这两个方法将输出写入CSS或HTML文件。


Examples

> ansi_html_style(colors = FALSE)
.ansi-bold       { font-weight: bold;             }
.ansi-italic     { font-style: italic;            }
.ansi-underline  { text-decoration: underline;    }
.ansi-blink      { text-decoration: blink;        }
.ansi-hide       { visibility: hidden;            }
.ansi-crossedout { text-decoration: line-through; }
.ansi-link:hover { text-decoration: underline;    }
> ansi_html_style(colors = 8, palette = "iterm-snazzy")
.ansi-bold        { font-weight: bold;             }
.ansi-italic      { font-style: italic;            }
.ansi-underline   { text-decoration: underline;    }
.ansi-blink       { text-decoration: blink;        }
.ansi-hide        { visibility: hidden;            }
.ansi-crossedout  { text-decoration: line-through; }
.ansi-link:hover  { text-decoration: underline;    }
.ansi-color-0     { color: #000000 }
.ansi-color-1     { color: #ff5c57 }
.ansi-color-2     { color: #5af78e }
.ansi-color-3     { color: #f3f99d }
.ansi-color-4     { color: #57c7ff }
.ansi-color-5     { color: #ff6ac1 }
.ansi-color-6     { color: #9aedfe }
.ansi-color-7     { color: #f1f1f0 }
.ansi-color-8     { color: #686868 }
.ansi-color-9     { color: #ff5c57 }
.ansi-color-10    { color: #5af78e }
.ansi-color-11    { color: #f3f99d }
.ansi-color-12    { color: #57c7ff }
.ansi-color-13    { color: #ff6ac1 }
.ansi-color-14    { color: #9aedfe }
.ansi-color-15    { color: #f1f1f0 }
.ansi-bg-color-0  { background-color: #000000 }
.ansi-bg-color-1  { background-color: #ff5c57 }
.ansi-bg-color-2  { background-color: #5af78e }
.ansi-bg-color-3  { background-color: #f3f99d }
.ansi-bg-color-4  { background-color: #57c7ff }
.ansi-bg-color-5  { background-color: #ff6ac1 }
.ansi-bg-color-6  { background-color: #9aedfe }
.ansi-bg-color-7  { background-color: #f1f1f0 }
.ansi-bg-color-8  { background-color: #686868 }
.ansi-bg-color-9  { background-color: #ff5c57 }
.ansi-bg-color-10 { background-color: #5af78e }
.ansi-bg-color-11 { background-color: #f3f99d }
.ansi-bg-color-12 { background-color: #57c7ff }
.ansi-bg-color-13 { background-color: #ff6ac1 }
.ansi-bg-color-14 { background-color: #9aedfe }
.ansi-bg-color-15 { background-color: #f1f1f0 }