asciidoctor-extensions.rb (816B)
1require 'asciidoctor' 2require 'asciidoctor/extensions' 3 4module Perf 5 module Documentation 6 class LinkPerfProcessor < Asciidoctor::Extensions::InlineMacroProcessor 7 use_dsl 8 9 named :chrome 10 11 def process(parent, target, attrs) 12 if parent.document.basebackend? 'html' 13 %(<a href="#{target}.html">#{target}(#{attrs[1]})</a>\n) 14 elsif parent.document.basebackend? 'manpage' 15 "#{target}(#{attrs[1]})" 16 elsif parent.document.basebackend? 'docbook' 17 "<citerefentry>\n" \ 18 "<refentrytitle>#{target}</refentrytitle>" \ 19 "<manvolnum>#{attrs[1]}</manvolnum>\n" \ 20 "</citerefentry>\n" 21 end 22 end 23 end 24 end 25end 26 27Asciidoctor::Extensions.register do 28 inline_macro Perf::Documentation::LinkPerfProcessor, :linkperf 29end