Skip to content

Commit

Permalink
Format the ad as superscript
Browse files Browse the repository at this point in the history
Closes #201 Consider superscript advertising as the default
  • Loading branch information
jennybc committed Sep 12, 2018
1 parent 6424afb commit 8c64e13
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# reprex 0.2.0.9000

* The reprex ad is formatted as superscript for `venue = "gh"` and `venue = "so"`, i.e. it is more subtle now (#201).

* New experimental venue "rtf" produces syntax highlighted snippets suitable for pasting into presentation software such as Keynote or PowerPoint. This venue is discussed in [an article](https://reprex.tidyverse.org/articles/articles/rtf.html) (#26).

* Arguments `opts_chunk` and `opts_knit` have been removed from `reprex()`. The same effect has always been achievable via roxygen comments in the reprex code and the examples have always demonstrated this. Overriding knitr options doesn't seem to come up often enough in real-world `reprex()` usage to justify these arguments.
Expand Down
5 changes: 4 additions & 1 deletion R/whisker.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply_template <- function(x, reprex_data = NULL) {
tidyverse_quiet = as.character(tidyverse_quiet),
comment = comment,
upload_fun = "knitr::imgur_upload",
advertise = advertise
ad = "Created on `r Sys.Date()` by the [reprex package](https://reprex.tidyverse.org) (v`r utils::packageVersion(\"reprex\")`)"
))

if (!is.null(reprex_data$std_file)) {
Expand All @@ -25,19 +25,22 @@ apply_template <- function(x, reprex_data = NULL) {
if (reprex_data$venue == "gh") {
data$si_start <- prose("<details><summary>Session info</summary>")
data$si_end <- prose("</details>")
data$ad <- paste0("<sup>", data$ad, "</sup>")
}

if (reprex_data$venue == "so") {
data$yaml <- yaml_md("md")
data$so_syntax_highlighting <- prose("<!-- language-all: lang-r -->")
## empty line between html comment re: syntax highlighting and reprex code
x <- c("", x)
data$ad <- paste0("<sup>", data$ad, "</sup>")
}

if (reprex_data$venue == "r") {
data$upload_fun <- "identity"
}

data$ad <- if (reprex_data$advertise) prose(data$ad) else NULL
data$body <- paste(x, collapse = "\n")
whisker::whisker.render(read_template("REPREX"), data = data)
}
Expand Down
4 changes: 1 addition & 3 deletions inst/templates/REPREX.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ knitr::opts_knit$set(upload.fun = {{{upload_fun}}})

{{{std_file_stub}}}

{{#advertise}}
#' Created on `r Sys.Date()` by the [reprex package](https://reprex.tidyverse.org) (v`r utils::packageVersion("reprex")`).
{{/advertise}}
{{{ad}}}

{{#si}}
{{{si_start}}}
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-pandoc.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ context("pandoc")
test_that("pandoc does not add hard linebreak in the ad", {
skip_on_cran()
out <- reprex(input = "1:3\n", venue = "gh", show = FALSE, advertise = TRUE)
expect_match(out[length(out)], "^Created on")
expect_match(out[length(out)], "Created on")
out <- reprex(input = "1:3\n", venue = "so", show = FALSE, advertise = TRUE)
expect_match(out[length(out)], "^Created on")
expect_match(out[length(out)], "Created on")
})

test_that("pandoc version checkers don't error", {
Expand Down

0 comments on commit 8c64e13

Please sign in to comment.