-
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
519 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Package: hrbrthemes | ||
Type: Package | ||
Title: Additional Themes, Theme Components and Utilities for 'ggplot2' | ||
Version: 0.2.0 | ||
Version: 0.3.0 | ||
Date: 2017-03-01 | ||
Authors@R: c( | ||
person("Bob", "Rudis", email = "[email protected]", role = c("aut", "cre")), | ||
|
@@ -34,6 +34,11 @@ Imports: | |
grid, | ||
scales, | ||
extrafont, | ||
purrr | ||
knitr, | ||
rmarkdown, | ||
htmltools, | ||
tools, | ||
magrittr | ||
RoxygenNote: 6.0.1 | ||
VignetteBuilder: knitr | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#' ipsum R markdown template | ||
#' | ||
#' Template for creating an R markdown document with an emphasis on typography | ||
#' | ||
#' @inheritParams rmarkdown::html_document | ||
#' @param extra_dependencies,... Additional function arguments to pass to the | ||
#' base R Markdown HTML output formatter | ||
#' @export | ||
ipsum <- function(number_sections = FALSE, | ||
fig_width = 7, | ||
fig_height = 5, | ||
fig_retina = if (!fig_caption) 2, | ||
fig_caption = FALSE, | ||
dev = 'png', | ||
smart = TRUE, | ||
self_contained = TRUE, | ||
highlight = "default", | ||
mathjax = "default", | ||
extra_dependencies = NULL, | ||
css = NULL, | ||
includes = NULL, | ||
keep_md = FALSE, | ||
lib_dir = NULL, | ||
md_extensions = NULL, | ||
pandoc_args = NULL, | ||
...) { | ||
|
||
toc <- FALSE | ||
toc_depth <- 3 | ||
theme <- NULL | ||
template <- "default" | ||
code_folding <- "none" | ||
|
||
dep <- htmltools::htmlDependency("ipsum", "0.1.0", | ||
system.file("rmarkdown", "templates", "ipsum", "resources", | ||
package = "hrbrthemes"), | ||
stylesheet="ipsum.css") | ||
|
||
extra_dependencies <- append(extra_dependencies, list(dep)) | ||
|
||
|
||
args <- c("--standalone") | ||
args <- c(args, "--section-divs") | ||
args <- c(args, rmarkdown::pandoc_toc_args(toc, toc_depth)) | ||
|
||
args <- c(args, "--template", | ||
rmarkdown::pandoc_path_arg(system.file("rmarkdown", "templates", "ipsum", "base.html", | ||
package = "hrbrthemes"))) | ||
|
||
if (number_sections) | ||
args <- c(args, "--number-sections") | ||
|
||
for (css_file in css) | ||
args <- c(args, "--css", rmarkdown::pandoc_path_arg(css_file)) | ||
|
||
pre_processor <- function(metadata, input_file, runtime, | ||
knit_meta, files_dir, output_dir) { | ||
|
||
if (is.null(lib_dir)) lib_dir <- files_dir | ||
|
||
args <- c() | ||
args <- c(args, pandoc_html_highlight_args(highlight, | ||
template, self_contained, lib_dir, | ||
output_dir)) | ||
args <- c(args, includes_to_pandoc_args(includes = includes, | ||
filter = if (identical(runtime, "shiny")) | ||
normalize_path else identity)) | ||
args | ||
|
||
} | ||
|
||
output_format( | ||
knitr = rmarkdown::knitr_options_html(fig_width, fig_height, | ||
fig_retina, keep_md, dev), | ||
pandoc = rmarkdown::pandoc_options(to = "html", | ||
from = from_rmarkdown(fig_caption, | ||
md_extensions), | ||
args = args), | ||
keep_md = keep_md, clean_supporting = self_contained, | ||
pre_processor = pre_processor, | ||
base_format = rmarkdown::html_document_base(smart = smart, | ||
theme = theme, | ||
self_contained = self_contained, | ||
lib_dir = lib_dir, | ||
mathjax = mathjax, | ||
template = template, | ||
pandoc_args = pandoc_args, | ||
extra_dependencies = extra_dependencies, | ||
...)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Most (if not all) from github.com/rstudio/rmarkdown | ||
|
||
from_rmarkdown <- function (implicit_figures = TRUE, extensions = NULL) { | ||
extensions <- paste0(extensions, collapse = "") | ||
extensions <- gsub(" ", "", extensions) | ||
if (!implicit_figures && !grepl("implicit_figures", extensions)) | ||
extensions <- paste0("-implicit_figures", extensions) | ||
rmarkdown_format(extensions) | ||
} | ||
|
||
from_rst <-function (extensions = NULL) { | ||
format <- c("rst") | ||
addExtension <- function(extension) { | ||
if (length(grep(extension, extensions)) == 0) | ||
format <<- c(format, paste0("+", extension)) | ||
} | ||
addExtension("autolink_bare_uris") | ||
addExtension("ascii_identifiers") | ||
addExtension("tex_math_single_backslash") | ||
format <- c(format, extensions, recursive = TRUE) | ||
paste(format, collapse = "") | ||
} | ||
|
||
pandoc_html_highlight_args <- function (highlight, template, self_contained, | ||
files_dir, output_dir) { | ||
args <- c() | ||
if (is.null(highlight)) { | ||
args <- c(args, "--no-highlight") | ||
} | ||
else if (!identical(template, "default")) { | ||
if (identical(highlight, "default")) | ||
highlight <- "pygments" | ||
args <- c(args, "--highlight-style", highlight) | ||
} | ||
else { | ||
highlight <- match.arg(highlight, html_highlighters()) | ||
if (highlight %in% c("default", "textmate")) { | ||
highlight_path <- system.file("rmd/h/highlight", package = "rmarkdown") | ||
if (self_contained) | ||
highlight_path <- pandoc_path_arg(highlight_path) | ||
else { | ||
highlight_path <- normalized_relative_to(output_dir, | ||
render_supporting_files(highlight_path, files_dir)) | ||
} | ||
args <- c(args, "--no-highlight") | ||
args <- c(args, "--variable", paste("highlightjs=", | ||
highlight_path, sep = "")) | ||
if (identical(highlight, "textmate")) { | ||
args <- c(args, "--variable", paste("highlightjs-theme=", | ||
highlight, sep = "")) | ||
} | ||
} | ||
else { | ||
args <- c(args, "--highlight-style", highlight) | ||
} | ||
} | ||
args | ||
|
||
} | ||
|
||
html_highlighters <- function () { c(highlighters(), "textmate") } | ||
highlighters <- function () { | ||
c("default", "tango", "pygments", "kate", "monochrome", "espresso", | ||
"zenburn", "haddock") | ||
} | ||
|
||
normalized_relative_to <- function (dir, file) { | ||
relative_to(normalizePath(dir, winslash = "/", mustWork = FALSE), | ||
normalizePath(file, winslash = "/", mustWork = FALSE)) | ||
} | ||
|
||
normalize_path <- function (path) { | ||
if (is.null(path)) | ||
NULL | ||
else normalizePath(path, winslash = "/", mustWork = FALSE) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml"$if(lang)$ lang="$lang$" xml:lang="$lang$"$endif$> | ||
|
||
<head> | ||
|
||
<meta charset="utf-8"> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
<meta name="generator" content="pandoc" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
||
<title>$if(title)$$title$$endif$</title> | ||
|
||
<link href="https://fonts.googleapis.com/css?family=Roboto+Slab:100,300,400,700" rel="stylesheet"/> | ||
<link href="https://fonts.googleapis.com/css?family=Roboto+Condensed:300,300i,400,400i,700,700i" rel="stylesheet"/> | ||
<link href="https://fonts.googleapis.com/css?family=Roboto:100,100i,300,300i,400,400i,500,500i,700,700i,900,900i" rel="stylesheet"/> | ||
|
||
$for(header-includes)$ | ||
$header-includes$ | ||
$endfor$ | ||
|
||
$if(highlightjs)$ | ||
<style type="text/css">code{white-space: pre;}</style> | ||
<link rel="stylesheet" | ||
href="$highlightjs$/$if(highlightjs-theme)$$highlightjs-theme$$else$default$endif$.css" | ||
$if(html5)$$else$type="text/css" $endif$/> | ||
<script src="$highlightjs$/highlight.js"></script> | ||
<script type="text/javascript"> | ||
if (window.hljs && document.readyState && document.readyState === "complete") { | ||
window.setTimeout(function() { | ||
hljs.initHighlighting(); | ||
}, 0); | ||
} | ||
</script> | ||
$endif$ | ||
|
||
$if(highlighting-css)$ | ||
<style type="text/css">code{white-space: pre;}</style> | ||
<style type="text/css"> | ||
$highlighting-css$ | ||
</style> | ||
$endif$ | ||
|
||
$for(css)$ | ||
<link rel="stylesheet" href="$css$" $if(html5)$$else$type="text/css" $endif$/> | ||
$endfor$ | ||
|
||
</head> | ||
|
||
<body> | ||
<div class="container"> | ||
|
||
<h1>$if(title)$$title$$endif$</h1> | ||
|
||
$for(include-before)$ | ||
$include-before$ | ||
$endfor$ | ||
|
||
$if(toc)$ | ||
<div id="$idprefix$TOC"> | ||
$toc$ | ||
</div> | ||
$endif$ | ||
|
||
$body$ | ||
|
||
$for(include-after)$ | ||
$include-after$ | ||
$endfor$ | ||
|
||
</div> | ||
|
||
$if(mathjax-url)$ | ||
<!-- dynamically load mathjax for compatibility with self-contained --> | ||
<script> | ||
(function () { | ||
var script = document.createElement("script"); | ||
script.type = "text/javascript"; | ||
script.src = "$mathjax-url$"; | ||
document.getElementsByTagName("head")[0].appendChild(script); | ||
})(); | ||
</script> | ||
$endif$ | ||
|
||
</body> | ||
</html> |
Oops, something went wrong.