Path: blob/main/dev-docs/feature-format-matrix/_extensions/quarto-ext/fontawesome/fontawesome.lua
3589 views
local function ensureLatexDeps()1quarto.doc.use_latex_package("fontawesome5")2end34local function ensureHtmlDeps()5quarto.doc.add_html_dependency({6name = 'fontawesome6',7version = '0.1.0',8stylesheets = {'assets/css/all.css', 'assets/css/latex-fontsize.css'}9})10end1112local function isEmpty(s)13return s == nil or s == ''14end1516local function isValidSize(size)17local validSizes = {18"tiny",19"scriptsize",20"footnotesize",21"small",22"normalsize",23"large",24"Large",25"LARGE",26"huge",27"Huge"28}29for _, v in ipairs(validSizes) do30if v == size then31return size32end33end34return ""35end3637return {38["fa"] = function(args, kwargs)3940local group = "solid"41local icon = pandoc.utils.stringify(args[1])42if #args > 1 then43group = icon44icon = pandoc.utils.stringify(args[2])45end4647local title = pandoc.utils.stringify(kwargs["title"])48if not isEmpty(title) then49title = " title=\"" .. title .. "\""50end5152local label = pandoc.utils.stringify(kwargs["label"])53if isEmpty(label) then54label = " aria-label=\"" .. icon .. "\""55else56label = " aria-label=\"" .. label .. "\""57end5859local size = pandoc.utils.stringify(kwargs["size"])6061-- detect html (excluding epub which won't handle fa)62if quarto.doc.is_format("html:js") then63ensureHtmlDeps()64if not isEmpty(size) then65size = " fa-" .. size66end67return pandoc.RawInline(68'html',69"<i class=\"fa-" .. group .. " fa-" .. icon .. size .. "\"" .. title .. label .. "></i>"70)71-- detect pdf / beamer / latex / etc72elseif quarto.doc.is_format("pdf") then73ensureLatexDeps()74if isEmpty(isValidSize(size)) then75return pandoc.RawInline('tex', "\\faIcon{" .. icon .. "}")76else77return pandoc.RawInline('tex', "{\\" .. size .. "\\faIcon{" .. icon .. "}}")78end79else80return pandoc.Null()81end82end83}848586