Class: Asciidoctor::Foodogsquared::Extensions::FDroidInlineMacro

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

Instance Method Summary collapse

Instance Method Details

#process(parent, target, attrs) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/asciidoctor/foodogsquared/extensions/fdroid-inline-macro.rb', line 14

def process(parent, target, attrs)
  doc = parent.document

  app_id = target
   = %(https://gitlab.com/fdroid/fdroiddata/-/raw/master/metadata/#{app_id}.yml)

   = OpenURI.open_uri() { |f| YAML.safe_load(f.read) }
  attrs['caption'] ||= ['AutoName']

  url = %(https://f-droid.org/#{attrs['lang']}/packages/#{app_id})
  doc.register :links, url
  create_anchor parent, attrs['caption'], type: :link, target: url
end