Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle new prefix in fontawesome 5 #1967

Merged
merged 1 commit into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions R/html_dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ navbar_icon_dependencies <- function(navbar) {
source <- read_utf8(navbar)

# find icon references
res <- regexec('<(span|i) +class *= *("|\') *(fa fa|ion ion)-', source)
res <- regexec('<(span|i) +class *= *("|\') *(fa\\w fa|ion ion)-', source)
matches <- regmatches(source, res)
libs <- c()
for (match in matches) {
Expand All @@ -151,7 +151,9 @@ navbar_icon_dependencies <- function(navbar) {
libs <- unique(libs)

# return their dependencies
html_dependencies_fonts("fa fa" %in% libs, "ion ion" %in% libs)
any_fa <- any(grepl("fa\\w fa", libs))
any_ion <- any(grepl("ion ion", libs))
html_dependencies_fonts(any_fa, any_ion)
}

# utility function to return a list of font dependencies based
Expand Down
13 changes: 12 additions & 1 deletion R/html_document.R
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,18 @@ navbar_link_text <- function(x, ...) {
iconset <- split[[1]][[1]]
else
iconset <- ""
tagList(tags$span(class = paste(iconset, x$icon)), " ", x$text, ...)
# check if a full class is passed for fontawesome
# use default 'fas' otherwise
# https://github.com/rstudio/rmarkdown/issues/1554
class = if (grepl("^fa\\w fa", iconset)) {
x$icon
} else if (iconset == "fa") {
paste("fas", x$icon)
} else {
# should be other than FontAwesome
paste(iconset, x$icon)
}
tagList(tags$span(class = class), " ", x$text, ...)
}
else
tagList(x$text, ...)
Expand Down