Skip to content

Commit

Permalink
fix: Update/Release for Quarto v1.2 (#6)
Browse files Browse the repository at this point in the history
Fixes #5
  • Loading branch information
mcanouil authored Dec 27, 2022
1 parent 090f533 commit ee8f6db
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
3 changes: 2 additions & 1 deletion _extensions/iconify/_extension.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
title: Iconify support
author: Mickaël Canouil
version: 0.3.0
version: 1.0.0
quarto-required: ">=1.2.280"
contributes:
shortcodes:
- iconify.lua
32 changes: 16 additions & 16 deletions _extensions/iconify/iconify.lua
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
local function ensureHtmlDeps()
quarto.doc.addHtmlDependency({
local function ensure_html_deps()
quarto.doc.add_html_dependency({
name = 'iconify',
version = '1.0.0-beta.2',
scripts = {"iconify-icon.min.js"}
})
end

local function isEmpty(s)
local function is_empty(s)
return s == nil or s == ''
end

local function isValidSize(size)
if isEmpty(size) then
local function is_valid_size(size)
if is_empty(size) then
return ''
end
local size_table = {
Expand Down Expand Up @@ -53,8 +53,8 @@ end
return {
["iconify"] = function(args, kwargs)
-- detect html (excluding epub which won't handle fa)
if quarto.doc.isFormat("html:js") then
ensureHtmlDeps()
if quarto.doc.is_format("html:js") then
ensure_html_deps()
local set = "fluent-emoji"
local icon = pandoc.utils.stringify(args[1])
if #args > 1 then
Expand All @@ -65,41 +65,41 @@ return {
local attributes = ' icon="' .. set .. ':' .. icon .. '"'
local label = '"Icon ' .. icon .. ' from ' .. set .. ' Iconify.design set."'

local size = isValidSize(pandoc.utils.stringify(kwargs["size"]))
if not isEmpty(size) then
local size = is_valid_size(pandoc.utils.stringify(kwargs["size"]))
if not is_empty(size) then
attributes = attributes .. ' style="' .. size .. '"'
end

local aria_label = pandoc.utils.stringify(kwargs["label"])
if isEmpty(aria_label) then
if is_empty(aria_label) then
aria_label = ' aria-label="' .. label .. '"'
else
attributes = attributes .. aria_label
end
local title = pandoc.utils.stringify(kwargs["title"])
if isEmpty(title) then
if is_empty(title) then
title = ' title="' .. label .. '"'
else
attributes = attributes .. title
end
-- local style = pandoc.utils.stringify(kwargs["style"])
-- if not isEmpty(style) then
-- if not is_empty(style) then
-- local attributes = attributes .. ' style="' .. style .. '"'
-- end
local width = pandoc.utils.stringify(kwargs["width"])
if not isEmpty(width) and isEmpty(size) then
if not is_empty(width) and is_empty(size) then
attributes = attributes .. ' width="' .. width .. '"'
end
local height = pandoc.utils.stringify(kwargs["height"])
if not isEmpty(height) and isEmpty(size) then
if not is_empty(height) and is_empty(size) then
attributes = attributes .. ' height="' .. height .. '"'
end
local flip = pandoc.utils.stringify(kwargs["flip"])
if not isEmpty(flip) then
if not is_empty(flip) then
attributes = attributes .. ' flip="' .. flip.. '"'
end
local rotate = pandoc.utils.stringify(kwargs["rotate"])
if not isEmpty(rotate) then
if not is_empty(rotate) then
attributes = attributes .. ' rotate="' .. rotate .. '"'
end

Expand Down

0 comments on commit ee8f6db

Please sign in to comment.