Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-doc
Path: blob/main/shared/lib/GitReferencesMacro/extension.rb
18086 views
1
require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'
2
3
include ::Asciidoctor
4
5
class GitReferencesMacro < Asciidoctor::Extensions::InlineMacroProcessor
6
use_dsl
7
8
named :gitref
9
10
def process parent, target, attrs
11
hash = target
12
repository = if (repository = attrs['repository'])
13
"#{repository}"
14
else
15
"src"
16
end
17
length = if (length = attrs['length'])
18
length.to_i
19
else
20
12
21
end
22
url = %(https://cgit.freebsd.org/#{repository}/commit/?id=#{hash})
23
%(<a href="#{url}">#{hash[0, length]}</a>)
24
end
25
end
26
27