From f77b0d43211e7558bb19c9fa7a5243c6d46485c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Canouil?= <8896044+mcanouil@users.noreply.github.com> Date: Sun, 11 Aug 2024 12:47:12 +0200 Subject: [PATCH] fix: Allow to set/unset `inline` attribute (#32) --- README.md | 7 ++++--- _extensions/iconify/_extension.yml | 2 +- _extensions/iconify/iconify.lua | 8 +++++++- example.qmd | 4 ++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a0da4bb..2da5c2e 100644 --- a/README.md +++ b/README.md @@ -40,14 +40,15 @@ You can browse all of the available sets of icons here: ### Iconify Attributes Iconify API provides additional attributes: . -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 >}} -{{< iconify >}} +{{< iconify >}} +{{< iconify >}} ``` [^2]: `title` and `label` takes the following default value: `Icon from Iconify.design set.`. +[^3]: `inline` is a boolean attribute that can be set to `true` or `false`. Default is `true`. ### Sizing Icons diff --git a/_extensions/iconify/_extension.yml b/_extensions/iconify/_extension.yml index bdcb4e1..47e4246 100644 --- a/_extensions/iconify/_extension.yml +++ b/_extensions/iconify/_extension.yml @@ -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: diff --git a/_extensions/iconify/iconify.lua b/_extensions/iconify/iconify.lua index 9979b4d..d5c89a4 100644 --- a/_extensions/iconify/iconify.lua +++ b/_extensions/iconify/iconify.lua @@ -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', - '' + '' ) else return pandoc.Null() diff --git a/example.qmd b/example.qmd index f999e81..5ff83be 100644 --- a/example.qmd +++ b/example.qmd @@ -12,9 +12,9 @@ It provides an `{{{< iconify >}}}` shortcode: {{{< iconify >}}} ``` -- Optional `` (default is `fluent-emoji`) ``, ``, ``, ``, and ``: +- Optional `` (default is `fluent-emoji`) ``, ``, ``, ``, ``, ``, ``, and ``: ``` markdown - {{{< iconify >}}} + {{{< iconify >}}} ``` If `` is defined, `` and `` are not used. See for more details.