Skip to content

Commit

Permalink
Move more logic to skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
noamross committed Sep 3, 2019
1 parent ae57c1a commit 76376ab
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 31 deletions.
40 changes: 10 additions & 30 deletions R/joss_article.R
Expand Up @@ -7,7 +7,8 @@
#' R Markdown and to locally preview how the article will appear as PDF.
#'
#' The following variables may be set in YAML metadata to populate fields in the
#' article PDF: \code{doi, year, volume, issue, page, submitted, published,
#' article PDF, but are only necccessary fo local preview:
#' \code{formatted_doi, citation_author, year, volume, issue, page, submitted, published,
#' review_url, repository}, and \code{archive_doi}.
#'
#' @inheritParams rmarkdown::pdf_document
Expand All @@ -23,42 +24,21 @@ joss_article <- function(journal = "JOSS",

rmarkdown::pandoc_available('2.2', TRUE)

logo_path <- find_resource("joss_article",
paste0(journal, "-logo.png"))
logo_path <- find_resource("joss_article", paste0(journal, "-logo.png"))
journalname <- ifelse(journal == "JOSS",
"Journal of Open Source Software",
"Journal of Open Source Education")

pandoc_args <- c(
"-V", paste0("logo_path=", logo_path),
"-V", paste0("journal_name=", journalname),
"-V", "graphics=true",
"--csl", find_resource("joss_article", "apa.csl")
)

base <- pdf_document_format(
"joss_article",
latex_engine = latex_engine,
pandoc_args = pandoc_args,
citation_package = "none",
fig_width = 6, fig_height = 4.15,
dev = "png"

)
base$keep_md <- keep_md
base$clean_supporting <- !keep_md

base$post_knit <- function(metadata, input_file, runtime, ...) {
if (!is.null(metadata$authors)) {
citation_author <- ifelse(
length(metadata$authors) > 1,
paste(metadata$authors[[1]]$name, "et. al."),
metadata$authors[[1]]$name
)
return(c("-V", paste0("citation_author=", citation_author)))
}
}

base
keep_md = keep_md,
pandoc_args = c(
"-V", paste0("logo_path=", logo_path),
"-V", paste0("journal_name=", journalname),
"-V", "graphics=true"
),
...)
}

7 changes: 6 additions & 1 deletion inst/rmarkdown/templates/joss_article/skeleton/skeleton.Rmd
Expand Up @@ -19,9 +19,14 @@ affiliations:
index: 1
- name: Institution 2
index: 2
citation_author: Price-Whelan et. al.
date: 13 August 2017
year: 2017
formatted_doi: 10.21105/joss.00388
bibliography: paper.bib
output: rticles::joss_article
csl: apa.csl
journal: JOSS
---

# Summary
Expand Down Expand Up @@ -81,7 +86,7 @@ For a quick reference, the following citation commands can be used:

# Rendered R Figures

Figures can be plotted like so. Note figures are rendered as PNG.
Figures can be plotted like so:

```{r}
plot(1:10)
Expand Down

0 comments on commit 76376ab

Please sign in to comment.