您最多能選擇 25 個主題 主題必須以字母或數字為開頭,可包含連接號「-」且最長為 35 個字元。
 
 
boB Rudis b20655a1fa
basics work
4 年前
R basics work 4 年前
inst basics work 4 年前
man basics work 4 年前
tests R package repo initialization complete 4 年前
.Rbuildignore basics work 4 年前
.codecov.yml R package repo initialization complete 4 年前
.gitignore R package repo initialization complete 4 年前
.travis.yml R package repo initialization complete 4 年前
CONDUCT.md R package repo initialization complete 4 年前
DESCRIPTION basics work 4 年前
LICENSE basics work 4 年前
LICENSE.md basics work 4 年前
NAMESPACE basics work 4 年前
NEWS.md R package repo initialization complete 4 年前
README.Rmd basics work 4 年前
README.md basics work 4 年前
purplerain.Rproj R package repo initialization complete 4 年前

README.md

Project Status: Active – The project has reached a stable, usablestate and is being activelydeveloped. Signedby Signed commit% Linux buildStatus
Minimal RVersion License

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 processing
  • pr_add_css_rules: Add “raw” CSS rules
  • pr_add_sources: Add HTML sources to be processed
  • pr_enable_js: Enable JavaScript processing
  • pr_raster: Render a Prince chain to raster output
  • pr_render: Render a Prince chain
  • pr_set_input_format: Set input format
  • pr_set_pdf_metadata: Set PDF metadata
  • prince: 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.