Skip to contents

Joins pieces into text: character as user text, spans from r8span(), R8 values as their text, and other r8_text objects. Pieces join on one line: the first line of each piece continues the last line of the text before it, and its other lines follow. c() stacks r8_text objects as lines.

Usage

r8text(...)

# S3 method for class 'r8_text'
c(...)

Arguments

...

Pieces: character, r8_text objects, and R8 values.

Value

An r8_text object.

Details

An r8_text object is a character vector of plain lines, so nchar() gives the plain width and cat() writes plain text. Its attributes hold the spans of its roles, the depth of each line, and a copy of the plain lines; text that sub() or toupper() changes encodes without roles. format() encodes it as plain text unless its caller names another output type, and print() writes it in the output type that r8output_type() determines.

Author

EDG

Examples

t <- r8text("GBM ", r8span("trained", "highlight"))
c(t, r8text(r8span("12 s", "summary")))
#> GBM trained
#> 12 s
format(t, output_type = "html")
#> [1] "<pre class=\"r8\"><span class=\"r8-line\" data-depth=\"0\"><span class=\"r8-user_text\">GBM </span><span class=\"r8-highlight\" style=\"color:var(--r8-highlight,#6CA3A0);font-weight:bold\">trained</span></span></pre>"