R/build_lines.R

Defines functions build_lines

#' @importFrom whisker whisker.render
build_lines <- function(obj,
                        stem = "tex_temp",
                        usrPackages,
                        fileDir = tex_opts$get('fileDir'),
                        resizebox = tex_opts$get('resizebox'),
                        margin = tex_opts$get('margin')
                        ){
  
  if( resizebox ){
      
    obj <- tex_resize(obj)
      
  }
  
  obj <- clean_packages(obj)

  usrPackages <- union(usrPackages,texPreview::build_usepackage(attr(obj,'packages')))
  
  cat(obj, file= tex_path(fileDir,stem), sep= '\n')
  
  TMPL <- readLines(system.file('tmpl.tex',package = 'texPreview'))
  
  input_path <- normalizePath(tex_path(fileDir,stem),winslash = .Platform$file.sep)
  
  input_path <- sprintf('{"%s"}',input_path)

  ARGS <- append(margin, list(usrPackages = paste0(usrPackages,collapse = '\n'), file = input_path))
  
  whisker::whisker.render(TMPL, ARGS)
}

Try the texPreview package in your browser

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

texPreview documentation built on May 29, 2024, 5:45 a.m.