Sha256: 6ad2990f7aa9e07de9a3d1a6800a99c1b8caafb277570e8791182f84362cfa7f
Contents?: true
Size: 947 Bytes
Versions: 21
Compression:
Stored size: 947 Bytes
Contents
module Nexmo module OAS module Renderer module Filters class ExternalLink < Banzai::Filter def call(input) @input = input document.css('a').each_with_index do |link, _index| if link['href']&.start_with?('http') && link['class'] && !link['class'].include?('no-external-marker') link['target'] = '_blank' if link.css('svg').empty? link.add_child <<~HEREDOC <svg class="Vlt-icon Vlt-icon--smaller Vlt-icon--text-bottom Vlt-blue-dark"><use xlink:href="/assets/symbol/volta-icons.svg#Vlt-icon-open"></use></svg> HEREDOC end end end @document.to_html end private def document @document ||= Nokogiri::HTML::DocumentFragment.parse(@input) end end end end end end
Version data entries
21 entries across 21 versions & 1 rubygems