您最多能選擇 25 個主題
主題必須以字母或數字為開頭,可包含連接號「-」且最長為 35 個字元。
boB Rudis
b20655a1fa
|
4 年前 | |
---|---|---|
R | 4 年前 | |
inst | 4 年前 | |
man | 4 年前 | |
tests | 4 年前 | |
.Rbuildignore | 4 年前 | |
.codecov.yml | 4 年前 | |
.gitignore | 4 年前 | |
.travis.yml | 4 年前 | |
CONDUCT.md | 4 年前 | |
DESCRIPTION | 4 年前 | |
LICENSE | 4 年前 | |
LICENSE.md | 4 年前 | |
NAMESPACE | 4 年前 | |
NEWS.md | 4 年前 | |
README.Rmd | 4 年前 | |
README.md | 4 年前 | |
purplerain.Rproj | 4 年前 |
README.md
purplerain
Tools to Produce Publication-quality HTML and PDF Output via the Prince Utility
Description
Prince (https://www.princexml.com/) is a framework and toolchain that enables the creation of publication-quality HTML and PDF output from XML or HTML sources. Tools are provided to orchestrate document creation with Prince.
WIP
This is package is in rapid development mode. The API will most certainly change.
What’s Inside The Tin
The following functions are implemented:
pr_add_css_file
: Add CSS files to be included during processingpr_add_css_rules
: Add “raw” CSS rulespr_add_sources
: Add HTML sources to be processedpr_enable_js
: Enable JavaScript processingpr_raster
: Render a Prince chain to raster outputpr_render
: Render a Prince chainpr_set_input_format
: Set input formatpr_set_pdf_metadata
: Set PDF metadataprince
: Start a Prince processing chain
Installation
remotes::install_git("https://git.rud.is/hrbrmstr/purplerain.git")
# or
remotes::install_git("https://git.sr.ht/~hrbrmstr/purplerain")
# or
remotes::install_gitlab("hrbrmstr/purplerain")
# or
remotes::install_bitbucket("hrbrmstr/purplerain")
NOTE: To use the ‘remotes’ install options you will need to have the {remotes} package installed.
Usage
library(purplerain)
# current version
packageVersion("purplerain")
## [1] '0.1.0'
Render an HTML file to PDF with some extra/custom CSS rules
prince() %>%
pr_add_sources(
source_paths = c(
system.file("examples", "lab-report.html", package = "purplerain")
)
) %>%
pr_add_css_rules("body { font-family: sans-serif; }") %>%
pr_add_css_rules(c(
"h1, h2.subtitle{ text-align: center; }",
"h2.subtitle { font-size: 14pt; }"
)) %>%
pr_add_css_rules("
#hello {
color: red;
text-align: center;
font-size: large;
font-style: italic;
font-family: serif;
}") %>%
pr_render(tempfile(fileext=".pdf"), open = FALSE)
Rasterize an HTML file to PNG with some extra/custom CSS rules
prince() %>%
pr_add_sources(
source_paths = c(
system.file("examples", "lab-report.html", package = "purplerain")
)
) %>%
pr_add_css_rules("body { font-family: sans-serif; }") %>%
pr_add_css_rules(c(
"h1, h2.subtitle{ text-align: center; }",
"h2.subtitle { font-size: 14pt; }"
)) %>%
pr_add_css_rules("
#hello {
color: red;
text-align: center;
font-size: large;
font-style: italic;
font-family: serif;
}") %>%
pr_raster(tempfile(pattern = "ex-%02d", fileext=".png"))
Render an HTML file from an R Markdown file then render that result to PDF and rasterize it, too
rmarkdown::render(
input = system.file("examples", "r-markdown.Rmd", package = "purplerain"),
output_file = "/tmp/example.html",
quiet = TRUE
)
prince() %>%
pr_add_sources("/tmp/example.html") %>%
pr_render("/tmp/r-markdown.pdf", TRUE)
prince() %>%
pr_add_sources("/tmp/example.html") %>%
pr_raster("/tmp/r-markdown-%02d.png")
purplerain Metrics
Lang | # Files | (%) | LoC | (%) | Blank lines | (%) | # Lines | (%) |
---|---|---|---|---|---|---|---|---|
R | 8 | 0.89 | 136 | 0.7 | 51 | 0.67 | 148 | 0.78 |
Rmd | 1 | 0.11 | 57 | 0.3 | 25 | 0.33 | 41 | 0.22 |
Code of Conduct
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.