Skip to content

Commit c6f368c

Browse files
authored
fix: Allow name copied from iconify website to be used (#20)
Fixes #19
1 parent a6213d1 commit c6f368c

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ To embed an icon, use the `{{< iconify >}}` shortcode[^1]. For example:
1818

1919
```default
2020
{{< iconify exploding-head >}}
21+
{{< iconify fluent-emoji exploding-head >}}
22+
{{< iconify fluent-emoji:exploding-head >}}
2123
{{< iconify exploding-head size=2xl >}}
2224
{{< iconify exploding-head size=5x rotate=180deg >}}
2325
{{< iconify exploding-head size=Huge >}}
@@ -40,10 +42,11 @@ Iconify API provides additional attributes: <https://docs.iconify.design/iconify
4042
Currently, this extension supports: `width`, `height`, `title`[^2], `label`[^2] (_i.e._, `aria-label`), `flip`, and `rotate`.
4143

4244
``` markdown
43-
{{< iconify <set> <icon-name> <size=...> <width=...> <height=...> <flip=...> <rotate=...> <title=...> <label=...> >}}
45+
{{< iconify <set> <icon> <size=...> <width=...> <height=...> <flip=...> <rotate=...> <title=...> <label=...> >}}
46+
{{< iconify <set:icon> <size=...> <width=...> <height=...> <flip=...> <rotate=...> <title=...> <label=...> >}}
4447
```
4548

46-
[^2]: `title` and `label` takes the following default value: `Icon <icon-name> from <set> Iconify.design set.`.
49+
[^2]: `title` and `label` takes the following default value: `Icon <icon> from <set> Iconify.design set.`.
4750

4851
### Sizing Icons
4952

_extensions/iconify/iconify.lua

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,16 @@ return {
7979
-- detect html (excluding epub which won't handle fa)
8080
if quarto.doc.is_format("html:js") then
8181
ensure_html_deps()
82-
local set = "fluent-emoji"
8382
local icon = pandoc.utils.stringify(args[1])
84-
if #args > 1 then
83+
local set = "fluent-emoji"
84+
85+
if string.find(icon, ":") then
86+
if #args > 1 then
87+
print('Warning: use "set:icon" or "set icon" syntax, not both.')
88+
end
89+
set = string.sub(icon, 1, string.find(icon, ":") - 1)
90+
icon = string.sub(icon, string.find(icon, ":") + 1)
91+
elseif #args > 1 then
8592
set = icon
8693
icon = pandoc.utils.stringify(args[2])
8794
end

example.qmd

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ format: html
66
This extension allows you to use [Iconify](https://icon-sets.iconify.design/) icons in your Quarto HTML documents.
77
It provides an `{{{< iconify >}}}` shortcode:
88

9-
- Mandatory `<icon-name>`:
9+
- Mandatory `<icon>`:
1010
``` markdown
11-
{{{< iconify <icon-name> >}}}
11+
{{{< iconify <icon> >}}}
12+
{{{< iconify <set:icon> >}}}
1213
```
1314

1415
- Optional `<set>` (default is `fluent-emoji`) `<size=...>`, `<width=...>`, `<height=...>`, `<flip=...>`, and `<rotate=...>`:
1516
``` markdown
16-
{{{< iconify <set> <icon-name> <size=...> <width=...> <height=...> <flip=...> <rotate=...> >}}}
17+
{{{< iconify <set> <icon> <size=...> <width=...> <height=...> <flip=...> <rotate=...> >}}}
1718
```
1819
If `<size=...>` is defined, `<width=...>` and `<height=...>` are not used.
1920
See <https://docs.iconify.design/iconify-icon/> for more details.
@@ -23,6 +24,8 @@ For example:
2324
| Shortcode | Icon |
2425
| -------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
2526
| `{{{< iconify exploding-head >}}}` | {{< iconify exploding-head >}} |
27+
| `{{{< iconify fluent-emoji exploding-head >}}}` | {{< iconify exploding-head >}} |
28+
| `{{{< iconify fluent-emoji:exploding-head >}}}` | {{< iconify exploding-head >}} |
2629
| `{{{< iconify exploding-head size=2xl >}}}` | {{< iconify exploding-head size=2xl >}} |
2730
| `{{{< iconify exploding-head size=5x rotate=180deg >}}}` | {{< iconify exploding-head size=5x rotate=180deg >}} |
2831
| `{{{< iconify exploding-head size=Huge >}}}` | {{< iconify exploding-head size=Huge >}} |

0 commit comments

Comments
 (0)