tufte/ 0000755 0001762 0000144 00000000000 15042227512 011401 5 ustar ligges users tufte/tests/ 0000755 0001762 0000144 00000000000 15042223722 012542 5 ustar ligges users tufte/tests/testthat/ 0000755 0001762 0000144 00000000000 15042227512 014403 5 ustar ligges users tufte/tests/testthat/test-html.R 0000644 0001762 0000144 00000004454 15041710233 016452 0 ustar ligges users test_that("add marginnote", { expect_snapshot(marginnote_html("text")) expect_snapshot(marginnote_html("text", "#")) }) expect_refs_margin <- function( moved = FALSE, options = NULL, ..., variant = NULL ) { rmd <- test_path("resources/margins_references.Rmd") out <- withr::local_tempfile(fileext = ".html") rmd_temp <- withr::local_tempfile(fileext = ".Rmd") xfun::write_utf8( knitr::knit_expand(rmd, linked = if (moved) "yes" else "no"), rmd_temp ) rmarkdown::pandoc_convert( basename(rmd_temp), "html4", "markdown", output = out, citeproc = TRUE, verbose = FALSE, wd = dirname(rmd_temp), options = c("--wrap", "preserve", options), ... ) x <- xfun::read_utf8(out) expect_snapshot(margin_references(x), variant = variant) } citeproc_variant <- function() { if (!rmarkdown::pandoc_available("2.11")) { "pandoc-citeproc" } else if (!rmarkdown::pandoc_available("2.14.1")) { # new citeproc creates links on author "new-citeproc-post-2.14.0.2" } else if (!rmarkdown::pandoc_available("3.1.8")) { # Pandoc 2.14.1 fixed that "new-citeproc-post-2.14.1" } else { "new-citeproc-post-3.1.8" } } pandoc_variant <- citeproc_variant() test_that("put references in margin when link-citations: yes", { skip_on_cran() skip_if_not_pandoc() expect_refs_margin(moved = TRUE, variant = pandoc_variant) expect_refs_margin(moved = FALSE, variant = pandoc_variant) }) test_that("put references in margin when link-citations: yes using csl", { skip_on_cran() # requires recent Pandoc skip_if_not_pandoc("2.11") skip_if_offline("zotero.org") expect_refs_margin( moved = TRUE, variant = pandoc_variant, c("--csl", "https://www.zotero.org/styles/apa-6th-edition") ) expect_refs_margin( moved = TRUE, variant = pandoc_variant, c("--csl", "https://www.zotero.org/styles/chicago-author-date-16th-edition") ) }) test_that("footnotes are correctly parsed", { skip_on_cran() skip_if_not_pandoc() pandoc_html <- local_pandoc_convert( "Here is some text^[This should be a sidenote].", to = "html4" ) expect_identical( parse_footnotes(pandoc_html), list(items = "This should be a sidenote", range = 2:7) ) }) tufte/tests/testthat/resources/ 0000755 0001762 0000144 00000000000 14757122121 016417 5 ustar ligges users tufte/tests/testthat/resources/margins_references.Rmd 0000644 0001762 0000144 00000002245 14757122121 022727 0 ustar ligges users --- title: "Test margin references" link-citations: {{linked}} references: - author: - family: Xie given: Yihui id: R-knitr issued: year: 2020 note: R package version 1.30 title: "Knitr: A general-purpose package for dynamic report generation in r" title-short: Knitr type: book url: "https://yihui.org/knitr/" - author: - family: Xie given: Yihui id: R-knitr2 issued: year: 2020 note: R package version 1.29 title: "Knitr: A general-purpose package for dynamic report generation in r - duplicate" title-short: Knitr type: book url: "https://yihui.org/knitr/" - author: - family: Xie given: Yihui - family: Allaire given: J. J. - family: Grolemund given: Garrett id: rmarkdown2018 issued: year: 2018 note: ISBN 9781138359338 publisher: Chapman; Hall/CRC publisher-place: Boca Raton, Florida title: "R markdown: The definitive guide" title-short: R markdown type: book url: "https://bookdown.org/yihui/rmarkdown" output: tufte::tufte_html --- See [@R-knitr]. See @R-knitr2 See @R-knitr and @rmarkdown2018 See [@R-knitr] and [@rmarkdown2018] tufte/tests/testthat/helpers.R 0000644 0001762 0000144 00000003004 15041657263 016176 0 ustar ligges users # Use to test pandoc availability or version lower than skip_if_not_pandoc <- function(ver = NULL) { if (!rmarkdown::pandoc_available(ver)) { msg <- if (is.null(ver)) { "Pandoc is not available" } else { sprintf("Version of Pandoc is lower than %s.", ver) } skip(msg) } } # Use to test version greater than skip_if_pandoc <- function(ver = NULL) { if (rmarkdown::pandoc_available(ver)) { msg <- if (is.null(ver)) { "Pandoc is available" } else { sprintf("Version of Pandoc is greater than %s.", ver) } skip(msg) } } local_rmd_file <- function(..., .env = parent.frame()) { path <- withr::local_tempfile(.local_envir = .env, fileext = ".Rmd") xfun::write_utf8(c(...), path) path } local_render <- function(input, ..., .env = parent.frame()) { skip_if_not_pandoc() output_file <- withr::local_tempfile(.local_envir = .env) rmarkdown::render(input, output_file = output_file, quiet = TRUE, ...) } local_pandoc_convert <- function( text, from = "markdown", options = NULL, ..., .env = parent.frame() ) { skip_if_not_pandoc() rmd <- local_rmd_file(text) out <- withr::local_tempfile(.local_envir = .env) rmarkdown::pandoc_convert( rmd, from = from, output = out, options = c("--wrap", "preserve", options), ... ) xfun::read_utf8(out) } .render_and_read <- function(input, ...) { skip_if_not_pandoc() res <- local_render(input, ...) xfun::read_utf8(res) } tufte/tests/testthat/_snaps/ 0000755 0001762 0000144 00000000000 15041662774 015702 5 ustar ligges users tufte/tests/testthat/_snaps/new-citeproc-post-2.14.1/ 0000755 0001762 0000144 00000000000 15041663044 021774 5 ustar ligges users tufte/tests/testthat/_snaps/new-citeproc-post-2.14.1/html.md 0000644 0001762 0000144 00000034035 15041662677 023302 0 ustar ligges users # put references in margin when link-citations: yes Code margin_references(x) Output [1] "
See (Xie 2020aXie, Yihui. 2020a. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/.).
" [2] "See Xie (2020bXie, Yihui. 2020b. Knitr: A General-Purpose Package for Dynamic Report Generation in r - Duplicate. https://yihui.org/knitr/.)
" [3] "See Xie (2020aXie, Yihui. 2020a. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/.) and Xie, Allaire, and Grolemund (2018Xie, Yihui, J. J. Allaire, and Garrett Grolemund. 2018. R Markdown: The Definitive Guide. Boca Raton, Florida: Chapman; Hall/CRC. https://bookdown.org/yihui/rmarkdown.)
" [4] "See (Xie 2020aXie, Yihui. 2020a. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/.) and (Xie, Allaire, and Grolemund 2018Xie, Yihui, J. J. Allaire, and Garrett Grolemund. 2018. R Markdown: The Definitive Guide. Boca Raton, Florida: Chapman; Hall/CRC. https://bookdown.org/yihui/rmarkdown.)
" --- Code margin_references(x) Output [1] "See (Xie 2020a).
" [2] "See Xie (2020b)
" [3] "See Xie (2020a) and Xie, Allaire, and Grolemund (2018)
" [4] "See (Xie 2020a) and (Xie, Allaire, and Grolemund 2018)
" [5] "See (Xie, 2020aXie, Y. (2020a). Knitr: A general-purpose package for dynamic report generation in r. Retrieved from https://yihui.org/knitr/).
" [2] "See Xie (2020bXie, Y. (2020b). Knitr: A general-purpose package for dynamic report generation in r - duplicate. Retrieved from https://yihui.org/knitr/)
" [3] "See Xie (2020aXie, Y. (2020a). Knitr: A general-purpose package for dynamic report generation in r. Retrieved from https://yihui.org/knitr/) and Xie, Allaire, & Grolemund (2018Xie, Y., Allaire, J. J., & Grolemund, G. (2018). R markdown: The definitive guide. Boca Raton, Florida: Chapman; Hall/CRC. Retrieved from https://bookdown.org/yihui/rmarkdown)
" [4] "See (Xie, 2020aXie, Y. (2020a). Knitr: A general-purpose package for dynamic report generation in r. Retrieved from https://yihui.org/knitr/) and (Xie et al., 2018Xie, Y., Allaire, J. J., & Grolemund, G. (2018). R markdown: The definitive guide. Boca Raton, Florida: Chapman; Hall/CRC. Retrieved from https://bookdown.org/yihui/rmarkdown)
" --- Code margin_references(x) Output [1] "See (Xie 2020aXie, Yihui. 2020a. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/.).
" [2] "See Xie (2020bXie, Yihui. 2020b. Knitr: A General-Purpose Package for Dynamic Report Generation in r - Duplicate. https://yihui.org/knitr/.)
" [3] "See Xie (2020aXie, Yihui. 2020a. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/.) and Xie, Allaire, and Grolemund (2018Xie, Yihui, J. J. Allaire, and Garrett Grolemund. 2018. R Markdown: The Definitive Guide. Boca Raton, Florida: Chapman; Hall/CRC. https://bookdown.org/yihui/rmarkdown.)
" [4] "See (Xie 2020aXie, Yihui. 2020a. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/.) and (Xie, Allaire, and Grolemund 2018Xie, Yihui, J. J. Allaire, and Garrett Grolemund. 2018. R Markdown: The Definitive Guide. Boca Raton, Florida: Chapman; Hall/CRC. https://bookdown.org/yihui/rmarkdown.)
" tufte/tests/testthat/_snaps/new-citeproc-post-3.1.8/ 0000755 0001762 0000144 00000000000 15041710026 021711 5 ustar ligges users tufte/tests/testthat/_snaps/new-citeproc-post-3.1.8/html.md 0000644 0001762 0000144 00000034035 15041710026 023204 0 ustar ligges users # put references in margin when link-citations: yes Code margin_references(x) Output [1] "See (Xie 2020aXie, Yihui. 2020a. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/.).
" [2] "See Xie (2020bXie, Yihui. 2020b. Knitr: A General-Purpose Package for Dynamic Report Generation in r - Duplicate. https://yihui.org/knitr/.)
" [3] "See Xie (2020aXie, Yihui. 2020a. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/.) and Xie, Allaire, and Grolemund (2018Xie, Yihui, J. J. Allaire, and Garrett Grolemund. 2018. R Markdown: The Definitive Guide. Boca Raton, Florida: Chapman; Hall/CRC. https://bookdown.org/yihui/rmarkdown.)
" [4] "See (Xie 2020aXie, Yihui. 2020a. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/.) and (Xie, Allaire, and Grolemund 2018Xie, Yihui, J. J. Allaire, and Garrett Grolemund. 2018. R Markdown: The Definitive Guide. Boca Raton, Florida: Chapman; Hall/CRC. https://bookdown.org/yihui/rmarkdown.)
" --- Code margin_references(x) Output [1] "See (Xie 2020a).
" [2] "See Xie (2020b)
" [3] "See Xie (2020a) and Xie, Allaire, and Grolemund (2018)
" [4] "See (Xie 2020a) and (Xie, Allaire, and Grolemund 2018)
" [5] "See (Xie, 2020aXie, Y. (2020a). Knitr: A general-purpose package for dynamic report generation in r. Retrieved from https://yihui.org/knitr/).
" [2] "See Xie (2020bXie, Y. (2020b). Knitr: A general-purpose package for dynamic report generation in r - duplicate. Retrieved from https://yihui.org/knitr/)
" [3] "See Xie (2020aXie, Y. (2020a). Knitr: A general-purpose package for dynamic report generation in r. Retrieved from https://yihui.org/knitr/) and Xie, Allaire, & Grolemund (2018Xie, Y., Allaire, J. J., & Grolemund, G. (2018). R markdown: The definitive guide. Boca Raton, Florida: Chapman; Hall/CRC. Retrieved from https://bookdown.org/yihui/rmarkdown)
" [4] "See (Xie, 2020aXie, Y. (2020a). Knitr: A general-purpose package for dynamic report generation in r. Retrieved from https://yihui.org/knitr/) and (Xie et al., 2018Xie, Y., Allaire, J. J., & Grolemund, G. (2018). R markdown: The definitive guide. Boca Raton, Florida: Chapman; Hall/CRC. Retrieved from https://bookdown.org/yihui/rmarkdown)
" --- Code margin_references(x) Output [1] "See (Xie 2020aXie, Yihui. 2020a. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/.).
" [2] "See Xie (2020bXie, Yihui. 2020b. Knitr: A General-Purpose Package for Dynamic Report Generation in r - Duplicate. https://yihui.org/knitr/.)
" [3] "See Xie (2020aXie, Yihui. 2020a. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/.) and Xie, Allaire, and Grolemund (2018Xie, Yihui, J. J. Allaire, and Garrett Grolemund. 2018. R Markdown: The Definitive Guide. Boca Raton, Florida: Chapman; Hall/CRC. https://bookdown.org/yihui/rmarkdown.)
" [4] "See (Xie 2020aXie, Yihui. 2020a. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/.) and (Xie, Allaire, and Grolemund 2018Xie, Yihui, J. J. Allaire, and Garrett Grolemund. 2018. R Markdown: The Definitive Guide. Boca Raton, Florida: Chapman; Hall/CRC. https://bookdown.org/yihui/rmarkdown.)
" tufte/tests/testthat/_snaps/html.md 0000644 0001762 0000144 00000000642 15041710026 017152 0 ustar ligges users # add marginnote Code marginnote_html("text") Output [1] "text" --- Code marginnote_html("text", "#") Output [1] "text" tufte/tests/testthat/_snaps/new-citeproc-post-2.14.0.2/ 0000755 0001762 0000144 00000000000 14757122121 022132 5 ustar ligges users tufte/tests/testthat/_snaps/new-citeproc-post-2.14.0.2/html.md 0000644 0001762 0000144 00000034045 15041662257 023434 0 ustar ligges users # put references in margin when link-citations: yes Code margin_references(x) Output [1] "See (Xie 2020aXie, Yihui. 2020a. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/.).
" [2] "See Xie (2020b)Xie, Yihui. 2020b. Knitr: A General-Purpose Package for Dynamic Report Generation in r - Duplicate. https://yihui.org/knitr/.
" [3] "See Xie (2020a)Xie, Yihui. 2020a. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/. and Xie, Allaire, and Grolemund (2018)Xie, Yihui, J. J. Allaire, and Garrett Grolemund. 2018. R Markdown: The Definitive Guide. Boca Raton, Florida: Chapman; Hall/CRC. https://bookdown.org/yihui/rmarkdown.
" [4] "See (Xie 2020aXie, Yihui. 2020a. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/.) and (Xie, Allaire, and Grolemund 2018Xie, Yihui, J. J. Allaire, and Garrett Grolemund. 2018. R Markdown: The Definitive Guide. Boca Raton, Florida: Chapman; Hall/CRC. https://bookdown.org/yihui/rmarkdown.)
" --- Code margin_references(x) Output [1] "See (Xie 2020a).
" [2] "See Xie (2020b)
" [3] "See Xie (2020a) and Xie, Allaire, and Grolemund (2018)
" [4] "See (Xie 2020a) and (Xie, Allaire, and Grolemund 2018)
" [5] "See (Xie, 2020aXie, Y. (2020a). Knitr: A general-purpose package for dynamic report generation in r. Retrieved from https://yihui.org/knitr/).
" [2] "See Xie (2020b)Xie, Y. (2020b). Knitr: A general-purpose package for dynamic report generation in r - duplicate. Retrieved from https://yihui.org/knitr/
" [3] "See Xie (2020a)Xie, Y. (2020a). Knitr: A general-purpose package for dynamic report generation in r. Retrieved from https://yihui.org/knitr/ and Xie, Allaire, & Grolemund (2018)Xie, Y., Allaire, J. J., & Grolemund, G. (2018). R markdown: The definitive guide. Boca Raton, Florida: Chapman; Hall/CRC. Retrieved from https://bookdown.org/yihui/rmarkdown
" [4] "See (Xie, 2020aXie, Y. (2020a). Knitr: A general-purpose package for dynamic report generation in r. Retrieved from https://yihui.org/knitr/) and (Xie, Allaire, & Grolemund, 2018Xie, Y., Allaire, J. J., & Grolemund, G. (2018). R markdown: The definitive guide. Boca Raton, Florida: Chapman; Hall/CRC. Retrieved from https://bookdown.org/yihui/rmarkdown)
" --- Code margin_references(x) Output [1] "See (Xie 2020aXie, Yihui. 2020a. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/.).
" [2] "See Xie (2020b)Xie, Yihui. 2020b. Knitr: A General-Purpose Package for Dynamic Report Generation in r - Duplicate. https://yihui.org/knitr/.
" [3] "See Xie (2020a)Xie, Yihui. 2020a. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/. and Xie, Allaire, and Grolemund (2018)Xie, Yihui, J. J. Allaire, and Garrett Grolemund. 2018. R Markdown: The Definitive Guide. Boca Raton, Florida: Chapman; Hall/CRC. https://bookdown.org/yihui/rmarkdown.
" [4] "See (Xie 2020aXie, Yihui. 2020a. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/.) and (Xie, Allaire, and Grolemund 2018Xie, Yihui, J. J. Allaire, and Garrett Grolemund. 2018. R Markdown: The Definitive Guide. Boca Raton, Florida: Chapman; Hall/CRC. https://bookdown.org/yihui/rmarkdown.)
" tufte/tests/testthat/_snaps/pandoc-citeproc/ 0000755 0001762 0000144 00000000000 14757122121 020742 5 ustar ligges users tufte/tests/testthat/_snaps/pandoc-citeproc/html.md 0000644 0001762 0000144 00000012400 14757122121 022225 0 ustar ligges users # put references in margin when link-citations: yes Code margin_references(x) Output [1] "See (Xie 2020a)Xie, Yihui. 2020a. Knitr: A General-Purpose Package for Dynamic Report Generation in R..
" [2] "See Xie (2020b)Xie, Yihui. 2020b. Knitr: A General-Purpose Package for Dynamic Report Generation in R - Duplicate.
" [3] "See Xie (2020a)Xie, Yihui. 2020a. Knitr: A General-Purpose Package for Dynamic Report Generation in R. and Xie, Allaire, and Grolemund (2018Xie, Yihui, J. J. Allaire, and Garrett Grolemund. 2018. R Markdown: The Definitive Guide. Boca Raton, Florida: Chapman; Hall/CRC.)
" [4] "See (Xie 2020a)Xie, Yihui. 2020a. Knitr: A General-Purpose Package for Dynamic Report Generation in R. and (Xie, Allaire, and Grolemund 2018Xie, Yihui, J. J. Allaire, and Garrett Grolemund. 2018. R Markdown: The Definitive Guide. Boca Raton, Florida: Chapman; Hall/CRC.)
" --- Code margin_references(x) Output [1] "See (Xie 2020a).
" [2] "See Xie (2020b)
" [3] "See Xie (2020a) and Xie, Allaire, and Grolemund (2018)
" [4] "See (Xie 2020a) and (Xie, Allaire, and Grolemund 2018)
" [5] "Xie, Yihui. 2020a. Knitr: A General-Purpose Package for Dynamic Report Generation in R.
" [8] "———. 2020b. Knitr: A General-Purpose Package for Dynamic Report Generation in R - Duplicate.
" [11] "Xie, Yihui, J. J. Allaire, and Garrett Grolemund. 2018. R Markdown: The Definitive Guide. Boca Raton, Florida: Chapman; Hall/CRC.
" [14] "'] <- '
' # move to the same line as