You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
boB Rudis b20655a1fa
basics work
3 days ago
R basics work 3 days ago
inst basics work 3 days ago
man basics work 3 days ago
tests R package repo initialization complete 1 week ago
.Rbuildignore basics work 3 days ago
.codecov.yml R package repo initialization complete 1 week ago
.gitignore R package repo initialization complete 1 week ago
.travis.yml R package repo initialization complete 1 week ago
CONDUCT.md R package repo initialization complete 1 week ago
DESCRIPTION basics work 3 days ago
LICENSE basics work 3 days ago
LICENSE.md basics work 3 days ago
NAMESPACE basics work 3 days ago
NEWS.md R package repo initialization complete 1 week ago
README.Rmd basics work 3 days ago
README.md basics work 3 days ago
purplerain.Rproj R package repo initialization complete 1 week ago

README.md

Signedby 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.