Module: Ronin::Support::Web::HTML::Mixin

Included in:
Mixin
Defined in:
lib/ronin/support/web/html/mixin.rb

Overview

Provides helper methods for working with HTML.

Instance Method Summary collapse

Instance Method Details

#html_build { ... } ⇒ Nokogiri::HTML::Builder

Creates a new Nokogiri::HTML::Builder.

Examples:

html_build do
  html {
    body {
      div(style: 'display:none;') {
        object(classid: 'blabla')
      }
    }
  }
end

Yields:

  • [] The block that will be used to construct the HTML document.

Returns:

  • (Nokogiri::HTML::Builder)

    The new HTML builder object.

See Also:



108
109
110
# File 'lib/ronin/support/web/html/mixin.rb', line 108

def html_build(&block)
  HTML.build(&block)
end

#html_open(path) {|doc| ... } ⇒ Nokogiri::HTML::Document Also known as: open_html

Opens an HTML file.

Examples:

doc = HTML.open('index.html')
# => #<Nokogiri::HTML::Document:...>

Parameters:

  • path (String)

    The path to the HTML file.

Yields:

  • (doc)

    If a block is given, it will be passed the newly created document object.

Yield Parameters:

  • doc (Nokogiri::HTML::Document)

    The new HTML document object.

Returns:

  • (Nokogiri::HTML::Document)

    The parsed HTML file.

See Also:



79
80
81
# File 'lib/ronin/support/web/html/mixin.rb', line 79

def html_open(path,&block)
  HTML.open(path,&block)
end

#html_parse(html) {|doc| ... } ⇒ Nokogiri::HTML::Document

Parses the body of a document into a HTML document object.

Parameters:

  • html (String, IO)

    The HTML to parse.

Yields:

  • (doc)

    If a block is given, it will be passed the newly created document object.

Yield Parameters:

  • doc (Nokogiri::HTML::Document)

    The new HTML document object.

Returns:

  • (Nokogiri::HTML::Document)

    The new HTML document object.

See Also:



52
53
54
# File 'lib/ronin/support/web/html/mixin.rb', line 52

def html_parse(html,&block)
  HTML.parse(html,&block)
end