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

Use the fontawesome package for the HTML dependency on Font Awesome #2451

Merged
merged 5 commits into from
Feb 9, 2023
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
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Depends:
Imports:
bslib (>= 0.2.5.1),
evaluate (>= 0.13),
fontawesome (>= 0.5.0),
htmltools (>= 0.5.1),
jquerylib,
jsonlite,
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
rmarkdown 2.21
================================================================================

- Now HTML output formats use the Font Awesome HTML dependency from the **fontawesome** package instead of shipping an outdated version of Font Awesome in **rmarkdown** (thanks, @rich-iannone, #2451).

rmarkdown 2.20
================================================================================
Expand Down
10 changes: 1 addition & 9 deletions R/html_dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,7 @@ html_dependency_accessible_code_block <- function() {
#' @rdname html-dependencies
#' @export
html_dependency_font_awesome <- function() {

htmlDependency(
"font-awesome",
"5.1.0",
src = pkg_file("rmd/h/fontawesome"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably delete the directory inst/rmd/h/fontawesome, too, but it depends on whether we want to Import or Suggest fontawesome. If we want to make fontawesome a soft dependency, we can keep our (outdated) version of fontawesome. I don't have a strong opinion on this. The scope of the problems that we are trying to resolve seems to be narrow in my eyes (i.e., the icons are not actually widely used in this package), so I'm not sure if it's worth a new hard dependency.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scope of the problems that we are trying to resolve seems to be narrow in my eyes (i.e., the icons are not actually widely used in this package), so I'm not sure if it's worth a new hard dependency.

That is why at first as was thinking about deprecated to remove this function in the long term as user should use fontawesome 📦 directly and not through rmarkdown.

If we want to make fontawesome a soft dependency

This would mean that:

  • if fontawesome is available, then we use its HTML dependency
  • if not available we fallback to our internal one, even if outdated

Is that right ?

That could be a in-between solution to not Import the package indeed. In that case, I would probably add a message or a warning (probably using xfun::do_once()) to state that an outdated fontawesome would be used and the fontawesome would be used. But one could argue that this is like doing a soft deprecation probably 😅
We could check if an icon is available or not in our version, but probably too much complicated to do and maintain for the benefit.

It is just that silently doing the fallback will not prevent user to not understand why an icon is not showing, and also not teach people about the fontawesome package.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought a bit more about this and came away with the conclusion that having to install fontawesome separately might be confusing to a lot of users and it could cause problems when publishing across different environments. Usually for me when there's an 'optional' package there's always a clear error and message to install that optional package (for extra functionality) when using a specific function or argument. But in the case of a soft dependency it could happen that users would have icons appearing or not, or, older versions of icons being shown (not to mention the difficulty of explaining the different versions of the dependency in the documentation).

I agree that an extra dependency is not to be taken lightly but especially given that other packages like flexdashboard use the dependency function from rmarkdown directly (and they are more likely to use icons) this makes the case even stronger for fontawesome to be included in Imports.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that right ?

Yes.

Given all the potential trouble, we should probably just make fontawesome a hard dependency.

stylesheet = c(
"css/all.css",
"css/v4-shims.css")
)
fontawesome::fa_html_dependency()
}

# Create an HTML dependency for Ionicons
Expand Down
5 changes: 0 additions & 5 deletions inst/rmd/h/fontawesome/css/all.css

This file was deleted.

Loading