This PR is an updated version of #43 and closes #41. I've simplified how we create the box around a chunk. Instead of wrapping the chunk in a div that we style to look like a fieldset tag, we now just wrap the chunk in a fieldset tag. This means that we can cut down on the amount of additional CSS styles we are adding into the file and it simplifies the logic within the add_chunk_label_hyperlinks function. To handle the differences between rendering single HTML pages and bookdown sites, I had to change how we select the HTML files to work on for the litr_html_document and litr_gitbook functions. Finally, I added a few extra lines to the error message when a user has the wrong version of litr installed with the command for installing the release version of litr.
In terms of tests I have been able to produce the desired documents for a single Rmarkdown document by generating an example document and adding the following chunks to the document:
#' A function defined with references to chunks.
#'
#' This function does some math.
#'
#' @param x a number
#' @export
add_five <- function(x) {
<<a>>
<<b>>
return(x)
}
add_five(1)
<<c>>
add_five(10)
x <- y / 2
x <- x - 2
add_five(-2)
#' Another function defined with references to chunks.
#'
#' This function does some math.
#'
#' @param x a number
#' @export
add_seven_and_double <- function(x) {
<<a>>
return(y)
}
I had to use rmarkdown::render for the changes to display properly
rmarkdown::render("example.Rmd")
I have also successfully tested this change on a bookdown example:
I spread out these example chunks from above to different bookdown pages and got the expected behavior.
Let me know if there are other tests I should consider.
Finally, I wasn't sure whether or not to increment the litr version so I've kept it at 0.9.1.
This looks great, thanks @patrickvossler18 ! I just made some stylistic changes (narrower border that is dotted rather than solid and a smaller font size)
This PR is an updated version of #43 and closes #41. I've simplified how we create the box around a chunk. Instead of wrapping the chunk in a div that we style to look like a
fieldset
tag, we now just wrap the chunk in afieldset
tag. This means that we can cut down on the amount of additional CSS styles we are adding into the file and it simplifies the logic within theadd_chunk_label_hyperlinks
function. To handle the differences between rendering single HTML pages and bookdown sites, I had to change how we select the HTML files to work on for thelitr_html_document
andlitr_gitbook
functions. Finally, I added a few extra lines to the error message when a user has the wrong version oflitr
installed with the command for installing the release version oflitr
.In terms of tests I have been able to produce the desired documents for a single Rmarkdown document by generating an example document and adding the following chunks to the document:
I had to use rmarkdown::render for the changes to display properly
rmarkdown::render("example.Rmd")
rmarkdown::draft("example.Rmd", template = "make-an-r-package-from-bookdown", package = "litr")