-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: rewrite the whole API (#10)
- Loading branch information
Showing
9 changed files
with
105 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
_extensions/version-badge/_extension.yml → _extensions/badge/_extension.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
title: version-badge | ||
title: badge | ||
author: Mickaël Canouil | ||
version: 1.2.0 | ||
version: 2.0.0 | ||
quarto-required: ">=1.3.0" | ||
contributes: | ||
shortcodes: | ||
- version-badge.lua | ||
- badge.lua |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.quarto-badge { | ||
vertical-align: text-bottom; | ||
font-size: .65em; | ||
} | ||
|
||
.nav-link .quarto-badge { | ||
display: none; | ||
} | ||
|
||
.quarto-badge-href { | ||
text-decoration: none; | ||
color: inherit; | ||
} | ||
|
||
a.nav-link.quarto-badge-href { | ||
display: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
return { | ||
['badge'] = function(args, kwargs, meta) | ||
if quarto.doc.is_format("html") then | ||
quarto.doc.add_html_dependency({ | ||
name = 'badge', | ||
stylesheets = {"badge.css"} | ||
}) | ||
local badgeKey = pandoc.utils.stringify(args[1]) | ||
local badgeValue = pandoc.utils.stringify(args[2]) | ||
local badgeContent = "" | ||
local metaBadgeHref = "" | ||
for _, badge in ipairs(meta["badge"]) do | ||
local metaBadgeKey = pandoc.utils.stringify(badge["key"]) | ||
local metaBadgeClass = "" | ||
if badge["class"] ~= "" and badge["class"] ~= nil then | ||
metaBadgeClass = pandoc.utils.stringify(badge["class"]) | ||
end | ||
if metaBadgeKey == badgeKey then | ||
if badge["href"] ~= "" and badge["href"] ~= nil then | ||
local metaBadgeHref = pandoc.utils.stringify(badge["href"]) | ||
if metaBadgeHref:find("{{value}}") then | ||
metaBadgeHref = metaBadgeHref:gsub("{{value}}", badgeValue) | ||
end | ||
badgeValue = '<a ' .. | ||
'href="' .. metaBadgeHref .. '"' .. | ||
'class="quarto-badge-href"' .. | ||
'>' .. | ||
badgeValue .. | ||
'</a>' | ||
end | ||
local style = "" | ||
if (badge["colour"] ~= "" and badge["colour"] ~= nil) or (badge["color"] ~= "" and badge["color"] ~= nil) then | ||
metaBadgeColor = pandoc.utils.stringify(badge["colour"] or badge["color"]) | ||
style = 'style="background-color: ' .. metaBadgeColor .. ';' .. '"' | ||
end | ||
badgeContent = '<span class="badge rounded-pill quarto-badge ' .. metaBadgeClass .. '" ' .. style .. '>' .. | ||
badgeValue .. | ||
'</span>' | ||
end | ||
end | ||
return pandoc.RawInline('html', badgeContent) | ||
end | ||
end | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,29 @@ | ||
--- | ||
title: "Version Badge Example" | ||
title: "Quarto Badge Example" | ||
toc: true | ||
code-tools: true | ||
version-badge: | ||
version: 1.4 | ||
type: pre-release | ||
default: release | ||
changelog: https://github.com/mcanouil/quarto-version-badge/releases/tag/{{version}} | ||
prefix: "v" | ||
badge: | ||
- key: current | ||
colour: springgreen | ||
- key: future | ||
class: bg-danger | ||
href: https://github.com/mcanouil/quarto-badge | ||
- key: old | ||
class: bg-warning | ||
href: https://github.com/mcanouil/quarto-badge/releases/tag/{{value}} | ||
--- | ||
|
||
## {{< v 1.0 >}} A feature here from ages ago | ||
## {{< badge current 1.1 >}} A feature here from a while ago | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam euismod, nisl | ||
eget aliquam ultricies, nunc nisl aliquet nunc, quis aliquam nunc nisl eu | ||
|
||
## {{< v 1.1 >}} A feature here from a while ago | ||
## {{< badge future 1.4 >}} A feature not quite here yet | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam euismod, nisl | ||
eget aliquam ultricies, nunc nisl aliquet nunc, quis aliquam nunc nisl eu | ||
|
||
## {{< v 1.4 >}} A feature not quite here yet | ||
## {{< badge old 1.0 >}} A feature here from ages ago | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam euismod, nisl | ||
eget aliquam ultricies, nunc nisl aliquet nunc, quis aliquam nunc nisl eu |