Class: TestStackingParser

Inherits:
HTML::StackingParser show all
Defined in:
lib/html/tree.rb,
lib/html/xmltree.rb,
lib/html/stparser.rb

Constant Summary

Constants inherited from HTML::SGMLParser

HTML::SGMLParser::Attrfind, HTML::SGMLParser::Charref, HTML::SGMLParser::Commentclose, HTML::SGMLParser::Commentopen, HTML::SGMLParser::Endbracket, HTML::SGMLParser::Endtagfind, HTML::SGMLParser::Endtagopen, HTML::SGMLParser::Entitydefs, HTML::SGMLParser::Entityref, HTML::SGMLParser::Incomplete, HTML::SGMLParser::Interesting, HTML::SGMLParser::Special, HTML::SGMLParser::Starttagopen, HTML::SGMLParser::Tagfind

Instance Attribute Summary

Attributes inherited from HTML::SGMLParser

#src_range

Instance Method Summary collapse

Methods inherited from HTML::StackingParser

#feed, #last_tag, #parent_tag, #parse_file_named, #stack, #strip_whitespace=

Methods inherited from HTML::SGMLParser

#close, #feed, #finish_endtag, #finish_starttag, #get_source, #goahead, #handle_charref, #handle_data, #handle_data_range, #handle_endtag, #handle_entityref, #handle_starttag, #has_context, #initialize, #parse_comment, #parse_endtag, #parse_special, #parse_starttag, #report_unbalanced, #reset, #set_range, #setliteral, #setnomoretags, #unknown_charref, #unknown_endtag, #unknown_entityref, #unknown_starttag

Instance Method Details

#dump_stackObject



237
238
239
# File 'lib/html/stparser.rb', line 237

def dump_stack
  stack.each { |ea| print ea, '/' }
end

#handle_cdata(data) ⇒ Object

print(“EMPTY: #tag #TestStackingParser.attrsattrs.inspectn”)



249
250
251
252
253
254
255
256
257
258
# File 'lib/html/stparser.rb', line 249

def handle_cdata(data)
  # print("DATA: #{data.size} chars\n")
  if last_tag() != 'style'
    str = data.strip
    if str.size > 0
      dump_stack
      print(str.inspect, "\n")
    end
  end
end

#handle_comment(data) ⇒ Object



268
269
270
271
# File 'lib/html/stparser.rb', line 268

def handle_comment(data)
  super
  print("COMMENT: #{data}\n")
end

#handle_empty_tag(tag, attrs) ⇒ Object

print(“END: #tagn”)



246
247
248
# File 'lib/html/stparser.rb', line 246

def handle_empty_tag(tag, attrs)
  # print("EMPTY: #{tag} #{attrs.inspect}\n")
end

#handle_end_tag(tag) ⇒ Object



243
244
245
# File 'lib/html/stparser.rb', line 243

def handle_end_tag(tag)
  # print("END: #{tag}\n")
end

#handle_script(data) ⇒ Object



259
260
261
# File 'lib/html/stparser.rb', line 259

def handle_script(data)
  # print("SCRIPT: #{data.size} chars\n")
end

#handle_special(data) ⇒ Object



272
273
274
# File 'lib/html/stparser.rb', line 272

def handle_special(data)
  print("SPECIAL: #{data}\n")
end

#handle_start_tag(tag, attrs) ⇒ Object



240
241
242
# File 'lib/html/stparser.rb', line 240

def handle_start_tag(tag, attrs)
  print("START: #{tag} #{attrs.inspect}\n")
end

#handle_unknown_character(name) ⇒ Object

print(“SCRIPT: #TestStackingParser.datadata.size charsn”)



262
263
264
# File 'lib/html/stparser.rb', line 262

def handle_unknown_character(name)
  print("UNKC: #{name}\n")
end

#handle_unknown_entity(name) ⇒ Object



265
266
267
# File 'lib/html/stparser.rb', line 265

def handle_unknown_entity(name)
  print("UNKE: #{name}\n")
end