diff --git a/NAMESPACE b/NAMESPACE index eafb93e..46b38b0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -13,4 +13,3 @@ export(sas_run_selected) export(sas_run_string) export(sas_to_r) export(sas_upload) -export(sas_use_quarto) diff --git a/R/knitr.R b/R/knitr.R index b049c7a..a9a8498 100644 --- a/R/knitr.R +++ b/R/knitr.R @@ -26,6 +26,7 @@ #' @examples #' knitr::knit_engines$set(sas = sas_engine) sas_engine <- function (options) { + options$engine <- "txt" check_connection() code <- paste(options$code, collapse = "\n") @@ -66,40 +67,3 @@ sas_engine <- function (options) { knitr::engine_output(options, code, out) } - -#' Add SAS quarto template to specified directory -#' -#' @description -#' Adds SAS quarto template and syntax highlighting XML to a specified -#' directory. -#' -#' @param path (Default: Current directory) Path to copy quarto template and -#' syntax highlighting XML into. -#' @param xml Include syntax highlighting XML? -#' -#' @return No return value. -#' -#' @export -#' -#' @examples -#' \dontrun{ -#' sas_connect() -#' sas_use_quarto() -#' } -sas_use_quarto <- function(path, xml = TRUE) { - if (missing(path)) { - path <- "." - } else if (!dir.exists(path)) { - stop("Specified directory does not exist") - } - - template <- system.file("sasquatch.qmd", package = "sasquatch") - file.copy(template, path) - - if (xml) { - sas_xml <- system.file("sas.xml", package = "sasquatch") - file.copy(sas_xml, path) - } - - invisible() -} diff --git a/R/utils.R b/R/utils.R index 267b809..c21b262 100644 --- a/R/utils.R +++ b/R/utils.R @@ -2,18 +2,11 @@ wrap_in_iframe <- function(html) { html <- paste(html, collapse = "\n") html <- gsub("'", "\"", html) - html <- paste( - "", - sep = "\n" - ) - paste( + "", sep = "\n" ) } diff --git a/R/zzz.R b/R/zzz.R index 9102383..abdd460 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -3,4 +3,13 @@ .onAttach <- function(libname, pkgname) { .pkgenv$SASPy <- reticulate::import("saspy", delay_load = TRUE) knitr::knit_engines$set(sas = sas_engine) -} \ No newline at end of file + + knitr::knit_hooks$set(document = function(x, options) { + resizer_url <- system.file("resize-iframes.js", package = "sasquatch") + resizer_code <- paste(readLines(resizer_url), collapse = "\n") + resizer_script <- paste("", sep = "\n") + + iframe_start <- "