add _extensions

This commit is contained in:
2026-05-21 13:37:53 +08:00
parent 6a9a5fc90e
commit 61bd0bea2f
252 changed files with 33972 additions and 1 deletions
@@ -0,0 +1,6 @@
title: Share Post on Social Media
author: David Schoch
version: 1.0.0
contributes:
filters:
- social-share.lua
@@ -0,0 +1,7 @@
title: Font Awesome support
author: Carlos Scheidegger
version: 1.2.0
quarto-required: ">=1.2.269"
contributes:
shortcodes:
- fontawesome.lua
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,30 @@
.fa-tiny {
font-size: 0.5em;
}
.fa-scriptsize {
font-size: 0.7em;
}
.fa-footnotesize {
font-size: 0.8em;
}
.fa-small {
font-size: 0.9em;
}
.fa-normalsize {
font-size: 1em;
}
.fa-large {
font-size: 1.2em;
}
.fa-Large {
font-size: 1.5em;
}
.fa-LARGE {
font-size: 1.75em;
}
.fa-huge {
font-size: 2em;
}
.fa-Huge {
font-size: 2.5em;
}
@@ -0,0 +1,83 @@
local function ensureLatexDeps()
quarto.doc.use_latex_package("fontawesome5")
end
local function ensureHtmlDeps()
quarto.doc.add_html_dependency({
name = 'fontawesome6',
version = '1.2.0',
stylesheets = { 'assets/css/all.min.css', 'assets/css/latex-fontsize.css' }
})
end
local function isEmpty(s)
return s == nil or s == ''
end
local function isValidSize(size)
local validSizes = {
"tiny",
"scriptsize",
"footnotesize",
"small",
"normalsize",
"large",
"Large",
"LARGE",
"huge",
"Huge"
}
for _, v in ipairs(validSizes) do
if v == size then
return size
end
end
return ""
end
return {
["fa"] = function(args, kwargs)
local group = "solid"
local icon = pandoc.utils.stringify(args[1])
if #args > 1 then
group = icon
icon = pandoc.utils.stringify(args[2])
end
local title = pandoc.utils.stringify(kwargs["title"])
if not isEmpty(title) then
title = " title=\"" .. title .. "\""
end
local label = pandoc.utils.stringify(kwargs["label"])
if isEmpty(label) then
label = " aria-label=\"" .. icon .. "\""
else
label = " aria-label=\"" .. label .. "\""
end
local size = pandoc.utils.stringify(kwargs["size"])
-- detect html (excluding epub which won't handle fa)
if quarto.doc.is_format("html:js") then
ensureHtmlDeps()
if not isEmpty(size) then
size = " fa-" .. size
end
return pandoc.RawInline(
'html',
"<i class=\"fa-" .. group .. " fa-" .. icon .. size .. "\"" .. title .. label .. "></i>"
)
-- detect pdf / beamer / latex / etc
elseif quarto.doc.is_format("pdf") then
ensureLatexDeps()
if isEmpty(isValidSize(size)) then
return pandoc.RawInline('tex', "\\faIcon{" .. icon .. "}")
else
return pandoc.RawInline('tex', "{\\" .. size .. "\\faIcon{" .. icon .. "}}")
end
else
return pandoc.Null()
end
end
}
@@ -0,0 +1,112 @@
/*adapted from: https://www.remysheppard.com/blog/hugo-share-buttons/*/
.social-share {
display: flex;
flex-direction: row;
justify-content: left;
flex-wrap: wrap;
}
.social-share a {
border-radius: 25px;
padding: 0.25rem 0.5rem;
background: white;
border: 1px solid transparent;
transition: background ease 0.3s, color ease 0.3s;
margin-bottom: 1em;
margin-left: 0.5em;
text-decoration: none;
}
.social-share a:before {
display: none;
}
.social-share a.facebook {
border-color: #4267B2;
color: #4267B2;
}
.social-share a.facebook:hover {
background: #4267B2;
color: white;
}
.social-share a.twitter {
border-color: #1DA1F2;
color: #1DA1F2;
}
.social-share a.twitter:hover {
background: #1DA1F2;
color: white;
}
.social-share a.reddit {
border-color: #FF4500;
color: #FF4500;
}
.social-share a.reddit:hover {
background: #FF4500;
color: white;
}
.social-share a.stumbleupon {
border-color: #EB471D;
color: #EB471D;
}
.social-share a.stumbleupon:hover {
background: #EB471D;
color: white;
}
.social-share a.tumblr {
border-color: #35465C;
color: #35465C;
}
.social-share a.tumblr:hover {
background: #35465C;
color: white;
}
.social-share a.linkedin {
border-color: #2867B2;
color: #2867B2;
}
.social-share a.linkedin:hover {
background: #2867B2;
color: white;
}
.social-share a.email {
border-color: #00A4EF;
color: #00A4EF;
}
.social-share a.email:hover {
background: #00A4EF;
color: white;
}
.social-share a.mastodon {
border-color: #6364FF;
color: #6364FF;
}
.social-share a.mastodon:hover {
background: #6364FF;
color: white;
}
.social-share a.bsky {
border-color: #0A7AFF;
color: #0A7AFF;
}
.social-share a.bsky:hover {
border-color: #0A7AFF;
color: white;
}
@@ -0,0 +1,97 @@
local function ensureHtmlDeps()
quarto.doc.addHtmlDependency({
name = 'social-share',
version = '1.0.0',
stylesheets = {
'social-share.css',
'_extensions/quarto-ext/fontawesome/assets/css/all.min.css'
}
})
end
function Meta(m)
ensureHtmlDeps()
local share_start = '<div class= "page-columns page-rows-contents page-layout-article"><div class="social-share">'
if m.share.divclass then
local divclass = pandoc.utils.stringify(m.share.divclass)
share_start = '<div class= "' .. divclass .. '"><div class="social-share">'
end
local share_end = '</div></div>'
local share_text = share_start
local share_url = pandoc.utils.stringify(m.share.permalink)
if m.share.description ~= nil then
post_title = pandoc.utils.stringify(m.share.description)
else
post_title = pandoc.utils.stringify(m.title)
end
if m.share.twitter then
share_text = share_text ..
'<a href="https://twitter.com/share?url=' ..
share_url ..
'&text=' .. post_title .. '" target="_blank" class="twitter"><i class="fab fa-twitter fa-fw fa-lg"></i></a>'
end
if m.share.linkedin then
share_text = share_text ..
'<a href="https://www.linkedin.com/shareArticle?url=' ..
share_url ..
'&title=' ..
post_title .. '" target="_blank" class="linkedin"><i class="fa-brands fa-linkedin-in fa-fw fa-lg"></i></a>'
end
if m.share.email then
share_text = share_text ..
' <a href="mailto:?subject=' ..
post_title ..
'&body=Check out this link:' ..
share_url .. '" target="_blank" class="email"><i class="fa-solid fa-envelope fa-fw fa-lg"></i></a>'
end
if m.share.facebook then
share_text = share_text ..
'<a href="https://www.facebook.com/sharer.php?u=' ..
share_url .. '" target="_blank" class="facebook"><i class="fab fa-facebook-f fa-fw fa-lg"></i></a>'
end
if m.share.reddit then
share_text = share_text ..
'<a href="https://reddit.com/submit?url=' ..
share_url ..
'&title=' ..
post_title .. '" target="_blank" class="reddit"> <i class="fa-brands fa-reddit-alien fa-fw fa-lg"></i></a>'
end
if m.share.stumble then
share_text = share_text ..
'<a href="https://www.stumbleupon.com/submit?url=' ..
share_url ..
'&title=' ..
post_title ..
'" target="_blank" class="stumbleupon"><i class="fa-brands fa-stumbleupon fa-fw fa-lg"></i></a>'
end
if m.share.tumblr then
share_text = share_text ..
'<a href="https://www.tumblr.com/share/link?url=' ..
share_url ..
'&name=' ..
post_title .. '" target="_blank" class="tumblr"><i class="fa-brands fa-tumblr fa-fw fa-lg"></i></a>'
end
if m.share.mastodon then
share_text = share_text ..
'<a href="javascript:void(0);" onclick="var mastodon_instance=prompt(\'Mastodon Instance / Server Name?\'); if(typeof mastodon_instance===\'string\' &amp;&amp; mastodon_instance.length){this.href=\'https://\'+mastodon_instance+\'/share?text=' ..
post_title ..
' ' ..
share_url ..
'\'}else{return false;}" target="_blank" class="mastodon"><i class="fa-brands fa-mastodon fa-fw fa-lg"></i></a>'
end
if m.share.bsky then
share_text = share_text ..
'<a href="https://bsky.app/intent/compose?text=' ..
share_url ..
' ' ..
post_title ..
'" target="_blank" class="bsky"><i class="fa-brands fa-bluesky"></i></a>'
end
share_text = share_text .. share_end
if m.share.location then
quarto.doc.includeText(pandoc.utils.stringify(m.share.location), share_text)
else
quarto.doc.includeText("after-body", share_text)
end
end