mitchelloharawild / icons

R package to easily insert web icons to RMarkdown
https://pkg.mitchelloharawild.com/icons
310 stars 43 forks source link

new icon style appears to break within RMarkdown links #51

Closed francisbarton closed 3 years ago

francisbarton commented 3 years ago

I've just updated an RMarkdown document that previously used the old style like icon::ii("social_github"). When used within a link, this used to work fine to create a linked icon:

[`r icon::ii("social_github")`](https://github.com/mitchelloharawild/icon)

but now

a) icon::ionicons() does not seem to have an option for github icon or a twitter icon any more (nothing is found by find_icon()), - I can use Simple icons instead, but... b) the hyperlink is no longer rendered properly:

[`r icon::simple_icons("github")`](https://github.com/mitchelloharawild/icon)

renders with the literal brackets/braces and the URL visible, instead of creating a hyperlink.

Additionally, icon::migrate_icon("index.Rmd") gives

Error: Not yet implemented.

mitchelloharawild commented 3 years ago

The icon package will now attempt to install the most recent version of the ionicons icon set, of which some icon names have changed. In version 5.2.3, the github icon is named "logo-github" rather than "social_github".

library(icon)
#> ── Installed icons ────────────────────────────────────────── icon 0.1.0.9000 ──
#> ✓ ionicons        5.2.3      ✓ material_design 4.0.0 
#> ✓ academicons     1.9.1      ✓ fontawesome     5.15.2
#> ✓ simple_icons    4.4.0
ionicons
#> Ionicons icon set (version 5.2.3)
ionicons("logo-github")

Created on 2021-02-16 by the reprex package (v0.3.0)


The broken links is possibly a bug, I am investigating further.


The migrate_icon() function was an idea that unfortunately is too complex to implement. The rewrite of icon not only changes the interface (which can be automatically migrated), but also allows installation of icon libraries at specific versions. Updating the icon name is trickier to migrate correctly.

mitchelloharawild commented 3 years ago

MRE for hyperlink issue:

---
title: "icon"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)

r icon::simple_icons("github")

r icon::simple_icons("github")

mitchelloharawild commented 3 years ago

The hyperlink issue appears to not apply to icon::fontawesome, so it might be a pandoc parsing issue with the format of icon::simple_icons() svg structure.

---
title: "icon"
output: html_document
---

`r icon::fontawesome("github")`

[`r icon::fontawesome("github")`](https://github.com/mitchelloharawild/icon)

image

francisbarton commented 3 years ago

Thanks for those helpful responses, and for investigating. It must be quite a task to migrate over to the new system but I hope you'll be glad you did it.

It looks like the best thing for me to do is switch all my icons over to fontawesome.

BTW icon::icon_find("github") doesn't include ionicons("logo-github") in its results for some reason.

-- Installed icons ----------------------------------------- icon 0.2.0 --
v ionicons        5.5.0      x google_material       
x academicons                v octicons        12.0.0
v simple_icons    4.11.0     v fontawesome     5.15.2
mitchelloharawild commented 3 years ago

At this stage icon_find() will only return exact matches on the name of the icon. However I can see it being useful to allow partial matching of icon names here... possibly also regular expressions.