Class: Banzai::Filter::RelativeLinkFilter

Inherits:
HTML::Pipeline::Filter
  • Object
show all
Defined in:
lib/banzai/filter/relative_link_filter.rb

Overview

HTML filter that “fixes” relative links to files in a repository.

Context options:

:commit
:project
:project_wiki
:ref
:requested_path

Instance Method Summary collapse

Instance Method Details

#callObject


14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/banzai/filter/relative_link_filter.rb', line 14

def call
  return doc unless linkable_files?

  doc.search('a:not(.gfm)').each do |el|
    process_link_attr el.attribute('href')
  end

  doc.search('img').each do |el|
    process_link_attr el.attribute('src')
  end

  doc
end