Class: Asciidoctor::Foodogsquared::Extensions::WikipediaInlineMacro

Inherits:
Extensions::InlineMacroProcessor
  • Object
show all
Defined in:
lib/asciidoctor/foodogsquared/extensions/wikipedia-inline-macro.rb

Instance Method Summary collapse

Instance Method Details

#process(parent, target, attrs) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/asciidoctor/foodogsquared/extensions/wikipedia-inline-macro.rb', line 13

def process(parent, target, attrs)
  caption = attrs['caption'] || target
  parser = URI::Parser.new
  page = parser.escape target
  link = %(https://#{attrs['lang']}.wikipedia.org/wiki/#{page})
  node = create_anchor parent, caption, type: :link, target: link

  create_inline parent, :quoted, node.convert
end