@@ -1,26 +1,22 @@
require 'asciidoctor/extensions'
-module Git
- module Documentation
- class LinkGitProcessor < Asciidoctor::Extensions::InlineMacroProcessor
- def process(parent, target, attrs)
- prefix = parent.document.attr('git-relative-html-prefix')
- if parent.document.doctype == 'book'
- "<ulink url=\"#{prefix}#{target}.html\">" \
- "#{target}(#{attrs[1]})</ulink>"
- elsif parent.document.basebackend? 'html'
- %(<a href="#{prefix}#{target}.html">#{target}(#{attrs[1]})</a>)
- elsif parent.document.basebackend? 'docbook'
- "<citerefentry>\n" \
- "<refentrytitle>#{target}</refentrytitle>" \
- "<manvolnum>#{attrs[1]}</manvolnum>\n" \
- "</citerefentry>"
- end
+Asciidoctor::Extensions.register do
+
+ inline_macro :linkgit do
+ process do |parent, target, attrs|
+ prefix = parent.document.attr('git-relative-html-prefix')
+ if parent.document.doctype == 'book'
+ "<ulink url=\"#{prefix}#{target}.html\">" \
+ "#{target}(#{attrs[1]})</ulink>"
+ elsif parent.document.basebackend? 'html'
+ %(<a href="#{prefix}#{target}.html">#{target}(#{attrs[1]})</a>)
+ elsif parent.document.basebackend? 'docbook'
+ "<citerefentry>\n" \
+ "<refentrytitle>#{target}</refentrytitle>" \
+ "<manvolnum>#{attrs[1]}</manvolnum>\n" \
+ "</citerefentry>"
end
end
end
-end
-Asciidoctor::Extensions.register do
- inline_macro Git::Documentation::LinkGitProcessor, :linkgit
end
There's no need to create verbose classes, we can do the same with a simple block. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> --- Documentation/asciidoctor-extensions.rb | 34 +++++++++++-------------- 1 file changed, 15 insertions(+), 19 deletions(-)