add_tag {tokenbrowser}R Documentation

Wrap values in an HTML tag

Description

Wrap values in an HTML tag

Usage

add_tag(x, tag, attr_str = NULL, ignore_na = F, span_adjacent = F)

Arguments

x

a vector of values to be wrapped in a tag

tag

A character vector of length 1, specifying the html tag (e.g., "div", "h1", "span")

attr_str

A character string of the same length as x (or of length 1).

ignore_na

If TRUE, do not add tag if value is NA

span_adjacent

If TRUE, include adjacent tokens with identical attr_str within the same tag

Value

a character vector

Examples

x = c("Obama","Bush")
add_tag(x, 'span')

## add attributes with the tag_attr function
add_tag(x, 'span',
        tag_attr(class = "president"))

## add style attributes with the attr_style function within tag_attr
add_tag(x, 'span',
        tag_attr(class = "president",
                 style = attr_style(`background-color` = 'rgba(255, 255, 0, 1)')))

[Package tokenbrowser version 0.1.0 Index]