tufte/0000755000175000017500000000000014157532512011540 5ustar nileshnileshtufte/MD50000644000175000017500000000505714157532512012057 0ustar nileshnilesh3bdea247b222749ae9cb63a9c0d57c2f *DESCRIPTION af7f5b7df7156d49f99c9fec3f5113c4 *NAMESPACE 76f6aeada57991564a0c67935353addb *R/handout.R 23e2566eb076346f946ba2bc8eaa44a6 *R/html.R f1b88a7bc64861f48f6de505d744dfa4 *R/utils.R 7921893c0b8e463e16ddf0060eee5d82 *README.md 89e0dad03ffce9cdaffac2d6c9aabc35 *inst/NEWS.Rd 024c4cebbe19cacb954ff95bebd01c96 *inst/rmarkdown/templates/tufte_ctex/skeleton/skeleton.Rmd b9ca5771bee1be8152140fbd2884ad50 *inst/rmarkdown/templates/tufte_ctex/template.yaml ac187e42a20ec8ecbcc3f5c71971e343 *inst/rmarkdown/templates/tufte_handout/resources/tufte-handout.tex 7246c4c84252692e7ebcabd26dcb8734 *inst/rmarkdown/templates/tufte_html/resources/LICENSE b7b632602b08c1ba1172757b3afe0002 *inst/rmarkdown/templates/tufte_html/resources/envisioned.css 5294d5d521aab523c8acd8ac96cfe4c0 *inst/rmarkdown/templates/tufte_html/resources/et-book/bold-line-figures.ttf d6175af437d22f14e7cf64c370adc879 *inst/rmarkdown/templates/tufte_html/resources/et-book/display-italic-old-style-figures.ttf d54d0bf6aa7fcf3279d8812acb322c06 *inst/rmarkdown/templates/tufte_html/resources/et-book/roman-line-figures.ttf 638c7cda0684c1644411d3849e61995f *inst/rmarkdown/templates/tufte_html/resources/et-book/roman-old-style-figures.ttf ec3ca614f98c2fd411ee29beb65479a4 *inst/rmarkdown/templates/tufte_html/resources/et-book/semi-bold-old-style-figures.ttf 97e2b03bec21ea6fc61b22fe1d28ec58 *inst/rmarkdown/templates/tufte_html/resources/tufte-background.css 3c86f91ebbacd29b764a72515715b901 *inst/rmarkdown/templates/tufte_html/resources/tufte-fonts.css 879cdbe4f589f595a5789265b6d46b5f *inst/rmarkdown/templates/tufte_html/resources/tufte-italics.css db68faaedd336d364be373ebcc0e01dc *inst/rmarkdown/templates/tufte_html/resources/tufte.css 6614053b2ae2994c493786cd4f5d345a *inst/rmarkdown/templates/tufte_html/skeleton/skeleton.Rmd 37ccf6bb8b1258850b67699fc638c9d1 *inst/rmarkdown/templates/tufte_html/template.yaml a3a752159f7ba1096104119784f254a5 *man/tufte_handout.Rd 0382b700ae55feeba25194ab65c22e11 *tests/testthat.R 732d050b0f22f5bc5bc0019046a8960d *tests/testthat/_snaps/html.md cc8dd862eb346919920659c043d989f8 *tests/testthat/_snaps/new-citeproc-post-2.14.0.2/html.md e2cf7ec862bc71e570156a1090969bd6 *tests/testthat/_snaps/new-citeproc-post-2.14.1/html.md 0c155eb9c70c5fb20ad19b5ede564a78 *tests/testthat/_snaps/pandoc-citeproc/html.md 50928e75070014067bb3534b10bb4a98 *tests/testthat/helpers.R 17743393bfc9c9562067976a6e7802e2 *tests/testthat/resources/margins_references.Rmd fb7719896eadb8708cb663000eca98c7 *tests/testthat/test-html.R 601360ed637b25ca58f5546a465b2d06 *tools/copy-tufte-css.sh tufte/DESCRIPTION0000644000175000017500000000257214157532512013254 0ustar nileshnileshPackage: tufte Type: Package Title: Tufte's Styles for R Markdown Documents Version: 0.11 Authors@R: c( person("Yihui", "Xie", role = c("aut", "cre"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")), person("JJ", "Allaire", role = "aut"), person("Christophe", "Dervieux", role = "ctb", comment = c(ORCID = "0000-0003-4474-2498")), person("Andrzej", "Oles", role = "ctb"), person("Dave", "Liepmann", role = "ctb", comment = "Tufte CSS in inst/rmarkdown/templates/tufte_html/resources"), person(family = "RStudio, PBC", role = "cph") ) Maintainer: Yihui Xie Description: Provides R Markdown output formats to use Tufte styles for PDF and HTML output. License: GPL-3 URL: https://github.com/rstudio/tufte BugReports: https://github.com/rstudio/tufte/issues Imports: htmltools, xfun (>= 0.13), knitr (>= 1.28), rmarkdown (>= 2.1) RoxygenNote: 7.1.1 Suggests: testthat (>= 3.1.0), withr (>= 2.3.0) Config/testthat/edition: 3 NeedsCompilation: no Packaged: 2021-12-19 04:19:47 UTC; yihui Author: Yihui Xie [aut, cre] (), JJ Allaire [aut], Christophe Dervieux [ctb] (), Andrzej Oles [ctb], Dave Liepmann [ctb] (Tufte CSS in inst/rmarkdown/templates/tufte_html/resources), RStudio, PBC [cph] Repository: CRAN Date/Publication: 2021-12-19 04:30:02 UTC tufte/README.md0000644000175000017500000000142314136523540013015 0ustar nileshnilesh# tufte [![CRAN status](https://www.r-pkg.org/badges/version/tufte)](https://CRAN.R-project.org/package=tufte) [![R-CMD-check](https://github.com/rstudio/tufte/workflows/R-CMD-check/badge.svg)](https://github.com/rstudio/tufte/actions) [![Downloads from the RStudio CRAN mirror](https://cranlogs.r-pkg.org/badges/tufte)](https://cran.r-project.org/package=tufte) This R package provides a few R Markdown output formats that use the Tufte style. See https://rstudio.github.io/tufte/ for a comprehensive example. To install the development version of this package from Github, you may use `devtools::install_github('rstudio/tufte')`. You can also install it from [CRAN](https://cran.r-project.org/package=tufte) (`install.packages('tufte')`). tufte/man/0000755000175000017500000000000013733363256012321 5ustar nileshnileshtufte/man/tufte_handout.Rd0000644000175000017500000000754014050555021015451 0ustar nileshnilesh% Generated by roxygen2: do not edit by hand % Please edit documentation in R/handout.R, R/html.R, R/utils.R \name{tufte_handout} \alias{tufte_handout} \alias{tufte_book} \alias{tufte_html} \alias{newthought} \alias{margin_note} \alias{quote_footer} \alias{sans_serif} \title{Tufte handout formats (PDF and HTML)} \usage{ tufte_handout( fig_width = 4, fig_height = 2.5, fig_crop = TRUE, dev = "pdf", highlight = "default", ... ) tufte_book( fig_width = 4, fig_height = 2.5, fig_crop = TRUE, dev = "pdf", highlight = "default", ... ) tufte_html( ..., tufte_features = c("fonts", "background", "italics"), tufte_variant = c("default", "envisioned"), margin_references = TRUE ) newthought(text) margin_note(text, icon = "⊕") quote_footer(text) sans_serif(text) } \arguments{ \item{fig_width}{Default width (in inches) for figures} \item{fig_height}{Default height (in inches) for figures} \item{fig_crop}{\code{TRUE} to automatically apply the \code{pdfcrop} utility (if available) to pdf figures} \item{dev}{Graphics device to use for figure output (defaults to pdf)} \item{highlight}{Syntax highlighting style. Supported styles include "default", "tango", "pygments", "kate", "monochrome", "espresso", "zenburn", and "haddock". Pass \code{NULL} to prevent syntax highlighting.} \item{...}{Other arguments to be passed to \code{\link{pdf_document}} or \code{\link{html_document}} (note you cannot use the \code{template} argument in \code{tufte_handout} or the \code{theme} argument in \code{tufte_html()}; these arguments have been set internally)} \item{tufte_features}{A character vector of style features to enable: \code{fonts} stands for the \code{et-book} fonts in the \code{tufte-css} project, \code{background} means the lightyellow background color of the page, and \code{italics} means whether to use italics for the headers. You can enable a subset of these features, or just disable all of them by \code{NULL}. When this argument is not used and the \code{tufte_variant} argument is not \code{default}, no features are enabled.} \item{tufte_variant}{A variant of the Tufte style. Currently supported styles are \code{default} (from the \code{tufte-css} project), and \code{envisioned} (inspired by the project \code{Envisioned CSS} \url{https://github.com/nogginfuel/envisioned-css} but essentially just sets the font family to \code{Roboto Condensed}, and changed the background/foregroudn colors).} \item{margin_references}{Whether to place citations in margin notes.} \item{text}{A character string to be presented as a \dQuote{new thought} (using small caps), or a margin note, or a footer of a quote} \item{icon}{A character string to indicate there is a hidden margin note when the page width is too narrow (by default it is a circled plus sign)} } \description{ Templates for creating handouts according to the style of Edward R. Tufte and Richard Feynman. } \details{ \code{tufte_handout()} provides the PDF format based on the Tufte-LaTeX class: \url{https://tufte-latex.github.io/tufte-latex/}. \code{tufte_html()} provides the HTML format based on the Tufte CSS: \url{https://edwardtufte.github.io/tufte-css/}. \code{newthought()} can be used in inline R expressions in R Markdown (e.g. \samp{`r newthought(Some text)`}), and it works for both HTML (\samp{text}) and PDF (\samp{\\newthought{text}}) output. \code{margin_note()} can be used in inline R expressions to write a margin note (like a sidenote but not numbered). \code{quote_footer()} formats text as the footer of a quote. It puts \code{text} in \samp{
} for HTML output, and after \samp{\\hfill} for LaTeX output (to right-align text). \code{sans_serif()} applies sans-serif fonts to \code{text}. } \examples{ library(tufte) newthought("In this section") } \references{ See \url{https://rstudio.github.io/tufte/} for an example. } tufte/tools/0000755000175000017500000000000012643402674012703 5ustar nileshnileshtufte/tools/copy-tufte-css.sh0000755000175000017500000000057512647360110016126 0ustar nileshnilesh#!/bin/bash cd inst/rmarkdown/templates/tufte_html/resources/ cp ../../../../../../tufte-css/{tufte.css,LICENSE} ./ [ ! -d et-book ] && mkdir et-book find ../../../../../../tufte-css/et-book -type f -name \*.ttf -exec cp {} et-book/ \; cd et-book for i in `ls *.ttf`; do mv $i ${i#et-book-} done sed -e 's@et-book/et-book-.*/@@' -e 's@\(url."et-book\)-@\1/@' -i '' ../tufte.css tufte/tests/0000755000175000017500000000000014050553752012703 5ustar nileshnileshtufte/tests/testthat/0000755000175000017500000000000014157532512014542 5ustar nileshnileshtufte/tests/testthat/test-html.R0000644000175000017500000000336314136523540016611 0ustar nileshnileshtest_that("add marginnote", { expect_snapshot(marginnote_html("text")) expect_snapshot(marginnote_html("text", "#")) }) expect_refs_margin <- function(moved = FALSE, ..., 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), ...) 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 { # Pandoc 2.14.1 fixed that "new-citeproc-post-2.14.1" } } 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")) }) tufte/tests/testthat/resources/0000755000175000017500000000000014050553752016555 5ustar nileshnileshtufte/tests/testthat/resources/margins_references.Rmd0000644000175000017500000000216014050553752023061 0ustar nileshnilesh--- 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.R0000644000175000017500000000110514136523540016322 0ustar nileshnilesh# 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) } } tufte/tests/testthat/_snaps/0000755000175000017500000000000014136523540016023 5ustar nileshnileshtufte/tests/testthat/_snaps/pandoc-citeproc/0000755000175000017500000000000014136523540021075 5ustar nileshnileshtufte/tests/testthat/_snaps/pandoc-citeproc/html.md0000644000175000017500000001234114136523540022364 0ustar nileshnilesh# 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] "
" [6] "
" [7] "

Xie, Yihui. 2020a. Knitr: A General-Purpose Package for Dynamic Report Generation in R.

" [8] "
" [9] "
" [10] "

———. 2020b. Knitr: A General-Purpose Package for Dynamic Report Generation in R - Duplicate.

" [11] "
" [12] "
" [13] "

Xie, Yihui, J. J. Allaire, and Garrett Grolemund. 2018. R Markdown: The Definitive Guide. Boca Raton, Florida: Chapman; Hall/CRC.

" [14] "
" [15] "
" tufte/tests/testthat/_snaps/html.md0000644000175000017500000000064214136523540017313 0ustar nileshnilesh# 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/0000755000175000017500000000000014136523540022265 5ustar nileshnileshtufte/tests/testthat/_snaps/new-citeproc-post-2.14.0.2/html.md0000644000175000017500000003404514136523540023561 0ustar nileshnilesh# 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] "
" [6] "
" [7] "Xie, Yihui. 2020a. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/." [8] "
" [9] "
" [10] "———. 2020b. Knitr: A General-Purpose Package for Dynamic Report Generation in r - Duplicate. https://yihui.org/knitr/." [11] "
" [12] "
" [13] "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." [14] "
" [15] "
" # put references in margin when link-citations: yes using csl Code margin_references(x) Output [1] "

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/new-citeproc-post-2.14.1/0000755000175000017500000000000014136523540022126 5ustar nileshnileshtufte/tests/testthat/_snaps/new-citeproc-post-2.14.1/html.md0000644000175000017500000003403514136523540023421 0ustar nileshnilesh# 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] "
" [6] "
" [7] "Xie, Yihui. 2020a. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/." [8] "
" [9] "
" [10] "———. 2020b. Knitr: A General-Purpose Package for Dynamic Report Generation in r - Duplicate. https://yihui.org/knitr/." [11] "
" [12] "
" [13] "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." [14] "
" [15] "
" # put references in margin when link-citations: yes using csl Code margin_references(x) Output [1] "

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.R0000644000175000017500000000006614050553752014670 0ustar nileshnileshlibrary(testthat) library(tufte) test_check("tufte") tufte/R/0000755000175000017500000000000014050553752011742 5ustar nileshnileshtufte/R/html.R0000644000175000017500000002174314050553752013040 0ustar nileshnilesh#' @details \code{tufte_html()} provides the HTML format based on the Tufte CSS: #' \url{https://edwardtufte.github.io/tufte-css/}. #' @param tufte_features A character vector of style features to enable: #' \code{fonts} stands for the \code{et-book} fonts in the \code{tufte-css} #' project, \code{background} means the lightyellow background color of the #' page, and \code{italics} means whether to use italics for the headers. You #' can enable a subset of these features, or just disable all of them by #' \code{NULL}. When this argument is not used and the \code{tufte_variant} #' argument is not \code{default}, no features are enabled. #' @param tufte_variant A variant of the Tufte style. Currently supported styles #' are \code{default} (from the \code{tufte-css} project), and #' \code{envisioned} (inspired by the project \code{Envisioned CSS} #' \url{https://github.com/nogginfuel/envisioned-css} but essentially just #' sets the font family to \code{Roboto Condensed}, and changed the #' background/foregroudn colors). #' @param margin_references Whether to place citations in margin notes. #' @rdname tufte_handout #' @export tufte_html = function( ..., tufte_features = c('fonts', 'background', 'italics'), tufte_variant = c('default', 'envisioned'), margin_references = TRUE ) { tufte_variant = match.arg(tufte_variant) if (missing(tufte_features) && tufte_variant != 'default') tufte_features = character() html_document2 = function(..., extra_dependencies = list()) { rmarkdown::html_document( ..., extra_dependencies = c( extra_dependencies, tufte_html_dependency(tufte_features, tufte_variant) ) ) } format = html_document2(theme = NULL, ...) pandoc2 = pandoc2.0() # when fig.margin = TRUE, set fig.beforecode = TRUE so plots are moved before # code blocks, and they can be top-aligned ohooks = knitr::opts_hooks$set(fig.margin = function(options) { if (isTRUE(options$fig.margin)) options$fig.beforecode = TRUE options }) # make sure the existing post processor is called first in our new processor post_processor = format$post_processor format$post_processor = function(metadata, input, output, clean, verbose) { if (is.function(post_processor)) output = post_processor(metadata, input, output, clean, verbose) knitr::opts_hooks$restore(ohooks) x = xfun::read_utf8(output) fn_label = paste0(knitr::opts_knit$get('rmarkdown.pandoc.id_prefix'), 'fn') footnotes = parse_footnotes(x, fn_label) notes = footnotes$items # replace footnotes with sidenotes for (i in seq_along(notes)) { num = sprintf( '%d', fn_label, i, if (pandoc2) 'footnote-ref' else 'footnoteRef', fn_label, i, i ) con = sprintf(paste0( '', '', '%d %s' ), i, i, i, i, notes[i]) x = gsub_fixed(num, con, x) } # remove footnotes at the bottom if (length(footnotes$range)) x = x[-footnotes$range] # replace citations with margin notes if (margin_references) x = margin_references(x) # place figure captions in margin notes x[x == '

'] = '

' # move to the same line as ; the previous line should # start with ', x), grep('^$', x[i])) { j = j + 1 x[i] = paste0(x[i], x[i + j]) x[i + j] = '' } } # place table captions in the margin r = '^$' for (i in grep(r, x)) { # the previous line should be
(.+)
or
if (!grepl('^$', x[i - 1])) next cap = gsub(r, '\\1', x[i]) x[i] = x[i - 1] x[i - 1] = paste0( '

', '', cap, '

' ) } # add an incremental number to the id of