html.htmlDoc - WIN

Class htmlDoc
Inherits from __classBase.

The htmlDoc class provides an object representation of a html document.

Properties

html__type string Contains the format of the current document.
html table The top node of the html document object.

Methods

See also HTML API, API Reference, WIN.

local html_node_to_text

text html_node_to_text (node)

Returns a plain text conversion of the html node's contents.

Parameters
node table The node to convert.

Returns
text string The plain text conversion.

Remarks
This function is locally defined in the API, and is used by htmlDoc:get_text.


top


local fix_string_for_file

out_str fix_string_for_file (in_str)

Converts the input string to a form suitable for writing to a file as a string.

Parameters
in_str string
Input string to convert.

Returns
out_str string The converted string.

Remarks
This function is locally defined in the API, and is used by htmlDoc:serialize_node.


top


html.htmlDoc:color

color htmlDoc:color (source)

Returns the color value of the html color source.

Parameters
source string/number May be either a html color name or a color value.

Returns
color number The color value or nil if the source was not recognizable as a valid color. If a number it is a valid color value.

Remarks
This method can be used as a static member of the htmlDoc class.

See htmlDoc:color_name.


top


html.htmlDoc:color_name

name htmlDoc:color_name (color)

Returns the name of the html color source.

Parameters
source string/number May be either a html color name or a color value.

Returns
name string The color value's html name or nil if the source was not recognizable as a valid color.

Remarks
This method can be used as a static member of the htmlDoc class.

See htmlDoc:color.


top


html.htmlDoc:constructor

doc htmlDoc:constructor (source)

Constructs and returns the instantiated html document object.

Parameters
source htmlDoc/string/nil If a htmlDoc object the document is copied. If a string it may be the raw html document (as loaded from a file) or plain text, which will be parsed. If nil the object is initialized with a blank document.

Returns
doc htmlDoc The instantiated document object.

Remarks
See htmlDoc:parse.


top


html.htmlDoc:get_html

html htmlDoc:get_html ()

Creates and returns the raw html string representation of the current document object.

Parameters
none


Returns
html string The raw html representation of the document.

Remarks
The returned string is suitable for saving to a file.

See browserWindow:get_html, htmlDoc:serialize, htmlDoc:get_text.


top


html.htmlDoc:get_text

plain htmlDoc:get_text ()

Creates and returns the plain text string representation of the current document object.

Parameters
none


Returns
plain string The plain text representation of the document.

Remarks
The returned string is suitable for saving to a file.

See browserWindow:get_text, htmlDoc:serialize, htmlDoc:get_html.


top


html.htmlDoc:get_width

width htmlDoc:get_width ()

Returns the width value from the html document body tag if it has one, otherwise zero.

Parameters
none


Returns
width number The document width value or zero.

Remarks
See htmlMap:get_width.


top


html.htmlDoc:is_html

doc htmlDoc:is_html (doc)

Returns the html document node object interpreted from the source.

Parameters
source htmlDoc/string The source to interpret. If a htmlDoc object it is returned. If a raw string html document, a new document node is created and returned.

Returns
doc table/nil The document node. If source is not a valid html source nil is returned.

Remarks


top


html.htmlDoc:parse

htmlDoc:parse (source)

Parses the source as the current document object.

Parameters
source htmlDoc/string/nil If a htmlDoc object the document is copied. If a string it may be the raw html document (as loaded from a file) or plain text. If nil the document object is a blank document.

Returns
none


Remarks
See browserWindow:set_text.


top


html.htmlDoc:parse_node

node htmlDoc:parse_node (node, def_tag)

Parses the source node, returning a validated copy.

Parameters
source table/string The source node to parse.
def_tag string/nil The default tag for the parsed node if source is a table and has no tag key. If nil no default tagging is implemented.

Returns
node table/string The parsed node.

Remarks


top


html.htmlDoc:serialize

raw htmlDoc:serialize ()

Serializes the document object into a raw text string. If the document's type is "text" then the returned string is a plain text representation, otherwise html.

Parameters
none


Returns
raw string The raw text representation of the document.

Remarks
The returned string is suitable for saving to a file.

See browserWindow:serialize, htmlDoc:get_html, htmlDoc:get_text.


top


html.htmlDoc:serialize_node

html htmlDoc:serialize_node (node, indent)

Creates and returns the raw html string representation of the node.

Parameters
node table The node to serialize.
indent string The indent string to use for the output string's lines.

Returns
html string The raw html representation of the node.

Remarks
See htmlDoc:get_html.


top


html.htmlDoc:type

format htmlDoc:type ()

Returns the format that the current document was parsed from.

Parameters
none


Returns
format string The format of the document; either "text" or "html".

Remarks
See browserWindow:doc_type.


top


See also HTML API, API Reference, WIN.