HTML API - WIN
The html API provides three classes for parsing and displaying html
documents: htmlDoc,
htmlMap and browserWindow.
The browserWindow
class is the main class that is usually accessed, which uses the
other two class. The htmlDoc
class represents the the document; its features are usually accessed
via the browserWindow
class object. The htmlMap
class is a liner representation of the html document's contents for
drawing. An object of this class is created and accessed directly
when drawing the document to a printer.
Colors in the html documents may be their valid numeric value or a
name. See Colors for
the recognized color numbers and names, which are case sensitive.
The html document format is a native lua table structure. The top
table must have a html key, which must be a table. Typically the
html table contains a body key, which is a table, and possibly a
head key, which is also a table.
The head section contains metadata for the document. The body
section forms the top node of the display contents of the document.
Each node, depending upon its type, can contain specific key entries
as properties of the node, and indexed entries which form the child
nodes. The keys are case sensitive.
Classes
htmlDoc
htmlMap
browserWindow
Topics
See also API
Reference, WIN.
Colous
Colors
TML Name
|
API Name
|
Numeric
Value
|
black |
black |
0
|
orange |
orange |
1
|
magenta |
magenta |
2
|
sky |
sky |
3
|
yellow |
yellow |
4
|
pink |
pink |
5
|
cyan |
cyan |
6
|
gray |
gray |
7
|
silver |
silver |
8
|
red |
red |
9
|
green |
green |
10
|
blue |
blue |
11
|
brown |
brown |
12
|
lime |
lime |
13
|
purple |
purple |
14
|
white |
white |
15
|
top
Keys
Body
Keys
color |
number/string |
The default text color for the document. May
be a valid color value or a html color name. |
bgcolor |
number/string |
The default background color for the
document. May be a valid color value or a html color name. |
linkcolor |
number/string |
The default color for a link in the document.
May be a valid color value or a html color name. |
align |
string |
The default alignment for the document, may
be: "left", "right" or "center". |
width |
number/string |
The minimum display width of the document, in
characters. No minimum width if omitted. |
Remarks
Any indexed entries form the contents of the document.
top
Division
Keys
tag |
string |
Must be "d".
This key must exist. |
color |
number/string |
The text color for the division. If not
specified the color is inherited from the parent node. May
be a valid color value or a html color name. |
bgcolor |
number/string |
The background color for the division. If not
specified the color is inherited from the parent node. May
be a valid color value or a html color name. |
align |
string |
The alignment of the division, may be: "left", "right"
or "center". If not specified
the alignment is inherited from the parent. |
Remarks
Divisions are a block level element, similar to paragraphs but have
no implied line spacing after them. They usually contain child
nodes.
top
Head
Keys
title |
string |
The title property for the document. |
Remarks
top
Horizontal Line
Keys
tag |
string |
Must be "l".
This key must exist. |
color |
number/string |
The text color for the line. If not specified
the color is inherited from the parent node. May be a valid
color value or a html color name. |
bgcolor |
number/string |
The background color for the line. If not
specified the color is inherited from the parent node. May
be a valid color value or a html color name. |
align |
string |
The alignment of the line, may be: "left", "right"
or "center". If not specified
the alignment is inherited from the parent. |
width |
number |
The percentage of the display width of the
line. If not specified 100 is used. |
char |
string |
A single character string to use as the
repeated character for the line. If not specified "-" is used. |
Remarks
Horizontal lines are block level elements and contain no child
nodes.
top
Link
Keys
tag |
string |
Must be "a".
This key must exist. |
color |
number/string |
The text color for the link. If not specified
the color is inherited from the body's linkcolor. May be a
valid color value or a html color name. |
bgcolor |
number/string |
The background color for the link. If not
specified the color is inherited from the parent node. May
be a valid color value or a html color name. |
href |
string |
The address to navigate to. It may be a fully
qualified or relative address. |
protocol |
string |
The protocol to use for the linked file.
Recognized values are "ftp:",
"http:", "ftp"
and "http". If the protocol is
not specified "http:" is
generally assumed. If the href value specifies the protocol
this key should be omitted. |
Remarks
Links are inline elements and usually contain a single string child
node, but may contain more.
top
Paragraph
Keys
tag |
string |
Must be "p".
This key must exist. |
color |
number/string |
The text color for the paragraph. If not
specified the color is inherited from the parent node. May
be a valid color value or a html color name. |
bgcolor |
number/string |
The background color for the paragraph. If
not specified the color is inherited from the parent node.
May be a valid color value or a html color name. |
align |
string |
The alignment of the paragraph, may be: "left", "right"
or "center". If not specified
the alignment is inherited from the parent. |
Remarks
Paragraphs are a block level element and have an implied line
spacing after them. They usually contain child nodes.
top
Other/Unspecified
Keys
color |
number/string |
The text color for the inline element. If not
specified the color is inherited from the parent node. May
be a valid color value or a html color name. |
bgcolor |
number/string |
The background color for the inline element.
If not specified the color is inherited from the parent
node. May be a valid color value or a html color name. |
Remarks
Unknown tags or untaged tables are inline elements, and may contain
child nodes. They can be used for inline formatting.
top
Examples
Example Html Documents
#1
{
html = {
head = { title = "foo" },
body = { color = "black", linkcolor = "blue", bgcolor = "yellow",
{ tag = "p", align = "center", color = "gray", bgcolor = "cyan",
"\r",
"foo.com\r",
"======="
},
{ tag = "p", align = "left",
"Welcome to foo, where ", { color = "red", "everyone" }, " has loads of fun."
},
{ tag = "p", align = "left",
"Be sure to check out our great departments."
},
{ tag = "p", align = "left",
" ", { tag = "a", href = "joe.html", "Joe's Bar & Grill" }, "\r",
" ", { tag = "a", href = "mary.html", "Mary's Florist" }, "\r",
" ", { tag = "a", href = "fay.html", "Fay's Dating" }, "\r",
" ", { tag = "a", href = "downloads/myApp", protocol = "ftp:", "Download App" }
},
{ tag = "l", width = "50", align = "center", color = "brown" }
},
}
}
#2
{
html = {
head = { title = "Mary's Florist" },
body = { color = "blue", linkcolor = "red", bgcolor = "yellow",
{ tag = "p", align = "center", color = "pink", bgcolor = "green",
"\r",
{ color = "yellow", "{*}" }, " Mary's Florist ", { color = "yellow", "{*}" },
"\r"
},
{ tag = "p", align = "left",
{ color = "black", " Our Extensive Range:\r" },
" + Snapping Dragons.\r",
" + Violent Violets.\r",
" + Ivy that Poisoned Ivy.\r",
" + Two Lipped Tulips."
},
{ tag = "p", color = "brown", align = "center",
{ color = "black", "Mary's Florist" }, "\r",
"Where nature comes to life,\r",
"and tries to kill you."
},
{ tag = "p", align = "center",
{ color = "black", "Proudly at " }, { tag = "a", href = "http:foo.com", "foo.com" }
}
},
}
}
top
See also API
Reference, WIN.