nofollow_processor.rb 456 B

12345678910111213141516171819
  1. require 'asciidoctor/extensions'
  2. class NofollowProcessor < Asciidoctor::Extensions::InlineMacroProcessor
  3. use_dsl
  4. named :nofollow
  5. name_positional_attributes 'target', 'text'
  6. def process(parent, target, attrs)
  7. text = attrs['text'] || target
  8. (create_anchor parent, text, type: :link, target: target).tap |node|
  9. node.set_attr 'rel', 'nofollow'
  10. end
  11. end
  12. end
  13. Asciidoctor::Extensions.register do
  14. inline_macro NofollowProcessor
  15. end