pagedown
pagedown copied to clipboard
Global resources not found when using custom template as package
Can you provide guidance into how I would pass resource dependencies to html_paged
?
I'm trying to create a new format following the instructions found here in Chapter 18 so I can turn it into a package.
However, when I serve the document, the resources I've specified are not found. It does work if I add the supporting files to the skeleton template as detailed in Chapter 17.
I'd rather have a global set of custom files that are used in multiple templates rather than having a copy of each in each template, mirroring how pagedown
's resources are kept.
Below is basically what I'm attempting.
my_report = function(
...,
# Pass custom css files
css = c('custom-fonts.css', 'custom-page.css', 'custom.css'),
template = pagedown:::pkg_resource('html', 'paged.html')
) {
my_pkg_resource = function(...) {
system.file('resources', ..., package = 'my_package', mustWork = TRUE)
}
# Get their path within package
css_custom = my_pkg_resource(file.path('css', xfun::with_ext(css, ".css")))
pagedown::html_paged(
...,
# Pass custom css paths to html_paged
css = css_custom,
template = template
)
}