wxRuby Documentation Home

Wx::HtmlTag

This class represents a single HTML tag.
It is used by tag handlers.

Derived from

Object

Methods

HtmlTag.new

HtmlTag.new(%(arg-type)HtmlTag% parent, String source, Integer pos, Integer end_pos, HtmlTagsCache cache, HtmlEntitiesParser entParser)

Constructor. You will probably never have to construct a HtmlTag object
yourself. Feel free to ignore the constructor parameters.
Have a look at src/html/htmlpars.cpp if you’re interested in creating it.

HtmlTag#get_all_params

String get_all_params()

Returns a string containing all parameters.

Example : tag contains <FONT SIZE=+2 COLOR="\#000000">. Call to
tag.GetAllParams() would return SIZE=+2 COLOR="\#000000".

HtmlTag#get_begin_pos

Integer get_begin_pos()

Returns beginning position of the text between this tag and paired
ending tag.
See explanation (returned position is marked with `|’):

bla bla bla bla bla internal text bla bla |

HtmlTag#get_end_pos_1

Integer get_end_pos_1()

Returns ending position of the text between this tag and paired
ending tag.
See explanation (returned position is marked with `|’):

bla bla bla bla bla internal text bla bla |

HtmlTag#get_end_pos_2

Integer get_end_pos_2()

Returns ending position 2 of the text between this tag and paired
ending tag.
See explanation (returned position is marked with `|’):

bla bla bla bla bla internal text bla bla |

HtmlTag#get_name

String get_name()

Returns tag’s name. The name is always in uppercase and it doesn’t contain
‘<’ or ‘/’ characters. (So the name of <FONT SIZE=+2> tag is “FONT
and name of </table> is “TABLE”)

HtmlTag#get_param

String get_param(%(arg-type)String% par, Boolean with_commas = false)

Returns the value of the parameter. You should check whether the
parameter exists or not (use has_param) first.

Parameters

Example

… /* you have HtmlTag variable tag which is equal to HTML tag <FONT SIZE=+2 COLOR=“#0000FF”> */ dummy = tag.GetParam(“SIZE”); // dummy == “+2” dummy = tag.GetParam(“COLOR”); // dummy == “#0000FF” dummy = tag.GetParam(“COLOR”, true); // dummy == “\”#0000FF\"" — see the difference!!

HtmlTag#get_param_as_colour

Boolean get_param_as_colour(%(arg-type)String% par, Colour clr)

Interprets tag parameter par as colour specification and saves its value
into Colour variable pointed by clr.

Returns true on success and false if par is not colour specification or
if the tag has no such parameter.

HtmlTag#get_param_as_int

Boolean get_param_as_int(%(arg-type)String% par, Integer value)

Interprets tag parameter par as an integer and saves its value
into int variable pointed by value.

Returns true on success and false if par is not an integer or
if the tag has no such parameter.

HtmlTag#has_ending

Boolean has_ending()

Returns true if this tag is paired with ending tag, false otherwise.

See the example of HTML document:


Hello


How are you?

This is centered…

Oops
Oooops!

In this example tags HTML and BODY have ending tags, first P and BR
doesn’t have ending tag while the second P has. The third P tag (which
is ending itself) of course doesn’t have ending tag.

HtmlTag#has_param

Boolean has_param(%(arg-type)String% par)

Returns true if the tag has a parameter of the given name.
Example : <FONT SIZE=+2 COLOR="\#FF00FF"> has two parameters named
SIZE” and “COLOR”.

Parameters

HtmlTag#scan_param

String scan_param(%(arg-type)String% par, Char format, (arg-type) value)

This method scans the given parameter. Usage is exactly the same as sscanf’s
usage except that you don’t pass a string but a parameter name as the first
argument
and you can only retrieve one value (i.e. you can use only one “\%” element
in format).

Parameters

[This page automatically generated from the Textile source at 2023-06-03 08:07:28 +0000]