Commit | Line | Data |
---|---|---|
ffef80ec TI |
1 | require 'asciidoctor' |
2 | require 'asciidoctor/extensions' | |
3 | ||
4 | module 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 | |
25 | end | |
26 | ||
27 | Asciidoctor::Extensions.register do | |
28 | inline_macro Perf::Documentation::LinkPerfProcessor, :linkperf | |
29 | end |