Merge branch 'jc/denoise-rm-to-resolve'
[git] / Documentation / asciidoctor-extensions.rb
1 require 'asciidoctor'
2 require 'asciidoctor/extensions'
3
4 module Git
5   module Documentation
6     class LinkGitProcessor < Asciidoctor::Extensions::InlineMacroProcessor
7       use_dsl
8
9       named :chrome
10
11       def process(parent, target, attrs)
12         if parent.document.basebackend? 'html'
13           prefix = parent.document.attr('git-relative-html-prefix')
14           %(<a href="#{prefix}#{target}.html">#{target}(#{attrs[1]})</a>)
15         elsif parent.document.basebackend? 'docbook'
16           "<citerefentry>\n" \
17             "<refentrytitle>#{target}</refentrytitle>" \
18             "<manvolnum>#{attrs[1]}</manvolnum>\n" \
19           "</citerefentry>"
20         end
21       end
22     end
23   end
24 end
25
26 Asciidoctor::Extensions.register do
27   inline_macro Git::Documentation::LinkGitProcessor, :linkgit
28 end