| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/html_resources.R |
| 3 |
\name{find_external_resources} |
| 4 |
\alias{find_external_resources} |
| 5 |
\title{Find External Resource References} |
| 6 |
\usage{ |
| 7 |
find_external_resources(input_file, encoding = "UTF-8") |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{input_file}{path to the R Markdown document or HTML file to process} |
| 11 |
|
| 12 |
\item{encoding}{Ignored. The encoding is always assumed to be UTF-8.} |
| 13 |
} |
| 14 |
\value{ |
| 15 |
A data frame with the following columns: |
| 16 |
\describe{ |
| 17 |
\item{path}{The relative path from the document to the resource} |
| 18 |
\item{explicit}{Whether the resource was specified explicitly |
| 19 |
(\code{TRUE}) or discovered implicitly (\code{FALSE})} |
| 20 |
\item{web}{Whether the resource is needed to display a Web page rendered |
| 21 |
from the document} |
| 22 |
} |
| 23 |
} |
| 24 |
\description{ |
| 25 |
Given an R Markdown document or HTML file, attempt to determine the set of |
| 26 |
additional files needed in order to render and display the document. |
| 27 |
} |
| 28 |
\details{ |
| 29 |
This routine applies heuristics in order to scan a document for |
| 30 |
possible resource references. |
| 31 |
|
| 32 |
In R Markdown documents, it looks for references to files implicitly |
| 33 |
referenced in Markdown (e.g. \code{}), in the document's |
| 34 |
YAML header, in raw HTML chunks, and as quoted strings in R code chunks |
| 35 |
(e.g. \code{read.csv("data.csv")}). |
| 36 |
|
| 37 |
Resources specified explicitly in the YAML header for R Markdown |
| 38 |
documents are also returned. To specify resources in YAML, use the |
| 39 |
\code{resource_files} key: |
| 40 |
|
| 41 |
\preformatted{--- |
| 42 |
title: My Document |
| 43 |
author: My Name |
| 44 |
resource_files: |
| 45 |
- data/mydata.csv |
| 46 |
- images/figure.png |
| 47 |
---} |
| 48 |
|
| 49 |
Each item in the \code{resource_files} list can refer to: |
| 50 |
\enumerate{ |
| 51 |
\item A single file, such as \code{images/figure.png}, or |
| 52 |
\item A directory, such as \code{resources/data}, in which case all of the |
| 53 |
directory's content will be recursively included, or |
| 54 |
\item A wildcard pattern, such as \code{data/*.csv}, in which case all of |
| 55 |
the files matching the pattern will be included. No recursion is done in |
| 56 |
this case. |
| 57 |
} |
| 58 |
|
| 59 |
In HTML files (and raw HTML chunks in R Markdown documents), this routine |
| 60 |
searches for resources specified in common tag attributes, such as |
| 61 |
\code{<img src="...">}, \code{<link href="...">}, etc. |
| 62 |
|
| 63 |
In all cases, only resources that exist on disk and are contained in the |
| 64 |
document's directory (or a child thereof) are returned. |
| 65 |
} |