diff --git a/_extensions/iconify/_extension.yml b/_extensions/iconify/_extension.yml index 2b05ae4..8801ddb 100644 --- a/_extensions/iconify/_extension.yml +++ b/_extensions/iconify/_extension.yml @@ -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 diff --git a/_extensions/iconify/iconify.lua b/_extensions/iconify/iconify.lua index c01c9d4..7e9ce0d 100644 --- a/_extensions/iconify/iconify.lua +++ b/_extensions/iconify/iconify.lua @@ -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 = { @@ -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 @@ -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