Update Wikipedia link inline macro

This commit is contained in:
Gabriel Arazas 2023-05-15 14:01:58 +08:00
parent bea743f019
commit 7cfc8878c3
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC

View File

@ -11,7 +11,8 @@ class WikipediaInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
def process(parent, target, attrs) def process(parent, target, attrs)
caption = attrs['caption'] || target caption = attrs['caption'] || target
page = URI.encode_www_form_component target parser = URI::Parser.new
page = parser.escape target
link = %(https://#{attrs['lang']}.wikipedia.org/wiki/#{page}) link = %(https://#{attrs['lang']}.wikipedia.org/wiki/#{page})
node = create_anchor parent, caption, type: :link, target: link node = create_anchor parent, caption, type: :link, target: link