if (reticulate::py_available(initialize = TRUE)) {
root <- system.file(package = "excerptr")
test_files <- file.path(root, "excerpts", "tests", "files")
outpath <- tempdir()
python_source <- "some_code.py"
f <- normalizePath(file.path(test_files, python_source))
cat(readLines(f), sep = "\n")
tryCatch(
excerptr(file_name = file.path(test_files, python_source),
output_path = tempdir(), run_pandoc = FALSE,
compile_latex = FALSE,
pandoc_formats = c("tex", "html")),
error = identity)
f <- file.path(outpath, sub("\\.py$", ".md", python_source))
if (!fritools::is_cran()) cat(readLines(f), sep = "\n")
}
Run the code above in your browser using DataLab