1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
Author: Steffen Moeller <moeller@debian.org>
Description: Adding expressiveness in error message, also finding packages in system path.
Index: Deactivated in version 2.10
--- r-cran-rmarkdown.orig/R/html_dependencies.R
+++ r-cran-rmarkdown/R/html_dependencies.R
@@ -239,11 +239,43 @@ validate_html_dependency <- function(lis
if (is.null(list$src$file))
stop("path for html_dependency not provided", call. = FALSE)
file <- list$src$file
- if (!is.null(list$package))
+ if (!is.null(list$package)) {
file <- system.file(file, package = list$package)
- if (!file.exists(file)) {
+ warning("validate_html_dependency: transformed package '",list$script,"' to file '",file)
+ list$src$file <- file
+ }
+
+ if (is.na(file) || "" == file) {
+ if (!is.null(list$script)) {
+ if (file.exists(paste(system.file(package="rmarkdown"),"rmd/h",list$script,sep="/"))) {
+ list$src$file <- paste(system.file(package="rmarkdown"),"rmd/h",sep="/")
+ return(list)
+ }
+ for(d in dir(paste(system.file(package="rmarkdown"),"rmd/h",sep="/"))) {
+ if (file.exists(paste(system.file(package="rmarkdown"),"rmd/h",d,list$script,sep="/"))) {
+ list$src$file <- paste(system.file(package="rmarkdown"),"rmd/h",d,sep="/")
+ return(list)
+ }
+ }
+ for(d in dir("/usr/share/javascript")) {
+ file <- paste("/usr/share/javascript",d,list$script,sep="/")
+ if (file.exists(file)) {
+ list$src$file <- d
+ return(list)
+ }
+ }
+ file <- paste(getwd(),list$script,sep="/")
+ warning("validate_html_dependency: transformed script '",list$script,"' to file '",file)
+ list$src$file <- getwd()
+ }
+ }
+
+ if (is.na(file) || "" == file) {
+ utils::str(list)
+ warning("validate_html_dependency was asked to search for a file dependency with no file name")
+ } else if (!file.exists(file)) {
utils::str(list)
- stop("path for html_dependency not found: ", file, call. = FALSE)
+ stop("path for html_dependency not found: '", file, "', expected in '", getwd(), "'", call. = FALSE)
}
list
|