Class: Nanoc2::Filters::RelativizePathsInHTML

Inherits:
Nanoc2::Filter show all
Includes:
Helpers::LinkTo
Defined in:
lib/nanoc2/filters/relativize_paths_in_html.rb

Constant Summary

Constants inherited from Nanoc2::Filter

Nanoc2::Filter::EXTENSIONS_MAP

Constants inherited from Plugin

Plugin::MAP

Instance Method Summary collapse

Methods included from Helpers::LinkTo

#link_to, #link_to_unless_current, #relative_path_to

Methods included from Helpers::HTMLEscape

#html_escape

Methods inherited from Nanoc2::Filter

#assigns, #filename, #initialize

Methods inherited from Plugin

identifier, identifiers, named, register

Constructor Details

This class inherits a constructor from Nanoc2::Filter

Instance Method Details

#run(content) ⇒ Object



9
10
11
12
13
# File 'lib/nanoc2/filters/relativize_paths_in_html.rb', line 9

def run(content)
  content.gsub(/(src|href)=(['"]?)(\/.+?)\2([ >])/) do
    $1 + '=' + $2 + relative_path_to($3) + $2 + $4
  end
end