Skip to content

Commit

Permalink
fix: Allow to set/unset inline attribute (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcanouil authored Aug 11, 2024
1 parent 3fb92cf commit f77b0d4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ You can browse all of the available sets of icons here:
### Iconify Attributes

Iconify API provides additional attributes: <https://docs.iconify.design/iconify-icon/>.
Currently, this extension supports: `width`, `height`, `title`[^2], `label`[^2] (_i.e._, `aria-label`), `flip`, and `rotate`.
Currently, this extension supports: `size`, `width`, `height`, `flip`, `rotate`, `title`[^2], `label`[^2] (_i.e._, `aria-label`), and `inline`[^3].

``` markdown
{{< iconify <set> <icon> <size=...> <width=...> <height=...> <flip=...> <rotate=...> <title=...> <label=...> >}}
{{< iconify <set:icon> <size=...> <width=...> <height=...> <flip=...> <rotate=...> <title=...> <label=...> >}}
{{< iconify <set> <icon> <size=...> <width=...> <height=...> <flip=...> <rotate=...> <title=...> <label=...> <inline=...> >}}
{{< iconify <set:icon> <size=...> <width=...> <height=...> <flip=...> <rotate=...> <title=...> <label=...> <inline=...> >}}
```

[^2]: `title` and `label` takes the following default value: `Icon <icon> from <set> Iconify.design set.`.
[^3]: `inline` is a boolean attribute that can be set to `true` or `false`. Default is `true`.

### Sizing Icons

Expand Down
2 changes: 1 addition & 1 deletion _extensions/iconify/_extension.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
title: Iconify support
author: Mickaël Canouil
version: 2.1.1
version: 2.1.2
quarto-required: ">=1.2.280"
contributes:
shortcodes:
Expand Down
8 changes: 7 additions & 1 deletion _extensions/iconify/iconify.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,15 @@ return {
attributes = attributes .. ' rotate="' .. rotate .. '"'
end

local inline = pandoc.utils.stringify(kwargs["inline"])
if is_empty(inline) or inline ~= "false" then
attributes = ' inline ' .. attributes
end


return pandoc.RawInline(
'html',
'<iconify-icon inline=true role="img"' .. attributes .. '></iconify-icon>'
'<iconify-icon role="img"' .. attributes .. '></iconify-icon>'
)
else
return pandoc.Null()
Expand Down
4 changes: 2 additions & 2 deletions example.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ It provides an `{{{< iconify >}}}` shortcode:
{{{< iconify <set:icon> >}}}
```

- Optional `<set>` (default is `fluent-emoji`) `<size=...>`, `<width=...>`, `<height=...>`, `<flip=...>`, and `<rotate=...>`:
- Optional `<set>` (default is `fluent-emoji`) `<size=...>`, `<width=...>`, `<height=...>`, `<flip=...>`, `<rotate=...>`, `<title=...>`, `<label=...>`, and `<inline=...>`:
``` markdown
{{{< iconify <set> <icon> <size=...> <width=...> <height=...> <flip=...> <rotate=...> >}}}
{{{< iconify <set> <icon> <size=...> <width=...> <height=...> <flip=...> <rotate=...> <title=...> <label=...> <inline=...> >}}}
```
If `<size=...>` is defined, `<width=...>` and `<height=...>` are not used.
See <https://docs.iconify.design/iconify-icon/> for more details.
Expand Down

0 comments on commit f77b0d4

Please sign in to comment.