tag-modify: [DEV] Convenience methods for manipulating tags in a block.

Description Usage Arguments Examples

Description

This function is aimed primarily at developers extending this package. You shouldn't need to use it for everyday operation.

Convenience methods for manipulating tags in a block.

Usage

1
2
3
4
5
6
7
  tag(block, tag_name, create = TRUE)

  tag(block, tag_name, value) <- value

  suffix(x)

  prefix(x)

Arguments

block

Block object to modify

tag_name

name of the tag (as a length 1 character vector)

create

if TRUE will create a new Tag of the appropriate type if one is not present. If FALSE, it will return NULL.

value

the replacement value. If it is a character string, it will replace the text slot. If it's a suffix object, it will be added to the end of the tag's text. If it's a prefix object it will be added to the beginning of the tag's text. Otherwise, the existing tag will be replaced with the new value.

x

for suffix and prefix, text.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
block <- Block()
tag(block, "name")
tag(block, "name", create = FALSE)

tag(block, "name") <- "myname"
block
tag(block, "aliases") <- tag(block, "name")@text
block
tag(block, "aliases") <- suffix("end")
block
tag(block, "aliases") <- prefix("start")
block

hadley/roxygen3 documentation built on May 17, 2019, 12:16 p.m.