glue/ 0000755 0001762 0000144 00000000000 14547351404 011215 5 ustar ligges users glue/NAMESPACE 0000644 0001762 0000144 00000001155 14404775364 012445 0 ustar ligges users # Generated by roxygen2: do not edit by hand
S3method("+",glue)
S3method("[",glue)
S3method("[[",glue)
S3method(as.character,glue)
S3method(as_glue,character)
S3method(as_glue,default)
S3method(as_glue,glue)
S3method(print,glue)
export(as_glue)
export(backtick)
export(double_quote)
export(glue)
export(glue_col)
export(glue_collapse)
export(glue_data)
export(glue_data_col)
export(glue_data_safe)
export(glue_data_sql)
export(glue_safe)
export(glue_sql)
export(glue_sql_collapse)
export(identity_transformer)
export(single_quote)
export(trim)
importFrom(methods,setOldClass)
useDynLib(glue,glue_)
useDynLib(glue,trim_)
glue/LICENSE 0000644 0001762 0000144 00000000052 14540666266 012227 0 ustar ligges users YEAR: 2023
COPYRIGHT HOLDER: glue authors
glue/.aspell/ 0000755 0001762 0000144 00000000000 14152560265 012552 5 ustar ligges users glue/.aspell/defaults.R 0000644 0001762 0000144 00000000231 14152560265 014500 0 ustar ligges users Rd_files <- vignettes <- R_files <- description <-
list(encoding = "UTF-8",
language = "en",
dictionaries = c("en_stats", "glue"))
glue/.aspell/glue.rds 0000644 0001762 0000144 00000000070 14152560265 014215 0 ustar ligges users b```b`fab`b2Hs'e |]c( glue/README.md 0000644 0001762 0000144 00000020347 14540666461 012507 0 ustar ligges users
# glue
[](https://cran.r-project.org/package=glue)
[](https://github.com/tidyverse/glue/actions/workflows/R-CMD-check.yaml)
[](https://github.com/tidyverse/glue/actions/workflows/test-coverage.yaml)
## Overview
Glue offers interpreted string literals that are small, fast, and
dependency-free. Glue does this by embedding R expressions in curly
braces which are then evaluated and inserted into the argument string.
## Installation
``` r
# Install released version from CRAN
install.packages("glue")
```
``` r
# Install development version from GitHub
pak::pak("tidyverse/glue")
```
## Usage
##### Variables can be passed directly into strings.
``` r
library(glue)
name <- "Fred"
glue('My name is {name}.')
#> My name is Fred.
```
Note that `glue::glue()` is also made available via
`stringr::str_glue()`. So if you’ve already attached stringr (or perhaps
the whole tidyverse), you can access `glue()` like so:
``` r
library(stringr) # or library(tidyverse)
stringr_fcn <- "`stringr::str_glue()`"
glue_fcn <- "`glue::glue()`"
str_glue('{stringr_fcn} is essentially an alias for {glue_fcn}.')
#> `stringr::str_glue()` is essentially an alias for `glue::glue()`.
```
##### Long strings are broken by line and concatenated together.
``` r
library(glue)
name <- "Fred"
age <- 50
anniversary <- as.Date("1991-10-12")
glue('My name is {name},',
' my age next year is {age + 1},',
' my anniversary is {format(anniversary, "%A, %B %d, %Y")}.')
#> My name is Fred, my age next year is 51, my anniversary is Saturday, October 12, 1991.
```
##### Named arguments are used to assign temporary variables.
``` r
glue('My name is {name},',
' my age next year is {age + 1},',
' my anniversary is {format(anniversary, "%A, %B %d, %Y")}.',
name = "Joe",
age = 40,
anniversary = as.Date("2001-10-12"))
#> My name is Joe, my age next year is 41, my anniversary is Friday, October 12, 2001.
```
##### `glue_data()` is useful with [magrittr](https://cran.r-project.org/package=magrittr) pipes.
``` r
`%>%` <- magrittr::`%>%`
head(mtcars) %>% glue_data("{rownames(.)} has {hp} hp")
#> Mazda RX4 has 110 hp
#> Mazda RX4 Wag has 110 hp
#> Datsun 710 has 93 hp
#> Hornet 4 Drive has 110 hp
#> Hornet Sportabout has 175 hp
#> Valiant has 105 hp
```
##### `glue()` is useful within dplyr pipelines
``` r
library(dplyr)
head(iris) %>%
mutate(description = glue("This {Species} has a petal length of {Petal.Length}"))
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 5.1 3.5 1.4 0.2 setosa
#> 2 4.9 3.0 1.4 0.2 setosa
#> 3 4.7 3.2 1.3 0.2 setosa
#> 4 4.6 3.1 1.5 0.2 setosa
#> 5 5.0 3.6 1.4 0.2 setosa
#> 6 5.4 3.9 1.7 0.4 setosa
#> description
#> 1 This setosa has a petal length of 1.4
#> 2 This setosa has a petal length of 1.4
#> 3 This setosa has a petal length of 1.3
#> 4 This setosa has a petal length of 1.5
#> 5 This setosa has a petal length of 1.4
#> 6 This setosa has a petal length of 1.7
```
##### Leading whitespace and blank lines from the first and last lines are automatically trimmed.
This lets you indent the strings naturally in code.
``` r
glue("
A formatted string
Can have multiple lines
with additional indention preserved
")
#> A formatted string
#> Can have multiple lines
#> with additional indention preserved
```
##### An additional newline can be used if you want a leading or trailing newline.
``` r
glue("
leading or trailing newlines can be added explicitly
")
#>
#> leading or trailing newlines can be added explicitly
```
##### `\\` at the end of a line continues it without a new line.
``` r
glue("
A formatted string \\
can also be on a \\
single line
")
#> A formatted string can also be on a single line
```
##### A literal brace is inserted by using doubled braces.
``` r
name <- "Fred"
glue("My name is {name}, not {{name}}.")
#> My name is Fred, not {name}.
```
##### Alternative delimiters can be specified with `.open` and `.close`.
``` r
one <- "1"
glue("The value of $e^{2\\pi i}$ is $<>$.", .open = "<<", .close = ">>")
#> The value of $e^{2\pi i}$ is $1$.
```
##### All valid R code works in expressions, including braces and escaping.
Backslashes do need to be doubled just like in all R strings.
``` r
`foo}\`` <- "foo"
glue("{
{
'}\\'' # { and } in comments, single quotes
\"}\\\"\" # or double quotes are ignored
`foo}\\`` # as are { in backticks
}
}")
#> foo
```
##### `glue_sql()` makes constructing SQL statements safe and easy
Use backticks to quote identifiers, normal strings and numbers are
quoted appropriately for your backend.
``` r
library(glue)
con <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
colnames(iris) <- gsub("[.]", "_", tolower(colnames(iris)))
DBI::dbWriteTable(con, "iris", iris)
var <- "sepal_width"
tbl <- "iris"
num <- 2
val <- "setosa"
glue_sql("
SELECT {`var`}
FROM {`tbl`}
WHERE {`tbl`}.sepal_length > {num}
AND {`tbl`}.species = {val}
", .con = con)
#> SELECT `sepal_width`
#> FROM `iris`
#> WHERE `iris`.sepal_length > 2
#> AND `iris`.species = 'setosa'
# `glue_sql()` can be used in conjunction with parameterized queries using
# `DBI::dbBind()` to provide protection for SQL Injection attacks
sql <- glue_sql("
SELECT {`var`}
FROM {`tbl`}
WHERE {`tbl`}.sepal_length > ?
", .con = con)
query <- DBI::dbSendQuery(con, sql)
DBI::dbBind(query, list(num))
DBI::dbFetch(query, n = 4)
#> sepal_width
#> 1 3.5
#> 2 3.0
#> 3 3.2
#> 4 3.1
DBI::dbClearResult(query)
# `glue_sql()` can be used to build up more complex queries with
# interchangeable sub queries. It returns `DBI::SQL()` objects which are
# properly protected from quoting.
sub_query <- glue_sql("
SELECT *
FROM {`tbl`}
", .con = con)
glue_sql("
SELECT s.{`var`}
FROM ({sub_query}) AS s
", .con = con)
#> SELECT s.`sepal_width`
#> FROM (SELECT *
#> FROM `iris`) AS s
# If you want to input multiple values for use in SQL IN statements put `*`
# at the end of the value and the values will be collapsed and quoted appropriately.
glue_sql("SELECT * FROM {`tbl`} WHERE sepal_length IN ({vals*})",
vals = 1, .con = con)
#> SELECT * FROM `iris` WHERE sepal_length IN (1)
glue_sql("SELECT * FROM {`tbl`} WHERE sepal_length IN ({vals*})",
vals = 1:5, .con = con)
#> SELECT * FROM `iris` WHERE sepal_length IN (1, 2, 3, 4, 5)
glue_sql("SELECT * FROM {`tbl`} WHERE species IN ({vals*})",
vals = "setosa", .con = con)
#> SELECT * FROM `iris` WHERE species IN ('setosa')
glue_sql("SELECT * FROM {`tbl`} WHERE species IN ({vals*})",
vals = c("setosa", "versicolor"), .con = con)
#> SELECT * FROM `iris` WHERE species IN ('setosa', 'versicolor')
```
# Other implementations
Some other implementations of string interpolation in R (although not
using identical syntax).
- [stringr::str_interp](https://stringr.tidyverse.org/reference/str_interp.html)
- [R.utils::gstring](https://cran.r-project.org/package=R.utils)
- [rprintf](https://cran.r-project.org/package=rprintf)
String templating is closely related to string interpolation, although
not exactly the same concept. Some packages implementing string
templating in R include.
- [whisker](https://cran.r-project.org/package=whisker)
- [brew](https://cran.r-project.org/package=brew)
- [jinjar](https://cran.r-project.org/package=jinjar)
## Code of Conduct
Please note that the glue project is released with a [Contributor Code
of Conduct](https://glue.tidyverse.org/CODE_OF_CONDUCT.html). By
contributing to this project, you agree to abide by its terms.
glue/man/ 0000755 0001762 0000144 00000000000 14541066114 011763 5 ustar ligges users glue/man/glue-deprecated.Rd 0000644 0001762 0000144 00000000446 14152560265 015314 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/glue.R
\name{glue-deprecated}
\alias{glue-deprecated}
\title{Deprecated Functions}
\description{
These functions are Deprecated in this release of glue, they will be removed
in a future version.
}
\keyword{internal}
glue/man/glue_safe.Rd 0000644 0001762 0000144 00000003405 14503407331 014204 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/safe.R
\name{glue_safe}
\alias{glue_safe}
\alias{glue_data_safe}
\title{Safely interpolate strings}
\usage{
glue_safe(..., .envir = parent.frame())
glue_data_safe(.x, ..., .envir = parent.frame())
}
\arguments{
\item{...}{[\code{expressions}]\cr Unnamed arguments are taken to be expression
string(s) to format. Multiple inputs are concatenated together before formatting.
Named arguments are taken to be temporary variables available for substitution.
\if{html}{\out{}}\preformatted{For `glue_data()`, elements in `...` override the values in `.x`.
}\if{html}{\out{
}}}
\item{.envir}{[\code{environment}: \code{parent.frame()}]\cr Environment to evaluate each expression in. Expressions are
evaluated from left to right. If \code{.x} is an environment, the expressions are
evaluated in that environment and \code{.envir} is ignored. If \code{NULL} is passed, it is equivalent to \code{\link[=emptyenv]{emptyenv()}}.}
\item{.x}{[\code{listish}]\cr An environment, list, or data frame used to lookup values.}
}
\value{
A glue object, as created by \code{\link[=as_glue]{as_glue()}}.
}
\description{
\code{glue_safe()} and \code{glue_data_safe()} differ from \code{\link[=glue]{glue()}} and \code{\link[=glue_data]{glue_data()}}
in that the safe versions only look up symbols from an environment using
\code{\link[=get]{get()}}. They do not execute any R code. This makes them suitable for use
with untrusted input, such as inputs in a Shiny application, where using the
normal functions would allow an attacker to execute arbitrary code.
}
\examples{
"1 + 1" <- 5
# glue actually executes the code
glue("{1 + 1}")
# glue_safe just looks up the value
glue_safe("{1 + 1}")
rm("1 + 1")
}
glue/man/identity_transformer.Rd 0000644 0001762 0000144 00000001136 14531745332 016533 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/transformer.R
\name{identity_transformer}
\alias{identity_transformer}
\title{Parse and Evaluate R code}
\usage{
identity_transformer(text, envir = parent.frame())
}
\arguments{
\item{text}{Text (typically) R code to parse and evaluate.}
\item{envir}{environment to evaluate the code in}
}
\description{
This is a simple wrapper around \code{eval(parse())}, used as the default
transformer.
}
\seealso{
\code{vignette("transformers", "glue")} for documentation on creating
custom glue transformers and some common use cases.
}
glue/man/as_glue.Rd 0000644 0001762 0000144 00000001306 14503407331 013667 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/glue.R
\name{as_glue}
\alias{as_glue}
\title{Coerce object to glue}
\usage{
as_glue(x, ...)
}
\arguments{
\item{x}{object to be coerced.}
\item{...}{further arguments passed to methods.}
}
\value{
A character vector with S3 class \code{"glue"}.
}
\description{
A glue object is a character vector with S3 class \code{"glue"}. The \code{"glue"}
class implements a print method that shows the literal contents (rather than
the string implementation) and a \code{+} method, so that you can concatenate with
the addition operator.
}
\examples{
x <- as_glue(c("abc", "\"\\\\\\\\", "\n"))
x
x <- 1
y <- 3
glue("x + y") + " = {x + y}"
}
glue/man/glue.Rd 0000644 0001762 0000144 00000011711 14531745332 013214 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/glue.R
\name{glue}
\alias{glue}
\alias{glue_data}
\title{Format and interpolate a string}
\usage{
glue_data(
.x,
...,
.sep = "",
.envir = parent.frame(),
.open = "{",
.close = "}",
.na = "NA",
.null = character(),
.comment = "#",
.literal = FALSE,
.transformer = identity_transformer,
.trim = TRUE
)
glue(
...,
.sep = "",
.envir = parent.frame(),
.open = "{",
.close = "}",
.na = "NA",
.null = character(),
.comment = "#",
.literal = FALSE,
.transformer = identity_transformer,
.trim = TRUE
)
}
\arguments{
\item{.x}{[\code{listish}]\cr An environment, list, or data frame used to lookup values.}
\item{...}{[\code{expressions}]\cr Unnamed arguments are taken to be expression
string(s) to format. Multiple inputs are concatenated together before formatting.
Named arguments are taken to be temporary variables available for substitution.
\if{html}{\out{}}\preformatted{For `glue_data()`, elements in `...` override the values in `.x`.
}\if{html}{\out{
}}}
\item{.sep}{[\code{character(1)}: \sQuote{""}]\cr Separator used to separate elements.}
\item{.envir}{[\code{environment}: \code{parent.frame()}]\cr Environment to evaluate each expression in. Expressions are
evaluated from left to right. If \code{.x} is an environment, the expressions are
evaluated in that environment and \code{.envir} is ignored. If \code{NULL} is passed, it is equivalent to \code{\link[=emptyenv]{emptyenv()}}.}
\item{.open}{[\code{character(1)}: \sQuote{\\\{}]\cr The opening delimiter. Doubling the
full delimiter escapes it.}
\item{.close}{[\code{character(1)}: \sQuote{\\\}}]\cr The closing delimiter. Doubling the
full delimiter escapes it.}
\item{.na}{[\code{character(1)}: \sQuote{NA}]\cr Value to replace \code{NA} values
with. If \code{NULL} missing values are propagated, that is an \code{NA} result will
cause \code{NA} output. Otherwise the value is replaced by the value of \code{.na}.}
\item{.null}{[\code{character(1)}: \sQuote{character()}]\cr Value to replace
NULL values with. If \code{character()} whole output is \code{character()}. If
\code{NULL} all NULL values are dropped (as in \code{paste0()}). Otherwise the
value is replaced by the value of \code{.null}.}
\item{.comment}{[\code{character(1)}: \sQuote{#}]\cr Value to use as the comment
character.}
\item{.literal}{[\code{boolean(1)}: \sQuote{FALSE}]\cr Whether to treat single or
double quotes, backticks, and comments as regular characters (vs. as
syntactic elements), when parsing the expression string. Setting \code{.literal = TRUE} probably only makes sense in combination with a custom
\code{.transformer}, as is the case with \code{glue_col()}. Regard this argument
(especially, its name) as experimental.}
\item{.transformer}{[\verb{function]}\cr A function taking two arguments, \code{text}
and \code{envir}, where \code{text} is the unparsed string inside the glue block and
\code{envir} is the execution environment. A \code{.transformer} lets you modify a
glue block before, during, or after evaluation, allowing you to create your
own custom \code{glue()}-like functions. See \code{vignette("transformers")} for
examples.}
\item{.trim}{[\code{logical(1)}: \sQuote{TRUE}]\cr Whether to trim the input
template with \code{\link[=trim]{trim()}} or not.}
}
\value{
A glue object, as created by \code{\link[=as_glue]{as_glue()}}.
}
\description{
Expressions enclosed by braces will be evaluated as R code. Long strings are
broken by line and concatenated together. Leading whitespace and blank lines
from the first and last lines are automatically trimmed.
}
\examples{
name <- "Fred"
age <- 50
anniversary <- as.Date("1991-10-12")
glue('My name is {name},',
'my age next year is {age + 1},',
'my anniversary is {format(anniversary, "\%A, \%B \%d, \%Y")}.')
# single braces can be inserted by doubling them
glue("My name is {name}, not {{name}}.")
# Named arguments can be used to assign temporary variables.
glue('My name is {name},',
' my age next year is {age + 1},',
' my anniversary is {format(anniversary, "\%A, \%B \%d, \%Y")}.',
name = "Joe",
age = 40,
anniversary = as.Date("2001-10-12"))
# `glue()` can also be used in user defined functions
intro <- function(name, profession, country){
glue("My name is {name}, a {profession}, from {country}")
}
intro("Shelmith", "Senior Data Analyst", "Kenya")
intro("Cate", "Data Scientist", "Kenya")
# `glue_data()` is useful in magrittr pipes
if (require(magrittr)) {
mtcars \%>\% glue_data("{rownames(.)} has {hp} hp")
# Or within dplyr pipelines
if (require(dplyr)) {
head(iris) \%>\%
mutate(description = glue("This {Species} has a petal length of {Petal.Length}"))
}}
# Alternative delimiters can also be used if needed
one <- "1"
glue("The value of $e^{2\\\\pi i}$ is $<>$.", .open = "<<", .close = ">>")
}
\seealso{
\url{https://www.python.org/dev/peps/pep-0498/} and
\url{https://www.python.org/dev/peps/pep-0257/} upon which this is based.
}
glue/man/quoting.Rd 0000644 0001762 0000144 00000001505 14503407331 013737 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/quoting.R
\name{quoting}
\alias{quoting}
\alias{single_quote}
\alias{double_quote}
\alias{backtick}
\title{Quoting operators}
\usage{
single_quote(x)
double_quote(x)
backtick(x)
}
\arguments{
\item{x}{A character to quote.}
}
\value{
A character vector of the same length as \code{x}, with the same
attributes (including names and dimensions) but with no class set.
Marked UTF-8 encodings are preserved.
}
\description{
These functions make it easy to quote each individual element and are useful
in conjunction with \code{\link[=glue_collapse]{glue_collapse()}}. These are thin wrappers around
\code{\link[base:encodeString]{base::encodeString()}}.
}
\examples{
x <- 1:5
glue('Values of x: {glue_collapse(backtick(x), sep = ", ", last = " and ")}')
}
glue/man/glue_collapse.Rd 0000644 0001762 0000144 00000002126 14503407331 015067 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/glue.R, R/sql.R
\name{glue_collapse}
\alias{glue_collapse}
\alias{glue_sql_collapse}
\title{Collapse a character vector}
\usage{
glue_collapse(x, sep = "", width = Inf, last = "")
glue_sql_collapse(x, sep = "", width = Inf, last = "")
}
\arguments{
\item{x}{The character vector to collapse.}
\item{sep}{a character string to separate the terms. Not
\code{\link[base]{NA_character_}}.}
\item{width}{The maximum string width before truncating with \code{...}.}
\item{last}{String used to separate the last two items if \code{x} has at least
2 items.}
}
\value{
Always returns a length-1 glue object, as created by \code{\link[=as_glue]{as_glue()}}.
}
\description{
\code{glue_collapse()} collapses a character vector of any length into a length 1 vector.
\code{glue_sql_collapse()} does the same but returns a \verb{[DBI::SQL()]}
object rather than a glue object.
}
\examples{
glue_collapse(glue("{1:10}"))
# Wide values can be truncated
glue_collapse(glue("{1:10}"), width = 5)
glue_collapse(1:4, ", ", last = " and ")
}
glue/man/trim.Rd 0000644 0001762 0000144 00000002026 14503407331 013223 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/glue.R
\name{trim}
\alias{trim}
\title{Trim a character vector}
\usage{
trim(x)
}
\arguments{
\item{x}{A character vector to trim.}
}
\value{
A character vector.
}
\description{
This trims a character vector according to the trimming rules used by glue.
These follow similar rules to \href{https://www.python.org/dev/peps/pep-0257/}{Python Docstrings},
with the following features.
\itemize{
\item Leading and trailing whitespace from the first and last lines is removed.
\item A uniform amount of indentation is stripped from the second line on, equal
to the minimum indentation of all non-blank lines after the first.
\item Lines can be continued across newlines by using \verb{\\\\}.
}
}
\examples{
glue("
A formatted string
Can have multiple lines
with additional indention preserved
")
glue("
\ntrailing or leading newlines can be added explicitly\n
")
glue("
A formatted string \\\\
can also be on a \\\\
single line
")
}
glue/man/glue_col.Rd 0000644 0001762 0000144 00000007220 14503407331 014042 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/color.R
\name{glue_col}
\alias{glue_col}
\alias{glue_data_col}
\title{Construct strings with color}
\usage{
glue_col(..., .envir = parent.frame(), .na = "NA", .literal = FALSE)
glue_data_col(.x, ..., .envir = parent.frame(), .na = "NA", .literal = FALSE)
}
\arguments{
\item{...}{[\code{expressions}]\cr Unnamed arguments are taken to be expression
string(s) to format. Multiple inputs are concatenated together before formatting.
Named arguments are taken to be temporary variables available for substitution.
\if{html}{\out{}}\preformatted{For `glue_data()`, elements in `...` override the values in `.x`.
}\if{html}{\out{
}}}
\item{.envir}{[\code{environment}: \code{parent.frame()}]\cr Environment to evaluate each expression in. Expressions are
evaluated from left to right. If \code{.x} is an environment, the expressions are
evaluated in that environment and \code{.envir} is ignored. If \code{NULL} is passed, it is equivalent to \code{\link[=emptyenv]{emptyenv()}}.}
\item{.na}{[\code{character(1)}: \sQuote{NA}]\cr Value to replace \code{NA} values
with. If \code{NULL} missing values are propagated, that is an \code{NA} result will
cause \code{NA} output. Otherwise the value is replaced by the value of \code{.na}.}
\item{.literal}{[\code{boolean(1)}: \sQuote{FALSE}]\cr Whether to treat single or
double quotes, backticks, and comments as regular characters (vs. as
syntactic elements), when parsing the expression string. Setting \code{.literal = TRUE} probably only makes sense in combination with a custom
\code{.transformer}, as is the case with \code{glue_col()}. Regard this argument
(especially, its name) as experimental.}
\item{.x}{[\code{listish}]\cr An environment, list, or data frame used to lookup values.}
}
\value{
A glue object, as created by \code{\link[=as_glue]{as_glue()}}.
}
\description{
The \link[crayon:crayon]{crayon} package defines a number of functions used to
color terminal output. \code{glue_col()} and \code{glue_data_col()} functions provide
additional syntax to make using these functions in glue strings easier.
Using the following syntax will apply the function \code{\link[crayon:crayon]{crayon::blue()}} to the text 'foo bar'.
\if{html}{\out{}}\preformatted{\{blue foo bar\}
}\if{html}{\out{
}}
If you want an expression to be evaluated, simply place that in a normal brace
expression (these can be nested).
\if{html}{\out{}}\preformatted{\{blue 1 + 1 = \{1 + 1\}\}
}\if{html}{\out{
}}
If the text you want to color contains, e.g., an unpaired quote or a comment
character, specify \code{.literal = TRUE}.
}
\examples{
\dontshow{if (require(crayon)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
library(crayon)
glue_col("{blue foo bar}")
glue_col("{blue 1 + 1 = {1 + 1}}")
glue_col("{blue 2 + 2 = {green {2 + 2}}}")
white_on_black <- bgBlack $ white
glue_col("{white_on_black
Roses are {red {colors()[[552]]}},
Violets are {blue {colors()[[26]]}},
`glue_col()` can show \\\\
{red c}{yellow o}{green l}{cyan o}{blue r}{magenta s}
and {bold bold} and {underline underline} too!
}")
# this would error due to an unterminated quote, if we did not specify
# `.literal = TRUE`
glue_col("{yellow It's} happening!", .literal = TRUE)
# `.literal = TRUE` also prevents an error here due to the `#` comment
glue_col(
"A URL: {magenta https://github.com/tidyverse/glue#readme}",
.literal = TRUE
)
# `.literal = TRUE` does NOT prevent evaluation
x <- "world"
y <- "day"
glue_col("hello {x}! {green it's a new {y}!}", .literal = TRUE)
\dontshow{\}) # examplesIf}
}
glue/man/figures/ 0000755 0001762 0000144 00000000000 14152560265 013433 5 ustar ligges users glue/man/figures/logo.png 0000644 0001762 0000144 00000135371 14540666007 015115 0 ustar ligges users PNG
IHDR ޫh cHRM z&