asciidoctor-extensions.rb 816 B

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