Add voidlinux and none for possible services in man inline macro

This commit is contained in:
Gabriel Arazas 2023-04-07 06:25:19 +08:00
parent 02bebfef70
commit ff59ce0fca
2 changed files with 26 additions and 15 deletions

View File

@ -35,6 +35,11 @@ This is also the default service when no value is given.
- `opensuse` uses https://manpages.opensuse.org.
- `voidlinux` use https://man.voidlinux.org.
- `none` uses none at all. :)
This is useful if the reference is not found anywhere.
Any invalid value raises an error.
--

View File

@ -13,22 +13,28 @@ class ManInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
suffix = (volnum = attrs['volnum']) ? %((#{volnum})) : ''
if doc.basebackend? 'html'
case attrs['service']
when 'debian'
domain = 'https://manpages.debian.org'
when 'arch'
domain = 'https://man.archlinux.org/man'
when 'opensuse'
domain = 'https://manpages.opensuse.org'
when 'voidlinux'
domain = 'https://man.voidlinux.org'
else
raise "no available manpage service #{attrs['service']}"
end
domain = case attrs['service']
when 'debian'
'https://manpages.debian.org'
when 'arch'
'https://man.archlinux.org/man'
when 'opensuse'
'https://manpages.opensuse.org'
when 'voidlinux'
'https://man.voidlinux.org'
when 'none'
nil
else
raise "no available manpage service #{attrs['service']}"
end
target = %(#{domain}/#{manname}.#{volnum})
doc.register :links, target
node = create_anchor parent, text, type: :link, target: target
if !domain.nil?
target = %(#{domain}/#{manname}.#{volnum})
doc.register :links, target
node = create_anchor parent, text, type: :link, target: target
else
node = create_inline parent, :quoted, manname
end
elsif doc.backend == 'manpage'
node = create_inline parent, :quoted, manname, type: :strong
else