-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9068760
commit 6901f23
Showing
7 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,5 @@ Imports: rmarkdown, knitr | |
VignetteBuilder: knitr | ||
License: GPL-3 | ||
RoxygenNote: 6.0.1 | ||
Suggests: | ||
testthat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
library(testthat) | ||
library(linl) | ||
library(rmarkdown) | ||
library(yaml) | ||
|
||
test_check("linl") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# variables --------------------------------------------------------------- | ||
frontmatter <- yaml::read_yaml("resources/frontmatter.yaml") | ||
body <- readLines("resources/body.txt") | ||
quiet <- !interactive() | ||
|
||
|
||
# helpers ----------------------------------------------------------------- | ||
|
||
# emit logicals as true/false since yes/no is ignored by rmarkdown | ||
to_lgl <- function(x) structure(ifelse(x, 'true', 'false'), class = "verbatim") | ||
|
||
build_rmd <- function(frontmatter, body) { | ||
stopifnot(is.list(frontmatter) && is.character(body)) | ||
outfile <- tempfile(fileext = ".Rmd") | ||
writeLines(c( | ||
"---", | ||
yaml::as.yaml(frontmatter, handlers = list(logical = to_lgl)), | ||
"---\n", | ||
body | ||
), outfile) | ||
return(outfile) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas elementum neque eget dolor [egestas fringilla](http://example.com): | ||
|
||
> Nullam eget dapibus quam, sit amet sagittis magna. | ||
|
||
Vestibulum id sodales lectus, sed scelerisque quam. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
author: | ||
- Aaron Wolen | ||
- Your Organization | ||
opening: To whom it may concern, | ||
closing: Sincerely, | ||
address: | ||
- 123 Street Rd | ||
- Chicago, IL | ||
return-address: | ||
- My Home | ||
- 456 Road St. | ||
- New York, NY | ||
output: linl::linl |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
context("Letter Options") | ||
|
||
test_that("Base letter", { | ||
frontmatter$plainquote <- TRUE | ||
input <- build_rmd(frontmatter, body) | ||
output <- render(input, output_dir = dirname(input), quiet = quiet) | ||
expect_true(file.exists(output)) | ||
}) | ||
|
||
test_that("Styled blockquotes", { | ||
skip_on_cran() | ||
input <- build_rmd(frontmatter, body) | ||
output <- render(input, output_dir = dirname(input), quiet = quiet) | ||
expect_true(file.exists(output)) | ||
}) | ||
|
||
test_that("PDF letterhead", { | ||
skip_on_cran() | ||
frontmatter$letterhead <- normalizePath("resources/letterhead.pdf") | ||
input <- build_rmd(frontmatter, body) | ||
output <- render(input, output_dir = dirname(input), quiet = quiet) | ||
expect_true(file.exists(output)) | ||
}) | ||
|
||
test_that("no option clash with colorlinks disabled (#19)", { | ||
skip_on_cran() | ||
frontmatter$letterhead <- normalizePath("resources/letterhead.pdf") | ||
frontmatter$colorlinks <- FALSE | ||
input <- build_rmd(frontmatter, body) | ||
output <- render(input, output_dir = dirname(input), quiet = quiet) | ||
expect_true(file.exists(output)) | ||
}) |