2 require 'asciidoctor/extensions'
6 class LinkGitProcessor < Asciidoctor::Extensions::InlineMacroProcessor
11 def process(parent, target, attrs)
12 prefix = parent.document.attr('git-relative-html-prefix')
13 if parent.document.doctype == 'book'
14 "<ulink url=\"#{prefix}#{target}.html\">" \
15 "#{target}(#{attrs[1]})</ulink>"
16 elsif parent.document.basebackend? 'html'
17 %(<a href="#{prefix}#{target}.html">#{target}(#{attrs[1]})</a>)
18 elsif parent.document.basebackend? 'docbook'
20 "<refentrytitle>#{target}</refentrytitle>" \
21 "<manvolnum>#{attrs[1]}</manvolnum>\n" \
27 class DocumentPostProcessor < Asciidoctor::Extensions::Postprocessor
28 def process document, output
29 if document.basebackend? 'docbook'
30 mansource = document.attributes['mansource']
31 manversion = document.attributes['manversion']
32 manmanual = document.attributes['manmanual']
34 "<refmiscinfo class=\"source\">#{mansource}</refmiscinfo>\n" \
35 "<refmiscinfo class=\"version\">#{manversion}</refmiscinfo>\n" \
36 "<refmiscinfo class=\"manual\">#{manmanual}</refmiscinfo>\n"
37 output = output.sub(/<\/refmeta>/, new_tags + "</refmeta>")
45 Asciidoctor::Extensions.register do
46 inline_macro Git::Documentation::LinkGitProcessor, :linkgit
47 postprocessor Git::Documentation::DocumentPostProcessor