Parent

Methods

Class/Module Index [+]

Quicksearch

HTML5::Filters::WhitespaceFilter

Public Instance Methods

each() click to toggle source
# File lib/feed_tools/vendor/html5/lib/html5/filters/whitespace.rb, line 11
def each
  preserve = 0
  __getobj__.each do |token|
    case token[:type]
    when :StartTag
      if preserve > 0 or SPACE_PRESERVE_ELEMENTS.include?(token[:name])
        preserve += 1
      end

    when :EndTag
      preserve -= 1 if preserve > 0

    when :SpaceCharacters
      token[:data] = " " if preserve == 0 && token[:data]

    when :Characters
      token[:data] = token[:data].sub(SPACES,' ') if preserve == 0
    end

    yield token
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.