Sha256: 4e9218a9f4474754f5dd9da9a4e14a6fb49bdffa8e359a53206ebc3f8543fc05
Contents?: true
Size: 767 Bytes
Versions: 8
Compression:
Stored size: 767 Bytes
Contents
require "reactor/support/link_matcher" module Reactor module Attributes class HTMLSerializer def initialize(attr, value) @attr = attr @value = value.to_str end def serialize serialize_html end private def serialize_html link_expressions = [/(href|src|usemap)\s*=\s*"([^"]*)"/, /(href|src|usemap)\s*=\s*'([^']*)'/] link_expressions.each do |expr| @value.gsub!(expr) do |string| link = Reactor::Support::LinkMatcher.new(Regexp.last_match(2)) if link.recognized? "#{Regexp.last_match(1)}=\"#{link.rewrite_url}\"" else string end end end @value end end end end
Version data entries
8 entries across 8 versions & 1 rubygems