`r params$title`"

knitr::opts_chunk$set(echo = FALSE, comment="");

if (!exists('headingLevel') || !is.numeric(headingLevel) || (length(headingLevel) != 1)) {
  headingLevel <- 0;
}

if (is.null(section)) {
  sectionsToShow <- x$form$sections$section_id;
} else {
  sectionsToShow <-
    intersect(
      x$form$sections$section_id,
      section
    );
}
for (section in sectionsToShow) {

  preregr::heading(
    "Section: ",
    x$form$sections[
      x$form$sections$section_id==section,
      "section_label"
    ],
    headingLevel=headingLevel + 1
  );

  item_ids <- x$form$items$item_id[x$form$items$section_id == section];
  item_labels <- x$form$items$item_label[x$form$items$section_id == section];
  names(item_labels) <- item_ids;

  for (currentItemId in item_ids) {

    preregr::heading(
      item_labels[currentItemId],
      headingLevel=headingLevel + 2
    );

    if (x$specs[[currentItemId]] == x$config$initialText) {
      cat0("*No content specified*\n");
    } else {
      cat(
       ifelse(!is.null(x$specs[[currentItemId]]$text) &&
                !is.na(x$specs[[currentItemId]]$text) &&
                nchar(x$specs[[currentItemId]]$text) > 0,
              x$specs[[currentItemId]]$text,
              "\n\n")
      );
    }

    cat0("\n\n(Item identifier: `", currentItemId, "`)\n\n");

  }

}


Try the preregr package in your browser

Any scripts or data that you put into this service are public.

preregr documentation built on May 31, 2023, 7:10 p.m.