mirror of
https://github.com/foo-dogsquared/asciidoctor-foodogsquared-extensions.git
synced 2025-01-30 22:57:56 +00:00
Add full
options attribute for SWHID inline macro
This commit is contained in:
parent
1c1deb96eb
commit
627ccd3f20
@ -15,6 +15,14 @@ swh:$SWHID[$CAPTION]
|
||||
If no caption is given, the link text will be the core identifier of the SWHID.
|
||||
|
||||
|
||||
== Attributes
|
||||
|
||||
You can configure certain behavior of the macro with the link:https://docs.asciidoctor.org/asciidoc/latest/attributes/options/[options attribute].
|
||||
Here's a list of them...
|
||||
|
||||
- `full` will make the entire SWHID as the default link text.
|
||||
|
||||
|
||||
== Extra notes
|
||||
|
||||
You would use like in the following form `swh:swh:1:snp:6ea7d28dfd4789609e0be2b64179fc9c12931beb[]` but you could also cut off `swh:` from the SWHID if you want to (i.e., `swh:1:snp:6ea7d28dfd4789609e0be2b64179fc9c12931beb[]`) to make it aesthetically pleasing.
|
||||
|
@ -12,9 +12,12 @@ class SWHInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
||||
# We're only considering `swh:` starting with the scheme version. Also, it
|
||||
# looks nice aesthetically.
|
||||
swhid = target.start_with?('swh:') ? target : %(swh:#{target})
|
||||
swhid_core_identifier = (swhid.split ';').at 0
|
||||
|
||||
text = attrs['caption'] || swhid_core_identifier
|
||||
default_caption = if attrs.key? 'full-option'
|
||||
swhid
|
||||
else
|
||||
swhid.split(';').at(0)
|
||||
end
|
||||
text = attrs['caption'] || default_caption
|
||||
target = %(https://archive.softwareheritage.org/#{swhid})
|
||||
|
||||
doc.register :links, target
|
||||
|
Loading…
Reference in New Issue
Block a user