Open mitchelloharawild opened 5 years ago
Hey Mitch,
Some comments about implementation in bookdown
epub_book
formatError in knit_print.icon(v$value, inline = TRUE, options = opts_chunk$get()) :
Icons for this format is currently not supported
## Git and GitHub `r icon::fontawesome("github")` {#github}
Thanks Garth.
I've added epub support, however I don't know how to appropriately scale the image size as ![](<path>){height=1em}
seems to be ignored. If you have any suggestions for this, that would be fantastic.
I don't know how to fix this one, although I'm pleased to see that the icon displays correctly in the navbar and title (and with the workaround it works fine). @yihui: Is there some way to suppress/control knit_print
outputs being used in creating default div ids?
I don't think the ids are created by knit_print
, but Pandoc instead. They are generated automatically by default: https://pandoc.org/MANUAL.html#heading-identifiers I'd strongly recommend using a manual id instead of relying on the auto ids.
Thanks Yihui. What I intended to ask was if knit_print()
output (or generally, non-text output) can be suppressed from pandoc's auto identifiers. Reading into pandoc's auto ids I suspect this isn't possible, as from what I understand any content in the header will be used to generate an ID.
Some insight into the knitr mechanics of plot outputs would be useful, as
# Title `r plot(rnorm(10))`
does not show the plot in the title, but:
# Title `r knitr::asis_output(letters)`
does show the letters in the title.
After some further investigation, it seems that using htmltools::htmlPreserve()
in markdown titles preserves the code into the auto ids. Removing this produces ids which ignore the icon code.
Awesome. Thanks for the careful investigation!
Looks like the distill package returns html5
in response to knitr::opts_knit$get("rmarkdown.pandoc.to")
which means that the icon package currently complains about Icons for this format is currently not supported
for distill. Adding "html5"
as an option in knit.R seems to fix the issue, but I haven't tested widely and I'm not sure if this is just a naiive hack. I've submitted it as a totally trivial pull request #42
Looks like {icon}
should consider all pandoc output formats, as listed here: https://pandoc.org/MANUAL.html#option--to
All common pandoc output formats should now be handled, with a fallback to png and markdown image inputs (cbda25610fe09480bad8658ac4b4af49ff2467b9)
Not sure if I should start a new issue or if this is an extension of this issue, but I've found icons has a strange interaction with Quarto (aka R Markdown 2.0 that all the cool kids seem to be getting excited about). Specifically I've found the icons generate extra output that breaks the formatting when they're included in lists or tables. I'm not sure if this is a Quarto issue or something that can be resolved at the icons package end, but just throwing it out there in case you have any ideas @mitchelloharawild
Example:
---
title: "Icons, meet Quarto!"
format: html
editor: visual
---
```{r, include=FALSE}
library(icons)
This works ok:
icons::fontawesome("star", style = "solid")
as does the inline version:
r icons::ionicons("rocket")
but not so much in a list:
r icons::fontawesome("star", style = "solid")
or a table:
Col1 | Col2 | Col3 |
---|---|---|
A1 | A2 | A3 |
B1 | B2 with a star r icons::ionicons("rocket") |
B3 |
C1 | C2 | C3 |
This is the output I see:
<img width="857" alt="Screen Shot 2022-04-07 at 10 03 41 pm" src="https://user-images.githubusercontent.com/2189134/162194428-7dcd6915-4373-4547-bcd5-3da8e850bd56.png">
Inspecting the difference in the final HTML between a RMD and a Quarto I see this:
R Markdown (works fine)
Quarto (mangles the list adding in the ::: stuff)
:::
sessioninfo::session_info(pkgs = "remotes") ─ Session info ─────────────────────────────────────────────────────────────────────────── setting value version R version 4.1.3 (2022-03-10) os macOS Monterey 12.3.1 system x86_64, darwin17.0 ui RStudio language (EN) collate en_AU.UTF-8 ctype en_AU.UTF-8 tz Australia/Sydney date 2022-04-07 rstudio 2022.02.1+461 Prairie Trillium (desktop) pandoc NA
─ Packages ─────────────────────────────────────────────────────────────────────────────── package version date (UTC) lib source remotes 2.4.2 2021-11-30 [1] CRAN (R 4.1.0)
Before release it would be great to check that icons work in non-standard locations including:
@apreshill has some examples where the font based implementation would work in tables.