mirror of
https://github.com/foo-dogsquared/asciidoctor-foodogsquared-extensions.git
synced 2025-01-30 22:57:56 +00:00
Add test and improve handling of subpath for man inline macro
This commit is contained in:
parent
9d3f69be6e
commit
2977870311
@ -34,8 +34,9 @@ module Asciidoctor::Foodogsquared::Extensions
|
|||||||
raise "no available manpage service #{attrs['service']}"
|
raise "no available manpage service #{attrs['service']}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
subpath = "#{attrs['subpath'].delete_prefix('/').delete_suffix('/')}/" if !attrs['subpath'].empty?
|
||||||
if !domain.nil?
|
if !domain.nil?
|
||||||
target = %(#{domain}/#{attrs['subpath'].delete_prefix '/'}#{manname}.#{attrs['volnum']})
|
target = %(#{domain}/#{subpath}#{manname}.#{attrs['volnum']})
|
||||||
doc.register :links, target
|
doc.register :links, target
|
||||||
node = create_anchor parent, text, type: :link, target: target
|
node = create_anchor parent, text, type: :link, target: target
|
||||||
else
|
else
|
||||||
|
@ -12,6 +12,17 @@ describe ManInlineMacro do
|
|||||||
(expect actual).to include expected.chomp
|
(expect actual).to include expected.chomp
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should process with the Debian Bookworm section' do
|
||||||
|
input = 'man:ls[1, service=debian, subpath=/bookworm]'
|
||||||
|
|
||||||
|
expected = <<~RESULT
|
||||||
|
<a href="https://manpages.debian.org/bookworm/ls.1">ls(1)</a>
|
||||||
|
RESULT
|
||||||
|
|
||||||
|
actual = (Asciidoctor.convert input).tr_s '\n', '\n'
|
||||||
|
(expect actual).to include expected.chomp
|
||||||
|
end
|
||||||
|
|
||||||
it 'should link to the Arch Linux manpage' do
|
it 'should link to the Arch Linux manpage' do
|
||||||
input = 'man:ls[volnum=1, service=arch]'
|
input = 'man:ls[volnum=1, service=arch]'
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user