Class: Perron::HtmlProcessor::TargetBlank

Inherits:
Base
  • Object
show all
Defined in:
lib/perron/html_processor/target_blank.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Perron::HtmlProcessor::Base

Instance Method Details

#processObject



8
9
10
11
12
13
14
15
16
# File 'lib/perron/html_processor/target_blank.rb', line 8

def process
  @html.css("a").each do |link|
    href = link["href"]

    next if href.blank? || href.start_with?("/", "#", "mailto:")

    link["target"] = "_blank"
  end
end