-
-
Notifications
You must be signed in to change notification settings - Fork 979
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
Support for Font Awesome 5 glyphs in navbar #1554
Comments
This is a bug. Thanks for the report! Reprex in a single zip file: site.zip I don't have time to fix it right now, but in case anyone wants to help, the fix should probably start from here: Lines 633 to 646 in 63418e2
When we upgraded FontAwesome to v5.1.0 last year in #1388, we should have noticed that the |
Removing the split for the iconset in the navbar_link_text <- function(x, ...) {
if (!is.null(x$icon)) {
tagList(tags$span(class = paste(x$icon)), " ", x$text, ...)
}
else
tagList(x$text, ...)
} navbar_icon_dependencies <- function(navbar) {
# read the navbar source
source <- read_utf8(navbar)
# find icon references
res <- regexec('<(span|i) +class *= *("|\') *(fab fa|fas fa|ion ion)-', source)
matches <- regmatches(source, res)
libs <- c()
for (match in matches) {
if (length(match) > 0)
libs <- c(libs, match[[4]])
}
libs <- unique(libs)
# return their dependencies
html_dependencies_fonts("fab fa" %in% libs | "fas fa" %in% libs,"ion ion" %in% libs)
} But the user needs to specify the icon set prefix in the name: "testing-site"
navbar:
title: "Testing"
left:
- text: "Home"
icon: fas fa-home
href: index.html
- text: "R stuff"
icon: fab fa-r-project
href: index.html Building from this results in the following spans: <a href="index.html">
<span class="fas fa-home"></span>
Home
</a> <a href="index.html">
<span class="fab fa-r-project"></span>
R stuff
</a> |
Can you provide more detailed instructions for how to do this? How do I edit these functions if they're embedded in the rmarkdown library? |
I've created a fork that fixes this issue following the suggestion above, but the user has to specify the icon set prefix, e.g. |
Woohoo! Thanks for making this fix! |
@jhelvy yeah it was about time 😅 better later than never... 🙄 Please report back if there are still some issues. But I believe it should be fixed regarding navbar in Rmarkdown website. Thanks! |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary. |
By filing an issue to this repo, I promise that
xfun::session_info('rmarkdown')
. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('rstudio/rmarkdown')
.Support for Font Awesome 5 was added in #1340 and it works great when used in an HTML document:
However, it's currently not possible to use Font Awesome 5 icons in the navbar in HTML documents. The code that is generated hard codes the
fa
prefix in the CSS class, which breaks the Font Awesome rendering engine.Here's a reprex:
index.Rmd
:_site.yml
:Building the site generates the following HTML spans in the navbar:
<span class="fa fa-home"></span>
: This works and shows the home icon<span class="fab fa fab fa-r-project"></span>
: This adds an extrafab
andfa
which makes Font Awesome display a "glyph missing" glyphIf I use
icon: fa-r-project
in_site.yml
instead of the fullfab fa-r-project
, I get this HTML:<span class="fa fa-r-project"></span>
: This doesn't add an extrafab
(but now there's nofab
), and this still adds anfa
, which makes the glyph not display.Ideally, this should be the correct output:
<span class="fab fa-r-project"></span>
Session information:
The text was updated successfully, but these errors were encountered: