Here are the examples of the r api knitr-knit_meta taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
18 Examples
19
File: scUnifrac.R, author: liuqivandy, license: Apache License 2.0
doReport < - function(plotData, outputFile) {
reportRmd < - system.file("report/scUnifracReportPrint.Rmd",
package = "scUnifrac")
reportContentRmd < - system.file("report/scUnifracReportContent.Rmd",
package = "scUnifrac")
outputPrefix < - sub("[.][^.]*$", "", outputFile)
outputRmd < - paste0(outputPrefix, ".Rmd")
outputContentRmd < - paste0(outputFile, "_content.Rmd")
file.copy(reportRmd, outputRmd, overwrite = TRUE)
file.copy(reportContentRmd, outputContentRmd, overwrite = TRUE)
outputFile < - getAbsolutePath(outputFile)
cat("Output report to:", outputFile, "\n")
knitr::knit_meta(class = NULL, clean = TRUE)
rmarkdown::render(outputRmd, params = list(data = plotData,
outFile = outputFile, contentFile = outputContentRmd))
if (file.exists(outputFile)) {
file.remove(outputRmd)
file.remove(outputContentRmd)
}
}
19
File: test-hpdf_document_base.R, author: RLesur, license: GNU General Public License v3.0
test_that("Render with WeasyPrint-Default options", {
pdf_file < - rmarkdown::render("document.Rmd", hpdf_document_base(),
"weasyprint.html")
knitr::knit_meta()
expect_true(file.exists("weasyprint.pdf"))
expect_false(file.exists("weasyprint.html"))
unlink(pdf_file)
})
19
File: test-hpdf_document_base.R, author: RLesur, license: GNU General Public License v3.0
test_that("Render with Prince-Default options", {
pdf_file < - rmarkdown::render("document.Rmd", hpdf_document_base(engine = "prince"),
"prince.html")
knitr::knit_meta()
expect_true(file.exists("prince.pdf"))
expect_false(file.exists("prince.html"))
expect_match(pdftools::pdf_text("prince.pdf"), "Created with Javascript")
unlink(pdf_file)
})
19
File: test-hpdf_document_base.R, author: RLesur, license: GNU General Public License v3.0
test_that("Attach Rmd file correctly", {
rmarkdown::render("document.Rmd", hpdf_document_base(attach_code = TRUE),
"weasyprint.html")
knitr::knit_meta()
rmarkdown::render("document.Rmd", hpdf_document_base(engine = "prince",
attach_code = TRUE), "prince.html")
knitr::knit_meta()
testthat::expect_equal(pdftools::pdf_attachments("weasyprint.pdf")[[1]]$name,
"document.Rmd")
testthat::expect_equal(pdftools::pdf_attachments("prince.pdf")[[1]]$name,
"document.Rmd")
unlink("weasyprint.pdf")
unlink("prince.pdf")
})
19
File: test-hpdf_document_base.R, author: RLesur, license: GNU General Public License v3.0
test_that("Keep html option", {
rmarkdown::render("document.Rmd", hpdf_document_base(keep_html = TRUE),
"weasyprint.html")
knitr::knit_meta()
expect_true(file.exists("weasyprint.html"))
unlink("weasyprint.pdf")
unlink("weasyprint.html")
rmarkdown::render("document.Rmd", hpdf_document_base(wpdf_engine = "prince",
keep_html = TRUE), "prince.html")
knitr::knit_meta()
expect_true(file.exists("prince.html"))
unlink("prince.pdf")
unlink("prince.html")
})
19
File: test-hpdf_document_base.R, author: RLesur, license: GNU General Public License v3.0
test_that("Include CSS works", {
rmarkdown::render("document.Rmd", hpdf_document_base(keep_html = TRUE,
css = "css_file.css"), "include_css.html")
knitr::knit_meta()
expect_true(any(grepl("html {color: red;}", readLines("include_css.html"),
fixed = TRUE)))
unlink("include_css.pdf")
unlink("include_css.html")
})
19
File: test-pdf-engines-as-postprocessors.R, author: RLesur, license: GNU General Public License v3.0
test_that("Attach Rmd file correctly", {
pdf_file < - rmarkdown::render("document.Rmd", convert_html2pdf_format(attach_code = TRUE))
knitr::knit_meta()
expect_equal(pdftools::pdf_attachments(pdf_file)[[1]]$name,
"document.Rmd")
unlink(pdf_file)
pdf_file < - rmarkdown::render("document.Rmd", convert_html2pdf_format(engine = "prince",
attach_code = TRUE))
knitr::knit_meta()
expect_equal(pdftools::pdf_attachments(pdf_file)[[1]]$name,
"document.Rmd")
unlink(pdf_file)
})
19
File: test-pdf-engines-as-postprocessors.R, author: RLesur, license: GNU General Public License v3.0
test_that("Keep html option", {
pdf_file < - rmarkdown::render("document.Rmd", convert_html2pdf_format(keep_html = TRUE))
knitr::knit_meta()
expect_true(file.exists("document.html"))
unlink(pdf_file)
unlink("document.html")
})
19
File: test-wpdf_document.R, author: RLesur, license: GNU General Public License v3.0
test_that("Render with WeasyPrint-Default options", {
rmarkdown::render("document.Rmd", wpdf_document(), "weasyprint.pdf")
knitr::knit_meta()
expect_true(file.exists("weasyprint.pdf"))
unlink("weasyprint.pdf")
})
19
File: test-wpdf_document.R, author: RLesur, license: GNU General Public License v3.0
test_that("Render with Prince-Default options", {
rmarkdown::render("document.Rmd", wpdf_document(wpdf_engine = "prince"),
"prince.pdf")
knitr::knit_meta()
expect_true(file.exists("prince.pdf"))
expect_match(pdftools::pdf_text("prince.pdf"), "Created with Javascript")
unlink("prince.pdf")
})
19
File: test-wpdf_document.R, author: RLesur, license: GNU General Public License v3.0
test_that("Attach Rmd file correctly", {
rmarkdown::render("document.Rmd", wpdf_document(attach_code = TRUE),
"weasyprint.pdf")
knitr::knit_meta()
rmarkdown::render("document.Rmd", wpdf_document(wpdf_engine = "prince",
attach_code = TRUE), "prince.pdf")
knitr::knit_meta()
testthat::expect_equal(pdftools::pdf_attachments("weasyprint.pdf")[[1]]$name,
"document.Rmd")
testthat::expect_equal(pdftools::pdf_attachments("prince.pdf")[[1]]$name,
"document.Rmd")
unlink("weasyprint.pdf")
unlink("prince.pdf")
})
19
File: test-wpdf_document.R, author: RLesur, license: GNU General Public License v3.0
test_that("Keep html option", {
rmarkdown::render("document.Rmd", wpdf_document(keep_html = TRUE),
"weasyprint.pdf")
knitr::knit_meta()
expect_true(file.exists("weasyprint.html"))
unlink("weasyprint.pdf")
unlink("weasyprint.html")
rmarkdown::render("document.Rmd", wpdf_document_base(wpdf_engine = "prince",
keep_html = TRUE), "prince.pdf")
knitr::knit_meta()
expect_true(file.exists("prince.html"))
unlink("prince.pdf")
unlink("prince.html")
})
19
File: test-wpdf_document.R, author: RLesur, license: GNU General Public License v3.0
test_that("Numbered sections options", {
rmarkdown::render("document.Rmd", wpdf_document(number_sections = TRUE),
"weasyprint.pdf")
knitr::knit_meta()
expect_true(file.exists("weasyprint.pdf"))
unlink("weasyprint.pdf")
rmarkdown::render("document.Rmd", wpdf_document(number_sections = TRUE,
wpdf_engine = "prince"), "prince.pdf")
knitr::knit_meta()
expect_true(file.exists("prince.pdf"))
unlink("prince.pdf")
})
19
File: test-wpdf_document_base.R, author: RLesur, license: GNU General Public License v3.0
test_that("Render with WeasyPrint-Default options", {
rmarkdown::render("document.Rmd", wpdf_document_base(), "weasyprint.pdf")
knitr::knit_meta()
expect_true(file.exists("weasyprint.pdf"))
unlink("weasyprint.pdf")
})
19
File: test-wpdf_document_base.R, author: RLesur, license: GNU General Public License v3.0
test_that("Render with Prince-Default options", {
rmarkdown::render("document.Rmd", wpdf_document_base(wpdf_engine = "prince"),
"prince.pdf")
knitr::knit_meta()
expect_true(file.exists("prince.pdf"))
expect_match(pdftools::pdf_text("prince.pdf"), "Created with Javascript")
unlink("prince.pdf")
})
19
File: test-wpdf_document_base.R, author: RLesur, license: GNU General Public License v3.0
test_that("Attach Rmd file correctly", {
rmarkdown::render("document.Rmd", wpdf_document_base(attach_code = TRUE),
"weasyprint.pdf")
knitr::knit_meta()
rmarkdown::render("document.Rmd", wpdf_document_base(wpdf_engine = "prince",
attach_code = TRUE), "prince.pdf")
knitr::knit_meta()
testthat::expect_equal(pdftools::pdf_attachments("weasyprint.pdf")[[1]]$name,
"document.Rmd")
testthat::expect_equal(pdftools::pdf_attachments("prince.pdf")[[1]]$name,
"document.Rmd")
unlink("weasyprint.pdf")
unlink("prince.pdf")
})
19
File: test-wpdf_document_base.R, author: RLesur, license: GNU General Public License v3.0
test_that("Keep html option", {
rmarkdown::render("document.Rmd", wpdf_document_base(keep_html = TRUE),
"weasyprint.pdf")
knitr::knit_meta()
expect_true(file.exists("weasyprint.html"))
unlink("weasyprint.pdf")
unlink("weasyprint.html")
rmarkdown::render("document.Rmd", wpdf_document_base(wpdf_engine = "prince",
keep_html = TRUE), "prince.pdf")
knitr::knit_meta()
expect_true(file.exists("prince.html"))
unlink("prince.pdf")
unlink("prince.html")
})
19
File: test-wpdf_document_base.R, author: RLesur, license: GNU General Public License v3.0
test_that("Include CSS works", {
rmarkdown::render("document.Rmd", wpdf_document_base(keep_html = TRUE,
css = "css_file.css"), "include_css.pdf")
knitr::knit_meta()
expect_true(any(grepl("html {color: red;}", readLines("include_css.html"),
fixed = TRUE)))
unlink("include_css.pdf")
unlink("include_css.html")
})