2 require 'asciidoctor/extensions'
6 class LinkGitProcessor < Asciidoctor::Extensions::InlineMacroProcessor
11 def process(parent, target, attrs)
12 if parent.document.basebackend? 'html'
13 generate_html(parent, target, attrs)
14 elsif parent.document.basebackend? 'docbook'
15 generate_docbook(parent, target, attrs)
21 def generate_html(parent, target, attrs)
22 section = attrs.has_key?(1) ? "(#{attrs[1]})" : ''
23 prefix = parent.document.attr('git-relative-html-prefix') || ''
24 %(<a href="#{prefix}#{target}.html">#{target}#{section}</a>\n)
27 def generate_docbook(parent, target, attrs)
29 <refentrytitle>#{target}</refentrytitle><manvolnum>#{attrs[1]}</manvolnum>
37 Asciidoctor::Extensions.register do
38 inline_macro Git::Documentation::LinkGitProcessor, :linkgit