mirror of
https://github.com/foo-dogsquared/asciidoctor-foodogsquared-extensions.git
synced 2025-01-30 22:57:56 +00:00
Add Repology link inline macro
This commit is contained in:
parent
c27fadcc9f
commit
cef163c722
@ -18,6 +18,7 @@ require_relative 'wikipedia-inline-macro/extension'
|
|||||||
require_relative 'package-indices-link-macro/extension'
|
require_relative 'package-indices-link-macro/extension'
|
||||||
require_relative 'fdroid-link-inline-macro/extension'
|
require_relative 'fdroid-link-inline-macro/extension'
|
||||||
require_relative 'musicbrainz-link-inline-macro/extension'
|
require_relative 'musicbrainz-link-inline-macro/extension'
|
||||||
|
require_relative 'repology-link-inline-macro/extension'
|
||||||
|
|
||||||
Asciidoctor::Extensions.register do
|
Asciidoctor::Extensions.register do
|
||||||
inline_macro ManInlineMacro
|
inline_macro ManInlineMacro
|
||||||
@ -43,4 +44,6 @@ Asciidoctor::Extensions.register do
|
|||||||
inline_macro FDroidLinkInlineMacro
|
inline_macro FDroidLinkInlineMacro
|
||||||
|
|
||||||
inline_macro MusicBrainzLinkInlineMacro
|
inline_macro MusicBrainzLinkInlineMacro
|
||||||
|
|
||||||
|
inline_macro RepologyLinkInlineMacro
|
||||||
end
|
end
|
||||||
|
27
lib/asciidoctor/repology-link-inline-macro/README.adoc
Normal file
27
lib/asciidoctor/repology-link-inline-macro/README.adoc
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
= Repology link inline macro
|
||||||
|
:toc:
|
||||||
|
|
||||||
|
|
||||||
|
An inline macro for shorthands Repology links.
|
||||||
|
|
||||||
|
|
||||||
|
== Synopsis
|
||||||
|
|
||||||
|
[source, asciidoc]
|
||||||
|
----
|
||||||
|
repology:$PROJECT[$CAPTION]
|
||||||
|
----
|
||||||
|
|
||||||
|
Where...
|
||||||
|
|
||||||
|
- `$PROJECT` is the project name listed in link:https://repology.org/projects/[Repology's project list].
|
||||||
|
|
||||||
|
- `$CAPTION` is the link text to be used.
|
||||||
|
By default, it will use the project name.
|
||||||
|
|
||||||
|
|
||||||
|
== Example usage
|
||||||
|
|
||||||
|
- `repology:beets[]` should link to the link:https://repology.org/project/beets/[Beets project page in Repology] with `beets` as the link text.
|
||||||
|
|
||||||
|
- `repology:beets[widely available in Linux distributions]` is the same as the previous item but with the link text replaced to `widely available in Linux distributions`.
|
18
lib/asciidoctor/repology-link-inline-macro/extension.rb
Normal file
18
lib/asciidoctor/repology-link-inline-macro/extension.rb
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class RepologyLinkInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
||||||
|
use_dsl
|
||||||
|
|
||||||
|
named :repology
|
||||||
|
name_positional_attributes 'caption'
|
||||||
|
|
||||||
|
def process(parent, target, attrs)
|
||||||
|
doc = parent.document
|
||||||
|
text = attrs['caption'] || target
|
||||||
|
url = %(https://repology.org/project/#{target})
|
||||||
|
|
||||||
|
doc.register :links, url
|
||||||
|
|
||||||
|
create_anchor parent, text, type: :link, target: url
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user