4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/nexmo_markdown_renderer/filters/external_link_filter.rb', line 4
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="/symbol/volta-icons.svg#Vlt-icon-open"></use></svg>
HEREDOC
end
end
end
@document.to_html
end
|