Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-doc
Path: blob/main/shared/lib/ManPageMacro/extension.rb
18086 views
1
require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'
2
3
include ::Asciidoctor
4
5
class ManPageMacro < Asciidoctor::Extensions::InlineMacroProcessor
6
use_dsl
7
8
named :man
9
name_positional_attributes 'section'
10
11
def process parent, target, attrs
12
manname = target
13
section = if (section = attrs['section'])
14
"#{section}"
15
else
16
""
17
end
18
url = %(https://man.freebsd.org/cgi/man.cgi?query=#{manname}&sektion=#{section}&format=html)
19
%(<a href="#{url}">#{manname}(#{section})</a>)
20
end
21
end
22
23