Class: Pekky::Format::Links

Inherits:
Transformer show all
Defined in:
lib/pekky/format.rb

Overview

Utility transformer which filters a nokogiri document fragment and replaces all instances of an anchor using the pekky:// protocol with the actual path to the page. This allows users to link to pages by name, without having to remember the path.

Class Method Summary collapse

Methods inherited from Transformer

_filter, _format, name, singleton_method_added

Class Method Details

.filter(doc, text) ⇒ Object



222
223
224
225
226
# File 'lib/pekky/format.rb', line 222

def self.filter(doc, text)
  doc.css("a[href^=pekky]").each do |a|
    a.attributes["href"].value = Util.look_up_page(a.attributes["href"].value)
  end
end