Class: Nexmo::Markdown::RelativeLinkFilter

Inherits:
Banzai::Filter
  • Object
show all
Defined in:
lib/nexmo_markdown_renderer/filters/relative_link_filter.rb

Instance Method Summary collapse

Instance Method Details

#call(input) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/nexmo_markdown_renderer/filters/relative_link_filter.rb', line 4

def call(input)
  @input = input

  document.css('a[href^="/"]').each_with_index do |link, _index|
    link[:href] = "/#{options[:locale]}#{link[:href]}" if options[:locale]
  end

  document.to_html
end