# File lib/webby/filters/basepath.rb, line 66
  def filter
    doc = @mode == :xml ? Hpricot.XML(@str) : Hpricot(@str)
    base_path = ::Webby.site.base
    attr_rgxp = %r/\[@(\w+)\]$/o
    sub_rgxp = %r/\A(?=\/)/o

    ::Webby.site.xpaths.each do |xpath|
      @attr_name = nil

      doc.search(xpath).each do |element|
        @attr_name ||= attr_rgxp.match(xpath)[1]
        a = element.get_attribute(@attr_name)
        element.set_attribute(@attr_name, a) if a.sub!(sub_rgxp, base_path)
      end
    end

    doc.to_html
  end