tag: Wrapp Text With HTML Tags

Description Usage Arguments Value Examples

Description

Wrap text with select HTML tags. tag is generic in comparison to specific tag types such as p. Functions also contain an underscore version (e.g., span_). This version uses a built in paste to paste all elements together. For example the following are equivalent:

h1(paste(LETTERS, ": ", em(letters)))
h1_(LETTERS, ": ", em(letters))

This is more natural to write with and more akin to how HTML tags work.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
tag(x, left, right = gsub("^<", "</", left))

p(x)

h1(x)

h2(x)

h3(x)

h4(x)

span(x, extra = "")

b(x)

em(x)

u(x)

tag_(..., left, right = gsub("^<", "</", left))

p_(...)

h1_(...)

h2_(...)

h3_(...)

h4_(...)

span_(..., extra = "")

b_(...)

em_(...)

u_(...)

Arguments

x

A text string.

left

A left tag.

right

A right tag.

extra

Additional arguments to pass to a left tag such as styling.

...

Multiple text strings.

Value

Returns a vector of strings wrpped in HTML tags.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
tag(LETTERS, "<iframe>")

p(LETTERS)
h1_(LETTERS, ": ", em(letters))
p(paste(b(LETTERS), 1:26, letters))

span(LETTERS)
set.seed(10)
(body <-p(span(LETTERS, extra=sprintf("style=\"color:%s\"", sample(colors(), 26)))))
## Not run: 
template2html(insert_body(highlight_template(c(x="")), body))
open_html()

## End(Not run)

trinker/hilight documentation built on May 31, 2019, 8:51 p.m.