Merge branch 'master' of https://github.com/Softcatala/git-po
[git/raj.git] / Documentation / asciidoctor-extensions.rb
blob0089e0cfb80df9a283b220ba4187e38f5612557d
1 require 'asciidoctor'
2 require 'asciidoctor/extensions'
4 module Git
5   module Documentation
6     class LinkGitProcessor < Asciidoctor::Extensions::InlineMacroProcessor
7       use_dsl
9       named :chrome
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
26 Asciidoctor::Extensions.register do
27   inline_macro Git::Documentation::LinkGitProcessor, :linkgit
28 end