Skip to content

Commit

Permalink
Fix attachments being lost from web article
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchelloharawild committed Aug 9, 2021
1 parent f731702 commit 6392af7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

export(create_article)
export(rjdistill_website)
export(rjournal_pdf_article)
export(rjournal_web_article)
import(downlit)
import(htmltools)
Expand Down
11 changes: 10 additions & 1 deletion R/collections.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,18 @@ render_collection <- function(site_dir,



distill_article_post_processor <- function(encoding_fn, self_contained) {
distill_article_post_processor <- function(encoding_fn, self_contained, rmd_path) {

function(metadata, input_file, output_file, clean, verbose) {
# If it is an article, produce PDF
if(!is.null(metadata$type)) {
rmarkdown::render(
rmd_path,
# output_format = "rticles::rjournal_article",
output_format = "rjdistill::rjournal_pdf_article",
clean = FALSE
)
}

# resolve bookdown-style figure cross references
html_output <- xfun::read_utf8(output_file)
Expand Down
26 changes: 11 additions & 15 deletions R/distill_article.R
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,12 @@ rjournal_web_article <- function(toc = FALSE,
# (as opposed to site level includes which we already process)
metadata_includes <- list()

rmd_path <- NULL

# post-knit
post_knit <- function(metadata, input_file, runtime, encoding, ...) {
# If it is an article, produce PDF
if(!is.null(metadata$type)) {
rmarkdown::render(
input_file,
# output_format = "rticles::rjournal_article",
output_format = "rjdistill::rjournal_pdf_article",
clean = FALSE
)
}
# save rmd path
rmd_path <<- input_file

# save encoding
encoding <<- encoding
Expand Down Expand Up @@ -302,7 +297,7 @@ rjournal_web_article <- function(toc = FALSE,
clean_supporting = self_contained,
post_knit = post_knit,
pre_processor = pre_processor,
post_processor = distill_article_post_processor(function() encoding, self_contained),
post_processor = distill_article_post_processor(function() encoding, self_contained, rmd_path),
on_exit = on_exit,
base_format = html_document_base(
smart = smart,
Expand Down Expand Up @@ -340,11 +335,12 @@ rjournal_pdf_article <- function(..., self_contained = FALSE) {
on.exit(unlink(sty_dest[copied]))
post_process(...)
}
output_format(
knitr = knitr_options(),
pandoc = pandoc_options(to = "latex", ext = ".tex"),
base_format = fmt
)
# output_format(
# knitr = knitr_options(),
# pandoc = pandoc_options(to = "latex", ext = ".tex"),
# base_format = fmt
# )
fmt
}

distill_highlighting_args <- function(highlight) {
Expand Down

0 comments on commit 6392af7

Please sign in to comment.