Sha256: fddf38c222eb9624b10e6d3957d4f9852a3d9c23105e66377b8c9518c4867b93

Contents?: true

Size: 1.64 KB

Versions: 31

Compression:

Stored size: 1.64 KB

Contents

#include <html_sax_parser.h>

/*
 * call-seq:
 *  native_parse_file(data, encoding)
 *
 * Parse +data+ with +encoding+
 */
static VALUE native_parse_file(VALUE self, VALUE data, VALUE encoding)
{
  xmlSAXHandlerPtr handler;
  htmlDocPtr hdoc ;
  Data_Get_Struct(self, xmlSAXHandler, handler);
  hdoc = htmlSAXParseFile( StringValuePtr(data),
                           (const char *)StringValuePtr(encoding),
                           (htmlSAXHandlerPtr)handler,
                           (void *)self );
  xmlFreeDoc(hdoc);
  return data;
}

/*
 * call-seq:
 *  native_parse_memory(data, encoding)
 *
 * Parse +data+ with +encoding+
 */
static VALUE native_parse_memory(VALUE self, VALUE data, VALUE encoding)
{
  xmlSAXHandlerPtr handler;
  htmlDocPtr hdoc ;
  Data_Get_Struct(self, xmlSAXHandler, handler);
  hdoc = htmlSAXParseDoc(  (xmlChar *)StringValuePtr(data),
                           (const char *)StringValuePtr(encoding),
                           (htmlSAXHandlerPtr)handler,
                           (void *)self );
  xmlFreeDoc(hdoc);
  return data;
}

VALUE cNokogiriHtmlSaxParser ;
void init_html_sax_parser()
{
  VALUE nokogiri  = rb_define_module("Nokogiri");
  VALUE html      = rb_define_module_under(nokogiri, "HTML");
  VALUE sax       = rb_define_module_under(html, "SAX");
  /*
   * Nokogiri::HTML::SAX::Parser is used for parsing HTML with SAX
   * callbacks.
   */
  VALUE klass     = rb_define_class_under(sax, "Parser", cNokogiriXmlSaxParser);

  cNokogiriHtmlSaxParser = klass;

  rb_define_private_method(klass, "native_parse_memory", native_parse_memory, 2);
  rb_define_private_method(klass, "native_parse_file", native_parse_file, 2);
}

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
akamai_bookmarklet-0.1.2 vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/html_sax_parser.c
akamai_bookmarklet-0.1.1 vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/html_sax_parser.c
akamai_bookmarklet-0.1.0 vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/ext/nokogiri/html_sax_parser.c
nokogiri-1.3.3-x86-mswin32 ext/nokogiri/html_sax_parser.c
nokogiri-1.3.3-x86-mingw32 ext/nokogiri/html_sax_parser.c
nokogiri-1.3.3-java ext/nokogiri/html_sax_parser.c
nokogiri-1.3.2-x86-mswin32 ext/nokogiri/html_sax_parser.c
nokogiri-1.3.2-x86-mingw32 ext/nokogiri/html_sax_parser.c
nokogiri-1.3.2-java ext/nokogiri/html_sax_parser.c
nokogiri-1.3.0-x86-mingw32 ext/nokogiri/html_sax_parser.c
nokogiri-1.3.2 ext/nokogiri/html_sax_parser.c
nokogiri-1.3.3 ext/nokogiri/html_sax_parser.c
nokogiri-1.2.0-x86-mswin32-60 ext/nokogiri/html_sax_parser.c
nokogiri-1.2.0-java ext/nokogiri/html_sax_parser.c
nokogiri-1.2.1-java ext/nokogiri/html_sax_parser.c
nokogiri-1.2.0 ext/nokogiri/html_sax_parser.c
nokogiri-1.2.1 ext/nokogiri/html_sax_parser.c
nokogiri-1.2.2-java ext/nokogiri/html_sax_parser.c
nokogiri-1.2.1-x86-mswin32-60 ext/nokogiri/html_sax_parser.c
nokogiri-1.2.2 ext/nokogiri/html_sax_parser.c