Skip to contents

Add body text (e.g., when no data to display)

Usage

add_body_text(
  spec = NULL,
  text = NULL,
  id = NULL,
  styleRef = NULL,
  order = NULL
)

Arguments

spec

Spec object (dispatches on class)

text

Character vector of body text lines

id

Body text identifier (auto-generated if NULL)

styleRef

Character vector of style names or result of f_combine(). Merged with last-win strategy.

order

Order of body text group (auto-assigned if NULL)

Value

Updated spec object

Details

Generic function to add body text. Dispatches to class-specific methods, allowing different spec classes to implement their own body text handling.

Multiple calls add multiple text groups. Calling with the same ID merges with last-win strategy.

Examples

# Text-only spec with body text
spec <- create_text() |>
  add_body_text("No data available for the specified criteria.")

# Table spec with body text as fallback when no data rows render
empty_df <- mtcars[0, ]
spec2 <- create_table(empty_df) |>
  set_document(hasData = FALSE) |>
  add_body_text("No adverse events were reported.",
                styleRef = f_combine("b", "fc_red"))

# Multiple calls append groups; same id merges (last-wins)
spec3 <- create_text() |>
  add_body_text("First paragraph.", id = "p1") |>
  add_body_text("Second paragraph.", id = "p2") |>
  add_body_text("Revised first paragraph.", id = "p1")