mirror of
https://github.com/foo-dogsquared/website.git
synced 2025-01-31 19:57:57 +00:00
23 lines
711 B
Ruby
23 lines
711 B
Ruby
|
class ManInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
||
|
use_dsl
|
||
|
|
||
|
named :man
|
||
|
name_positional_attributes 'volnum'
|
||
|
|
||
|
def process parent, target, attrs
|
||
|
doc = parent.document
|
||
|
text = manname = target
|
||
|
suffix = (volnum = attrs['volnum']) ? %((#{volnum})) : ''
|
||
|
if doc.basebackend? 'html'
|
||
|
target = %(#{manname}#{doc.outfilesuffix})
|
||
|
doc.register :links, target
|
||
|
node = create_anchor parent, text, type: :link, target: target
|
||
|
elsif doc.backend == 'manpage'
|
||
|
node = create_inline parent, :quoted, manname, type: :strong
|
||
|
else
|
||
|
node = create_inline parent, :quoted, manname
|
||
|
end
|
||
|
create_inline parent, :quoted, %(#{node.convert}#{suffix})
|
||
|
end
|
||
|
end
|