quarto, gt, and fontawesome issue

I have a vexing problem, and I am sorry I cannot easily provide a reprex of the issue. I have created a quarto website for my course. In that project I have created a table with some columns that have fontawesome icons that will link to either pages within the website or external links. Basically, something like this

  words = c("a", "b", "c"),
  fa = "['<i class='fa-solid fa-video'></i>'](./path/to_doc.qmd)") %>% 
  gt() %>% 
  fmt_markdown(columns = c(fa)) %>% 
    words = md("<i class='far fa-calendar'></i>")

But it will not render with the fontawesome icons. It worked with Rmarkdown in years past. Also, it seems I was able to render it at one time, but that behavior stopped. So I do think something is wrong with the code necessarily, but with how my project is set up in some way (organized, defaults, something).

R Markdown and Quarto works a bit differently, especially regarding tables. gt will output some HTML and Quarto will parse this HTML. If you have some Markdown content to be processed you have two solutions

Some questions:

  • Are you loading fontawesome somewhere in your document to be available in the rendered HTML ? Fontawesome is an external library and it needs to be included for the icon to be found.

Is this expected to have ' around the i tag ? I believe it should be

[<i class='fa-solid fa-video'></i>](./path/to_doc.qmd)

unless you wanted to show the string itself.

Hope it helps

Thank you very much for the response! Unfortunately I am still not able to get it work.

What is the answer to this question ? How to you load fontawesome JS library in your document ?

Sorry! Yes, I am loading fontawesome library(fontawesome) at the top of the script

This does not insert the JS library into the resulting HTML. It just load the fontawesome R library. But you are not using any of the fontawesome function that insert in the doc, so at the end you have no JS lib in the HTML

It would be the same with https://github.com/quarto-ext/fontawesome extensions for Quarto if you don't use any {{< fa ... >}} in the document.

So either use one of this, or explicitly load the library.

With R you should be able to do with a recent htmltools version.

```{r, echo = FALSE}

This worked! I added the code you provided fontawesome::fa_html_dependency() to my script, and all was right again.

Thank you SO much for taking the time and having the patience to help me!

Is there a reason why I didn't need this line of code in the previous versions of my document and website (Rmarkdown)? I am just curious for my own learning.

Thanks again!

Thank you so much for your helpful suggestions!

Also, I was able to fix the issue by adding fontawesome::fa_html_dependency() to the script.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.