Просмотр исходного кода

Detect presence of {showtext} as default of `use_showtext` (#56)

Updates color examples and adds left-column headings demo to skeleton
tags/v0.4.0
Garrick Aden-Buie 5 лет назад
Родитель
Сommit
b9bea9db0d
Аккаунт пользователя с таким Email не найден
8 измененных файлов: 72 добавлений и 22 удалений
  1. +3
    -0
      NEWS.md
  2. +9
    -5
      R/ggplot2.R
  3. +6
    -2
      R/zzz.R
  4. +2
    -0
      inst/rmarkdown/templates/xaringanthemer/skeleton/.gitignore
  5. +40
    -6
      inst/rmarkdown/templates/xaringanthemer/skeleton/skeleton.Rmd
  6. +4
    -3
      man/theme_xaringan.Rd
  7. +4
    -3
      man/theme_xaringan_base.Rd
  8. +4
    -3
      man/theme_xaringan_inverse.Rd

+ 3
- 0
NEWS.md Просмотреть файл

@@ -10,6 +10,9 @@

* Set slide number font size in `rem` so that increasing the font size at the
slide level doesn't result in giant slide numbers (#53).
* xaringanthemer no longer sets the `fig.showtext` chunk option when the
showtext package isn't installed (#56).

# xaringanthemes 0.3.4


+ 9
- 5
R/ggplot2.R Просмотреть файл

@@ -66,7 +66,7 @@ theme_xaringan <- function(
title_font = NULL,
title_font_use_google = NULL,
title_font_size = NULL,
use_showtext = TRUE
use_showtext = NULL
) {
requires_xaringanthemer_env(css_file = css_file, try_css = TRUE)
requires_package(fn = "xaringan_theme")
@@ -155,7 +155,7 @@ theme_xaringan_inverse <- function(
title_font = NULL,
title_font_use_google = NULL,
title_font_size = NULL,
use_showtext = TRUE
use_showtext = NULL
) {
requires_xaringanthemer_env(css_file = css_file, try_css = TRUE)
requires_package(fn = "xaringan_theme")
@@ -224,10 +224,11 @@ theme_xaringan_inverse <- function(
#' Fonts](https://fonts.google.com)?
#' @param title_font_size Base text font size, inherits from `title_font_size`,
#' or defaults to 14.
#' @param use_showtext If `TRUE` (default) the \pkg{showtext} package will be
#' @param use_showtext If `TRUE` the \pkg{showtext} package will be
#' used to register Google fonts. Set to `FALSE` to disable this feature
#' entirely, which may result in errors during plotting if the fonts used are
#' not available locally.
#' not available locally. The default is `TRUE` when the \pkg{showtext}
#' package is installed.
#' @param ... Ignored
#'
#' @examples
@@ -291,7 +292,7 @@ theme_xaringan_base <- function(
title_font = NULL,
title_font_use_google = NULL,
title_font_size = NULL,
use_showtext = TRUE
use_showtext = NULL
) {
text_color <- full_length_hex(text_color)
background_color <- full_length_hex(background_color)
@@ -304,6 +305,9 @@ theme_xaringan_base <- function(
text_font_use_google <- text_font_use_google %||% is_google_font(text_font)
title_font_use_google <- title_font_use_google %||% is_google_font(title_font)

if (is.null(use_showtext)) {
use_showtext <- requires_package("showtext", "theme_xaringan", required = FALSE)
}
text_font <- if (!is.null(text_font)) {
register_font(text_font, identical(text_font_use_google, TRUE) && use_showtext)
} else {

+ 6
- 2
R/zzz.R Просмотреть файл

@@ -2,13 +2,17 @@
.onLoad <- function(libname, pkgname, ...) {

if ("knitr" %in% loadedNamespaces()) {
knitr::opts_chunk$set(fig.showtext = TRUE)
if (requireNamespace("showtext", quietly = TRUE)) {
knitr::opts_chunk$set(fig.showtext = TRUE)
}
}

setHook(
packageEvent("knitr", "onLoad"),
function(...) {
knitr::opts_chunk$set(fig.showtext = TRUE)
if (requireNamespace("showtext", quietly = TRUE)) {
knitr::opts_chunk$set(fig.showtext = TRUE)
}
}
)


+ 2
- 0
inst/rmarkdown/templates/xaringanthemer/skeleton/.gitignore Просмотреть файл

@@ -0,0 +1,2 @@
*
!skeleton.Rmd

+ 40
- 6
inst/rmarkdown/templates/xaringanthemer/skeleton/skeleton.Rmd Просмотреть файл

@@ -25,7 +25,6 @@ knitr::opts_chunk$set(
echo = TRUE,
message = FALSE,
warning = FALSE,
fig.showtext = requireNamespace("showtext", quietly = TRUE),
hiline = TRUE
)
```
@@ -62,15 +61,30 @@ name: colors

## Colors

- <span style="color: var(--text-color)">Text Color</span>
.left-column[
Text color

- <span style="color: var(--header-color); font-family: var(--header-font-family);">Header Color</span>
[Link Color](#3)

- <span style="color: var(--link-color)">Link Color</span>
**Bold Color**

- <span style="color: var(--text-bold-color); font-weight: bold;">Bold Color</span>
_Italic Color_

- `inline code color`
`Inline Code`
]

.right-column[
Lorem ipsum dolor sit amet, [consectetur adipiscing elit (link)](#3),
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Erat nam at lectus urna.
Pellentesque elit ullamcorper **dignissim cras tincidunt (bold)** lobortis feugiat.
_Eros donec ac odio tempor_ orci dapibus ultrices.
Id porta nibh venenatis cras sed felis eget velit aliquet.
Aliquam id diam maecenas ultricies mi.
Enim sit amet
`code_color("inline")`
venenatis urna cursus eget nunc scelerisque viverra.
]

---

@@ -88,6 +102,26 @@ This is a normal paragraph text. Only use header levels 1-4.

###### Definitely don't use h6 `######`

---

# Left-Column Headings

.left-column[
## First

## Second

## Third
]

.right-column[
Dolor quis aptent mus a dictum ultricies egestas.

Amet egestas neque tempor fermentum proin massa!

Dolor elementum fermentum pharetra lectus arcu pulvinar.
]

---
class: inverse center middle


+ 4
- 3
man/theme_xaringan.Rd Просмотреть файл

@@ -17,7 +17,7 @@ theme_xaringan(
title_font = NULL,
title_font_use_google = NULL,
title_font_size = NULL,
use_showtext = TRUE
use_showtext = NULL
)
}
\arguments{
@@ -63,10 +63,11 @@ defaults to 11.}
\item{title_font_size}{Base text font size, inherits from \code{title_font_size},
or defaults to 14.}

\item{use_showtext}{If \code{TRUE} (default) the \pkg{showtext} package will be
\item{use_showtext}{If \code{TRUE} the \pkg{showtext} package will be
used to register Google fonts. Set to \code{FALSE} to disable this feature
entirely, which may result in errors during plotting if the fonts used are
not available locally.}
not available locally. The default is \code{TRUE} when the \pkg{showtext}
package is installed.}
}
\value{
A ggplot2 theme

+ 4
- 3
man/theme_xaringan_base.Rd Просмотреть файл

@@ -17,7 +17,7 @@ theme_xaringan_base(
title_font = NULL,
title_font_use_google = NULL,
title_font_size = NULL,
use_showtext = TRUE
use_showtext = NULL
)
}
\arguments{
@@ -60,10 +60,11 @@ defaults to 11.}
\item{title_font_size}{Base text font size, inherits from \code{title_font_size},
or defaults to 14.}

\item{use_showtext}{If \code{TRUE} (default) the \pkg{showtext} package will be
\item{use_showtext}{If \code{TRUE} the \pkg{showtext} package will be
used to register Google fonts. Set to \code{FALSE} to disable this feature
entirely, which may result in errors during plotting if the fonts used are
not available locally.}
not available locally. The default is \code{TRUE} when the \pkg{showtext}
package is installed.}
}
\value{
A ggplot2 theme

+ 4
- 3
man/theme_xaringan_inverse.Rd Просмотреть файл

@@ -17,7 +17,7 @@ theme_xaringan_inverse(
title_font = NULL,
title_font_use_google = NULL,
title_font_size = NULL,
use_showtext = TRUE
use_showtext = NULL
)
}
\arguments{
@@ -63,10 +63,11 @@ defaults to 11.}
\item{title_font_size}{Base text font size, inherits from \code{title_font_size},
or defaults to 14.}

\item{use_showtext}{If \code{TRUE} (default) the \pkg{showtext} package will be
\item{use_showtext}{If \code{TRUE} the \pkg{showtext} package will be
used to register Google fonts. Set to \code{FALSE} to disable this feature
entirely, which may result in errors during plotting if the fonts used are
not available locally.}
not available locally. The default is \code{TRUE} when the \pkg{showtext}
package is installed.}
}
\value{
A ggplot2 theme

Загрузка…
Отмена
Сохранить