Package?cli?version 3.6.0
Usage
ansi_html(x, escape_reserved = TRUE, csi = c("drop", "keep"))
Arguments
參數(shù)【x】:輸入字符向量。
參數(shù)【escape_reserved】:是否轉(zhuǎn)義HTML中保留的字符(&、<和>)。
參數(shù)【csi】:如何處理非sgr ANSI序列,要么“keep”,要么“drop”它們。文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-813311.html
Value
字符向量的HTML。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-813311.html
Example
code <- withr::with_options(
list(ansi.num_colors = 256),
code_highlight(format(ansi_html))
)
hcode <- paste(ansi_html(code), collapse = "\n")
css <- paste(format(ansi_html_style()), collapse= "\n")
page <- htmltools::tagList(
htmltools::tags$head(htmltools::tags$style(css)),
htmltools::tags$pre(htmltools::HTML(hcode))
)
if (interactive()) htmltools::html_print(page)
function (x, escape_reserved = TRUE, csi = c("drop", "keep"))
{
if (!is.character(x))
x <- as.character(x)
csi <- match.arg(csi)
x <- enc2utf8(x)
if (escape_reserved) {
x <- gsub_("&", "&", x, fixed = TRUE, useBytes = TRUE)
x <- gsub_("<", "<", x, fixed = TRUE, useBytes = TRUE)
x <- gsub_(">", ">", x, fixed = TRUE, useBytes = TRUE)
}
.Call(clic_ansi_html, x, csi == "keep")
}
到了這里,關(guān)于R語(yǔ)言【cli】——ansi_html():將ANSI格式文本轉(zhuǎn)換為HTML的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!