#' Save kable to files
#'
#' @param x A piece of HTML code for tables, usually generated by kable and
#' kableExtra
#' @param file save to files. If the input table is in HTML and the output file
#' ends with `.png`, `.pdf` and `.jpeg`, `webshot` will be used to do the
#' conversion
#'
#' @param bs_theme Which Bootstrap theme to use
#' @param self_contained Will the files be self-contained?
#' @param ... Additional variables being passed to `webshot::webshot`.`
#'
#' @export
save_kable <- function(x, file,
                       bs_theme = "simplex", self_contained = TRUE, ...) {
  if (attr(x, "format") == "latex") {
    return(save_kable_latex(x, file))
  }
  return(save_kable_html(x, file, bs_theme, self_contained, ...))
}

save_kable_html <- function(x, file, bs_theme, self_contained, ...) {
  html_header <- htmltools::tags$head(
    rmarkdown::html_dependency_jquery(),
    rmarkdown::html_dependency_bootstrap(theme = bs_theme),
    html_dependency_kePrint()
  )
  html_table <- htmltools::HTML(as.character(x))
  html_result <- htmltools::tagList(html_header, html_table)

  # Use webshot if necessary
  if (tools::file_ext(file) %in% c("png", "jpg", "jpeg", "pdf")) {
    file_html <- paste0(tools::file_path_sans_ext(file), ".html")
    htmltools::save_html(html_result, file = file_html)
    webshot::webshot(file_html, file, ...)
    unlink(file_html)
    unlink("lib", recursive = TRUE)
  } else {
    htmltools::save_html(html_result, file = file)
    if (self_contained) {
      rmarkdown::pandoc_self_contained_html(file, file)
      unlink("lib", recursive = TRUE)
    }
  }
}

save_kable_latex <- function(x, file) {

}
