| <head> |
| <title>html(3) - Plan 9 from User Space</title> |
| <meta content="text/html; charset=utf-8" http-equiv=Content-Type> |
| </head> |
| <body bgcolor=#ffffff> |
| <table border=0 cellpadding=0 cellspacing=0 width=100%> |
| <tr height=10><td> |
| <tr><td width=20><td> |
| <tr><td width=20><td><b>HTML(3)</b><td align=right><b>HTML(3)</b> |
| <tr><td width=20><td colspan=2> |
| <br> |
| <p><font size=+1><b>NAME </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| parsehtml, printitems, validitems, freeitems, freedocinfo, dimenkind, |
| dimenspec, targetid, targetname, fromStr, toStr – HTML parser<br> |
| |
| </table> |
| <p><font size=+1><b>SYNOPSIS </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <tt><font size=+1>#include <u.h><br> |
| #include <libc.h><br> |
| #include <html.h><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Item* parsehtml(uchar* data, int datalen, Rune* src, int mtype,<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| int chset, Docinfo** pdi)<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| </table> |
| |
| </table> |
| </font></tt> |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| |
| |
| </table> |
| |
| </table> |
| <tt><font size=+1>void printitems(Item* items, char* msg)<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>int validitems(Item* items)<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>void freeitems(Item* items)<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>void freedocinfo(Docinfo* d)<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>int dimenkind(Dimen d)<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>int dimenspec(Dimen d)<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>int targetid(Rune* s)<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Rune* targetname(int targid)<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>uchar* fromStr(Rune* buf, int n, int chset)<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Rune* toStr(uchar* buf, int n, int chset)<br> |
| </font></tt> |
| </table> |
| <p><font size=+1><b>DESCRIPTION </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| This library implements a parser for HTML 4.0 documents. The parsed |
| HTML is converted into an intermediate representation that describes |
| how the formatted HTML should be laid out. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Parsehtml</i> parses an entire HTML document contained in the buffer |
| <i>data</i> and having length <i>datalen</i>. The URL of the document should |
| be passed in as <i>src</i>. <i>Mtype</i> is the media type of the document, |
| which should be either <tt><font size=+1>TextHtml</font></tt> or <tt><font size=+1>TextPlain</font></tt>. The character set |
| of the document is described in <i>chset</i>, which can be |
| one of <tt><font size=+1>US_Ascii</font></tt>, <tt><font size=+1>ISO_8859_1</font></tt>, <tt><font size=+1>UTF_8</font></tt> or <tt><font size=+1>Unicode</font></tt>. The return value |
| is a linked list of <tt><font size=+1>Item</font></tt> structures, described in detail below. |
| As a side effect, <tt><font size=+1>*</font></tt><i>pdi</i> is set to point to a newly created <tt><font size=+1>Docinfo</font></tt> |
| structure, containing information pertaining to the entire document. |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| The library expects two allocation routines to be provided by |
| the caller, <tt><font size=+1>emalloc</font></tt> and <tt><font size=+1>erealloc</font></tt>. These routines are analogous |
| to the standard malloc and realloc routines, except that they |
| should not return if the memory allocation fails. In addition, |
| <tt><font size=+1>emalloc</font></tt> is required to zero the memory. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| For debugging purposes, <i>printitems</i> may be called to display the |
| contents of an item list; individual items may be printed using |
| the <tt><font size=+1>%I</font></tt> print verb, installed on the first call to <i>parsehtml</i>. <i>validitems</i> |
| traverses the item list, checking that all of the pointers are |
| valid. It returns <tt><font size=+1>1</font></tt> is everything is ok, and <tt><font size=+1>0</font></tt> if an error was |
| found. Normally, one would not call these routines directly. Instead, |
| one sets the global variable <i>dbgbuild</i> and the library calls them |
| automatically. One can also set <i>warn</i>, to cause the library to |
| print a warning whenever it finds a problem with the input document, |
| and <i>dbglex</i>, to print debugging information in the |
| lexer. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| When an item list is finished with, it should be freed with <i>freeitems</i>. |
| Then, <i>freedocinfo</i> should be called on the pointer returned in |
| <tt><font size=+1>*</font></tt><i>pdi</i>. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Dimenkind</i> and <i>dimenspec</i> are provided to interpret the <tt><font size=+1>Dimen</font></tt> type, |
| as described in the section <i>Dimension Specifications</i>. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| Frame target names are mapped to integer ids via a global, permanent |
| mapping. To find the value for a given name, call <i>targetid</i>, which |
| allocates a new id if the name hasn’t been seen before. The name |
| of a given, known id may be retrieved using <i>targetname</i>. The library |
| predefines <tt><font size=+1>FTtop</font></tt>, <tt><font size=+1>FTself</font></tt>, <tt><font size=+1>FTparent</font></tt> and |
| <tt><font size=+1>FTblank</font></tt>. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| The library handles all text as Unicode strings (type <tt><font size=+1>Rune*</font></tt>). |
| Character set conversion is provided by <i>fromStr</i> and <i>toStr</i>. <i>FromStr</i> |
| takes <i>n</i> Unicode characters from <i>buf</i> and converts them to the character |
| set described by <i>chset</i>. <i>ToStr</i> takes <i>n</i> bytes from <i>buf</i>, interpretted |
| as belonging to character set <i>chset</i>, and converts |
| them to a Unicode string. Both routines null-terminate the result, |
| and use <tt><font size=+1>emalloc</font></tt> to allocate space for it.<br> |
| <p><font size=+1><b>Items </b></font><br> |
| The return value of <i>parsehtml</i> is a linked list of variant structures, |
| with the generic portion described by the following definition: |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>typedef struct Item Item;<br> |
| struct Item<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| Item* next;<br> |
| int width;<br> |
| int height;<br> |
| int ascent;<br> |
| int anchorid;<br> |
| int state;<br> |
| Genattr* genattr;<br> |
| int tag;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| The field <tt><font size=+1>next</font></tt> points to the successor in the linked list of items, |
| while <tt><font size=+1>width</font></tt>, <tt><font size=+1>height</font></tt>, and <tt><font size=+1>ascent</font></tt> are intended for use by the caller |
| as part of the layout process. <tt><font size=+1>Anchorid</font></tt>, if non-zero, gives the |
| integer id assigned by the parser to the anchor that this item |
| is in (see section <i>Anchors</i>). <tt><font size=+1>State</font></tt> is a collection of |
| flags and values described as follows: |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>enum<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| IFbrk = 0x80000000,<br> |
| IFbrksp = 0x40000000,<br> |
| IFnobrk = 0x20000000,<br> |
| IFcleft = 0x10000000,<br> |
| IFcright = 0x08000000,<br> |
| IFwrap = 0x04000000,<br> |
| IFhang = 0x02000000,<br> |
| IFrjust = 0x01000000,<br> |
| IFcjust = 0x00800000,<br> |
| IFsmap = 0x00400000,<br> |
| IFindentshift = 8,<br> |
| IFindentmask = (255<<IFindentshift),<br> |
| IFhangmask = 255<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>IFbrk</font></tt> is set if a break is to be forced before placing this item. |
| <tt><font size=+1>IFbrksp</font></tt> is set if a 1 line space should be added to the break |
| (in which case <tt><font size=+1>IFbrk</font></tt> is also set). <tt><font size=+1>IFnobrk</font></tt> is set if a break is |
| not permitted before the item. <tt><font size=+1>IFcleft</font></tt> is set if left floats should |
| be cleared (that is, if the list of pending left floats should |
| be placed) before this item is placed, and <tt><font size=+1>IFcright</font></tt> is set for |
| right floats. In both cases, IFbrk is also set. <tt><font size=+1>IFwrap</font></tt> is set |
| if the line containing this item is allowed to wrap. <tt><font size=+1>IFhang</font></tt> is |
| set if this item hangs into the left indent. <tt><font size=+1>IFrjust</font></tt> is set if |
| the line containing this item should be right justified, and <tt><font size=+1>IFcjust</font></tt> |
| is |
| set for center justified lines. <tt><font size=+1>IFsmap</font></tt> is used to indicate that |
| an image is a server-side map. The low 8 bits, represented by |
| <tt><font size=+1>IFhangmask</font></tt>, indicate the current hang into left indent, in tenths |
| of a tabstop. The next 8 bits, represented by <tt><font size=+1>IFindentmask</font></tt> and |
| <tt><font size=+1>IFindentshift</font></tt>, indicate the current indent in tab |
| stops. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| The field <tt><font size=+1>genattr</font></tt> is an optional pointer to an auxiliary structure, |
| described in the section <i>Generic Attributes</i>. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| Finally, <tt><font size=+1>tag</font></tt> describes which variant type this item has. It can |
| have one of the values <tt><font size=+1>Itexttag</font></tt>, <tt><font size=+1>Iruletag</font></tt>, <tt><font size=+1>Iimagetag</font></tt>, <tt><font size=+1>Iformfieldtag</font></tt>, |
| <tt><font size=+1>Itabletag</font></tt>, <tt><font size=+1>Ifloattag</font></tt> or <tt><font size=+1>Ispacertag</font></tt>. For each of these values, |
| there is an additional structure defined, which includes Item |
| as an unnamed initial substructure, |
| and then defines additional fields. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| Items of type <tt><font size=+1>Itexttag</font></tt> represent a piece of text, using the following |
| structure: |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>struct Itext<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| Item;<br> |
| Rune* s;<br> |
| int fnt;<br> |
| int fg;<br> |
| uchar voff;<br> |
| uchar ul;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| Here <tt><font size=+1>s</font></tt> is a null-terminated Unicode string of the actual characters |
| making up this text item, <tt><font size=+1>fnt</font></tt> is the font number (described in |
| the section <i>Font Numbers</i>), and <tt><font size=+1>fg</font></tt> is the RGB encoded color for |
| the text. <tt><font size=+1>Voff</font></tt> measures the vertical offset from the baseline; |
| subtract <tt><font size=+1>Voffbias</font></tt> to get the actual value (negative values |
| represent a displacement down the page). The field <tt><font size=+1>ul</font></tt> is the underline |
| style: <tt><font size=+1>ULnone</font></tt> if no underline, <tt><font size=+1>ULunder</font></tt> for conventional underline, |
| and <tt><font size=+1>ULmid</font></tt> for strike-through. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| Items of type <tt><font size=+1>Iruletag</font></tt> represent a horizontal rule, as follows: |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>struct Irule<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| Item;<br> |
| uchar align;<br> |
| uchar noshade;<br> |
| int size;<br> |
| Dimen wspec;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| Here <tt><font size=+1>align</font></tt> is the alignment specification (described in the corresponding |
| section), <tt><font size=+1>noshade</font></tt> is set if the rule should not be shaded, <tt><font size=+1>size</font></tt> |
| is the height of the rule (as set by the size attribute), and |
| <tt><font size=+1>wspec</font></tt> is the desired width (see section <i>Dimension Specifications</i>). |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| Items of type <tt><font size=+1>Iimagetag</font></tt> describe embedded images, for which the |
| following structure is defined: |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>struct Iimage<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| Item;<br> |
| Rune* imsrc;<br> |
| int imwidth;<br> |
| int imheight;<br> |
| Rune* altrep;<br> |
| Map* map;<br> |
| int ctlid;<br> |
| uchar align;<br> |
| uchar hspace;<br> |
| uchar vspace;<br> |
| uchar border;<br> |
| Iimage* nextimage;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| Here <tt><font size=+1>imsrc</font></tt> is the URL of the image source, <tt><font size=+1>imwidth</font></tt> and <tt><font size=+1>imheight</font></tt>, |
| if non-zero, contain the specified width and height for the image, |
| and <tt><font size=+1>altrep</font></tt> is the text to use as an alternative to the image, |
| if the image is not displayed. <tt><font size=+1>Map</font></tt>, if set, points to a structure |
| describing an associated client-side image map. |
| <tt><font size=+1>Ctlid</font></tt> is reserved for use by the application, for handling animated |
| images. <tt><font size=+1>Align</font></tt> encodes the alignment specification of the image. |
| <tt><font size=+1>Hspace</font></tt> contains the number of pixels to pad the image with on |
| either side, and <tt><font size=+1>Vspace</font></tt> the padding above and below. <tt><font size=+1>Border</font></tt> is |
| the width of the border to draw around the |
| image. <tt><font size=+1>Nextimage</font></tt> points to the next image in the document (the |
| head of this list is <tt><font size=+1>Docinfo.images</font></tt>). |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| For items of type <tt><font size=+1>Iformfieldtag</font></tt>, the following structure is defined: |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>struct Iformfield<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| Item;<br> |
| Formfield* formfield;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| This adds a single field, <tt><font size=+1>formfield</font></tt>, which points to a structure |
| describing a field in a form, described in section <i>Forms</i>. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| For items of type <tt><font size=+1>Itabletag</font></tt>, the following structure is defined: |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>struct Itable<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| Item;<br> |
| Table* table;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Table</font></tt> points to a structure describing the table, described in |
| the section <i>Tables</i>. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| For items of type <tt><font size=+1>Ifloattag</font></tt>, the following structure is defined: |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>struct Ifloat<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| Item;<br> |
| Item* item;<br> |
| int x;<br> |
| int y;<br> |
| uchar side;<br> |
| uchar infloats;<br> |
| Ifloat* nextfloat;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| The <tt><font size=+1>item</font></tt> points to a single item (either a table or an image) |
| that floats (the text of the document flows around it), and <tt><font size=+1>side</font></tt> |
| indicates the margin that this float sticks to; it is either <tt><font size=+1>ALleft</font></tt> |
| or <tt><font size=+1>ALright</font></tt>. <tt><font size=+1>X</font></tt> and <tt><font size=+1>y</font></tt> are reserved for use by the caller; these |
| are typically used for the coordinates of the top of the float. |
| <tt><font size=+1>Infloats</font></tt> is used by the caller to keep track of whether it has |
| placed the float. <tt><font size=+1>Nextfloat</font></tt> is used by the caller to link together |
| all of the floats that it has placed. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| For items of type <tt><font size=+1>Ispacertag</font></tt>, the following structure is defined: |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>struct Ispacer<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| Item;<br> |
| int spkind;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Spkind</font></tt> encodes the kind of spacer, and may be one of <tt><font size=+1>ISPnull</font></tt> (zero |
| height and width), <tt><font size=+1>ISPvline</font></tt> (takes on height and ascent of the |
| current font), <tt><font size=+1>ISPhspace</font></tt> (has the width of a space in the current |
| font) and <tt><font size=+1>ISPgeneral</font></tt> (for all other purposes, such as between |
| markers and lists). |
| <p><font size=+1><b>Generic Attributes </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| The genattr field of an item, if non-nil, points to a structure |
| that holds the values of attributes not specific to any particular |
| item type, as they occur on a wide variety of underlying HTML |
| tags. The structure is as follows: |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>typedef struct Genattr Genattr;<br> |
| struct Genattr<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| Rune* id;<br> |
| Rune* class;<br> |
| Rune* style;<br> |
| Rune* title;<br> |
| SEvent* events;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| Fields <tt><font size=+1>id</font></tt>, <tt><font size=+1>class</font></tt>, <tt><font size=+1>style</font></tt> and <tt><font size=+1>title</font></tt>, when non-nil, contain values |
| of correspondingly named attributes of the HTML tag associated |
| with this item. <tt><font size=+1>Events</font></tt> is a linked list of events (with corresponding |
| scripted actions) associated with the item: |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>typedef struct SEvent SEvent;<br> |
| struct SEvent<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| SEvent* next;<br> |
| int type;<br> |
| Rune* script;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| Here, <tt><font size=+1>next</font></tt> points to the next event in the list, <tt><font size=+1>type</font></tt> is one of |
| <tt><font size=+1>SEonblur</font></tt>, <tt><font size=+1>SEonchange</font></tt>, <tt><font size=+1>SEonclick</font></tt>, <tt><font size=+1>SEondblclick</font></tt>, <tt><font size=+1>SEonfocus</font></tt>, <tt><font size=+1>SEonkeypress</font></tt>, |
| <tt><font size=+1>SEonkeyup</font></tt>, <tt><font size=+1>SEonload</font></tt>, <tt><font size=+1>SEonmousedown</font></tt>, <tt><font size=+1>SEonmousemove</font></tt>, <tt><font size=+1>SEonmouseout</font></tt>, |
| <tt><font size=+1>SEonmouseover</font></tt>, <tt><font size=+1>SEonmouseup</font></tt>, <tt><font size=+1>SEonreset</font></tt>, <tt><font size=+1>SEonselect</font></tt>, |
| <tt><font size=+1>SEonsubmit</font></tt> or <tt><font size=+1>SEonunload</font></tt>, and <tt><font size=+1>script</font></tt> is the text of the associated |
| script.<br> |
| <p><font size=+1><b>Dimension Specifications </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| Some structures include a dimension specification, used where |
| a number can be followed by a <tt><font size=+1>%</font></tt> or a <tt><font size=+1>*</font></tt> to indicate percentage |
| of total or relative weight. This is encoded using the following |
| structure: |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>typedef struct Dimen Dimen;<br> |
| struct Dimen<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| int kindspec;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| Separate kind and spec values are extracted using <i>dimenkind</i> and |
| <i>dimenspec</i>. <i>Dimenkind</i> returns one of <tt><font size=+1>Dnone</font></tt>, <tt><font size=+1>Dpixels</font></tt>, <tt><font size=+1>Dpercent</font></tt> or |
| <tt><font size=+1>Drelative</font></tt>. <tt><font size=+1>Dnone</font></tt> means that no dimension was specified. In all |
| other cases, <i>dimenspec</i> should be called to find the absolute number |
| of pixels, the percentage of total, or the |
| relative weight.<br> |
| <p><font size=+1><b>Background Specifications </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| It is possible to set the background of the entire document, and |
| also for some parts of the document (such as tables). This is |
| encoded as follows: |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>typedef struct Background Background;<br> |
| struct Background<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| Rune* image;<br> |
| int color;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Image</font></tt>, if non-nil, is the URL of an image to use as the background. |
| If this is nil, <tt><font size=+1>color</font></tt> is used instead, as the RGB value for a |
| solid fill color.<br> |
| <p><font size=+1><b>Alignment Specifications </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| Certain items have alignment specifiers taken from the following |
| enumerated type: |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>enum<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| ALnone = 0, ALleft, ALcenter, ALright, ALjustify,<br> |
| ALchar, ALtop, ALmiddle, ALbottom, ALbaseline<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| These values correspond to the various alignment types named in |
| the HTML 4.0 standard. If an item has an alignment of <tt><font size=+1>ALleft</font></tt> or |
| <tt><font size=+1>ALright</font></tt>, the library automatically encapsulates it inside a float |
| item. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| Tables, and the various rows, columns and cells within them, have |
| a more complex alignment specification, composed of separate vertical |
| and horizontal alignments: |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>typedef struct Align Align;<br> |
| struct Align<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| uchar halign;<br> |
| uchar valign;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Halign</font></tt> can be one of <tt><font size=+1>ALnone</font></tt>, <tt><font size=+1>ALleft</font></tt>, <tt><font size=+1>ALcenter</font></tt>, <tt><font size=+1>ALright</font></tt>, <tt><font size=+1>ALjustify</font></tt> |
| or <tt><font size=+1>ALchar</font></tt>. <tt><font size=+1>Valign</font></tt> can be one of <tt><font size=+1>ALnone</font></tt>, <tt><font size=+1>ALmiddle</font></tt>, <tt><font size=+1>ALbottom</font></tt>, <tt><font size=+1>ALtop</font></tt> |
| or <tt><font size=+1>ALbaseline</font></tt>.<br> |
| <p><font size=+1><b>Font Numbers </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| Text items have an associated font number (the <tt><font size=+1>fnt</font></tt> field), which |
| is encoded as <tt><font size=+1>style*NumSize+size</font></tt>. Here, <tt><font size=+1>style</font></tt> is one of <tt><font size=+1>FntR</font></tt>, |
| <tt><font size=+1>FntI</font></tt>, <tt><font size=+1>FntB</font></tt> or <tt><font size=+1>FntT</font></tt>, for roman, italic, bold and typewriter font |
| styles, respectively, and size is <tt><font size=+1>Tiny</font></tt>, <tt><font size=+1>Small</font></tt>, <tt><font size=+1>Normal</font></tt>, <tt><font size=+1>Large</font></tt> or |
| <tt><font size=+1>Verylarge</font></tt>. The total number of possible |
| font numbers is <tt><font size=+1>NumFnt</font></tt>, and the default font number is <tt><font size=+1>DefFnt</font></tt> |
| (which is roman style, normal size).<br> |
| <p><font size=+1><b>Document Info </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| Global information about an HTML page is stored in the following |
| structure: |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>typedef struct Docinfo Docinfo;<br> |
| struct Docinfo<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| // stuff from HTTP headers, doc head, and body tag<br> |
| Rune* src;<br> |
| Rune* base;<br> |
| Rune* doctitle;<br> |
| Background background;<br> |
| Iimage* backgrounditem;<br> |
| int text;<br> |
| int link;<br> |
| int vlink;<br> |
| int alink;<br> |
| int target;<br> |
| int chset;<br> |
| int mediatype;<br> |
| int scripttype;<br> |
| int hasscripts;<br> |
| Rune* refresh;<br> |
| Kidinfo* kidinfo;<br> |
| int frameid;<br> |
| // info needed to respond to user actions<br> |
| Anchor* anchors;<br> |
| DestAnchor* dests;<br> |
| Form* forms;<br> |
| Table* tables;<br> |
| Map* maps;<br> |
| Iimage* images;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Src</font></tt> gives the URL of the original source of the document, and |
| <tt><font size=+1>base</font></tt> is the base URL. <tt><font size=+1>Doctitle</font></tt> is the document’s title, as set |
| by a <tt><font size=+1><title></font></tt> element. <tt><font size=+1>Background</font></tt> is as described in the section |
| <i>Background Specifications</i>, and <tt><font size=+1>backgrounditem</font></tt> is set to be an |
| image item for the document’s background image |
| (if given as a URL), or else nil. <tt><font size=+1>Text</font></tt> gives the default foregound |
| text color of the document, <tt><font size=+1>link</font></tt> the unvisited hyperlink color, |
| <tt><font size=+1>vlink</font></tt> the visited hyperlink color, and <tt><font size=+1>alink</font></tt> the color for highlighting |
| hyperlinks (all in 24-bit RGB format). <tt><font size=+1>Target</font></tt> is the default target |
| frame id. <tt><font size=+1>Chset</font></tt> and <tt><font size=+1>mediatype</font></tt> are as for |
| the <i>chset</i> and <i>mtype</i> parameters to <i>parsehtml</i>. <tt><font size=+1>Scripttype</font></tt> is the |
| type of any scripts contained in the document, and is always <tt><font size=+1>TextJavascript</font></tt>. |
| <tt><font size=+1>Hasscripts</font></tt> is set if the document contains any scripts. Scripting |
| is currently unsupported. <tt><font size=+1>Refresh</font></tt> is the contents of a <tt><font size=+1><meta http−equiv=Refresh |
| ...></font></tt> tag, if any. <tt><font size=+1>Kidinfo</font></tt> is set if this document is a frameset |
| (see section <i>Frames</i>). <tt><font size=+1>Frameid</font></tt> is this document’s frame id. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>Anchors</font></tt> is a list of hyperlinks contained in the document, and |
| <tt><font size=+1>dests</font></tt> is a list of hyperlink destinations within the page (see |
| the following section for details). <tt><font size=+1>Forms</font></tt>, <tt><font size=+1>tables</font></tt> and <tt><font size=+1>maps</font></tt> are |
| lists of the various forms, tables and client-side maps contained |
| in the document, as described in subsequent sections. |
| <tt><font size=+1>Images</font></tt> is a list of all the image items in the document.<br> |
| <p><font size=+1><b>Anchors </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| The library builds two lists for all of the <tt><font size=+1><a></font></tt> elements (anchors) |
| in a document. Each anchor is assigned a unique anchor id within |
| the document. For anchors which are hyperlinks (the <tt><font size=+1>href</font></tt> attribute |
| was supplied), the following structure is defined: |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>typedef struct Anchor Anchor;<br> |
| struct Anchor<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| Anchor* next;<br> |
| int index;<br> |
| Rune* name;<br> |
| Rune* href;<br> |
| int target;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Next</font></tt> points to the next anchor in the list (the head of this list |
| is <tt><font size=+1>Docinfo.anchors</font></tt>). <tt><font size=+1>Index</font></tt> is the anchor id; each item within |
| this hyperlink is tagged with this value in its <tt><font size=+1>anchorid</font></tt> field. |
| <tt><font size=+1>Name</font></tt> and <tt><font size=+1>href</font></tt> are the values of the correspondingly named attributes |
| of the anchor (in particular, href is the URL to go |
| to). <tt><font size=+1>Target</font></tt> is the value of the target attribute (if provided) |
| converted to a frame id. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| Destinations within the document (anchors with the name attribute |
| set) are held in the <tt><font size=+1>Docinfo.dests</font></tt> list, using the following structure: |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>typedef struct DestAnchor DestAnchor;<br> |
| struct DestAnchor<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| DestAnchor* next;<br> |
| int index;<br> |
| Rune* name;<br> |
| Item* item;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Next</font></tt> is the next element of the list, <tt><font size=+1>index</font></tt> is the anchor id, |
| <tt><font size=+1>name</font></tt> is the value of the name attribute, and <tt><font size=+1>item</font></tt> is points to |
| the item within the parsed document that should be considered |
| to be the destination.<br> |
| <p><font size=+1><b>Forms </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| Any forms within a document are kept in a list, headed by <tt><font size=+1>Docinfo.forms</font></tt>. |
| The elements of this list are as follows: |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>typedef struct Form Form;<br> |
| struct Form<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| Form* next;<br> |
| int formid;<br> |
| Rune* name;<br> |
| Rune* action;<br> |
| int target;<br> |
| int method;<br> |
| int nfields;<br> |
| Formfield* fields;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Next</font></tt> points to the next form in the list. <tt><font size=+1>Formid</font></tt> is a serial number |
| for the form within the document. <tt><font size=+1>Name</font></tt> is the value of the form’s |
| name or id attribute. <tt><font size=+1>Action</font></tt> is the value of any action attribute. |
| <tt><font size=+1>Target</font></tt> is the value of the target attribute (if any) converted |
| to a frame target id. <tt><font size=+1>Method</font></tt> is one of <tt><font size=+1>HGet</font></tt> or |
| <tt><font size=+1>HPost</font></tt>. <tt><font size=+1>Nfields</font></tt> is the number of fields in the form, and <tt><font size=+1>fields</font></tt> |
| is a linked list of the actual fields. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| The individual fields in a form are described by the following |
| structure: |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>typedef struct Formfield Formfield;<br> |
| struct Formfield<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| Formfield* next;<br> |
| int ftype;<br> |
| int fieldid;<br> |
| Form* form;<br> |
| Rune* name;<br> |
| Rune* value;<br> |
| int size;<br> |
| int maxlength;<br> |
| int rows;<br> |
| int cols;<br> |
| uchar flags;<br> |
| Option* options;<br> |
| Item* image;<br> |
| int ctlid;<br> |
| SEvent* events;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| Here, <tt><font size=+1>next</font></tt> points to the next field in the list. <tt><font size=+1>Ftype</font></tt> is the |
| type of the field, which can be one of <tt><font size=+1>Ftext</font></tt>, <tt><font size=+1>Fpassword</font></tt>, <tt><font size=+1>Fcheckbox</font></tt>, |
| <tt><font size=+1>Fradio</font></tt>, <tt><font size=+1>Fsubmit</font></tt>, <tt><font size=+1>Fhidden</font></tt>, <tt><font size=+1>Fimage</font></tt>, <tt><font size=+1>Freset</font></tt>, <tt><font size=+1>Ffile</font></tt>, <tt><font size=+1>Fbutton</font></tt>, <tt><font size=+1>Fselect</font></tt> |
| or <tt><font size=+1>Ftextarea</font></tt>. <tt><font size=+1>Fieldid</font></tt> is a serial number for the field within |
| the form. <tt><font size=+1>Form</font></tt> points back |
| to the form containing this field. <tt><font size=+1>Name</font></tt>, <tt><font size=+1>value</font></tt>, <tt><font size=+1>size</font></tt>, <tt><font size=+1>maxlength</font></tt>, |
| <tt><font size=+1>rows</font></tt> and <tt><font size=+1>cols</font></tt> each contain the values of corresponding attributes |
| of the field, if present. <tt><font size=+1>Flags</font></tt> contains per-field flags, of which |
| <tt><font size=+1>FFchecked</font></tt> and <tt><font size=+1>FFmultiple</font></tt> are defined. <tt><font size=+1>Image</font></tt> is only used for fields |
| of type <tt><font size=+1>Fimage</font></tt>; it points to an |
| image item containing the image to be displayed. <tt><font size=+1>Ctlid</font></tt> is reserved |
| for use by the caller, typically to store a unique id of an associated |
| control used to implement the field. <tt><font size=+1>Events</font></tt> is the same as the |
| corresponding field of the generic attributes associated with |
| the item containing this field. <tt><font size=+1>Options</font></tt> is only used by |
| fields of type <tt><font size=+1>Fselect</font></tt>; it consists of a list of possible options |
| that may be selected for that field, using the following structure: |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>typedef struct Option Option;<br> |
| struct Option<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| Option* next;<br> |
| int selected;<br> |
| Rune* value;<br> |
| Rune* display;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Next</font></tt> points to the next element of the list. <tt><font size=+1>Selected</font></tt> is set if |
| this option is to be displayed initially. <tt><font size=+1>Value</font></tt> is the value to |
| send when the form is submitted if this option is selected. <tt><font size=+1>Display</font></tt> |
| is the string to display on the screen for this option.<br> |
| <p><font size=+1><b>Tables </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| The library builds a list of all the tables in the document, headed |
| by <tt><font size=+1>Docinfo.tables</font></tt>. Each element of this list has the following |
| format: |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>typedef struct Table Table;<br> |
| struct Table<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| Table* next;<br> |
| int tableid;<br> |
| Tablerow* rows;<br> |
| int nrow;<br> |
| Tablecol* cols;<br> |
| int ncol;<br> |
| Tablecell* cells;<br> |
| int ncell;<br> |
| Tablecell*** grid;<br> |
| Align align;<br> |
| Dimen width;<br> |
| int border;<br> |
| int cellspacing;<br> |
| int cellpadding;<br> |
| Background background;<br> |
| Item* caption;<br> |
| uchar caption_place;<br> |
| Lay* caption_lay;<br> |
| int totw;<br> |
| int toth;<br> |
| int caph;<br> |
| int availw;<br> |
| Token* tabletok;<br> |
| uchar flags;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Next</font></tt> points to the next element in the list of tables. <tt><font size=+1>Tableid</font></tt> |
| is a serial number for the table within the document. <tt><font size=+1>Rows</font></tt> is |
| an array of row specifications (described below) and <tt><font size=+1>nrow</font></tt> is the |
| number of elements in this array. Similarly, <tt><font size=+1>cols</font></tt> is an array |
| of column specifications, and <tt><font size=+1>ncol</font></tt> the size of this array. |
| <tt><font size=+1>Cells</font></tt> is a list of all cells within the table (structure described |
| below) and <tt><font size=+1>ncell</font></tt> is the number of elements in this list. Note |
| that a cell may span multiple rows and/or columns, thus <tt><font size=+1>ncell</font></tt> |
| may be smaller than <tt><font size=+1>nrow*ncol</font></tt>. <tt><font size=+1>Grid</font></tt> is a two-dimensional array |
| of cells within the table; the cell at row <tt><font size=+1>i</font></tt> and column <tt><font size=+1>j</font></tt> is |
| <tt><font size=+1>Table.grid[i][j]</font></tt>. A cell that spans multiple rows and/or columns |
| will be referenced by <tt><font size=+1>grid</font></tt> multiple times, however it will only |
| occur once in <tt><font size=+1>cells</font></tt>. <tt><font size=+1>Align</font></tt> gives the alignment specification for |
| the entire table, and <tt><font size=+1>width</font></tt> gives the requested width as a dimension |
| specification. <tt><font size=+1>Border</font></tt>, <tt><font size=+1>cellspacing |
| </font></tt>and <tt><font size=+1>cellpadding</font></tt> give the values of the corresponding attributes |
| for the table, and <tt><font size=+1>background</font></tt> gives the requested background for |
| the table. <tt><font size=+1>Caption</font></tt> is a linked list of items to be displayed as |
| the caption of the table, either above or below depending on whether |
| <tt><font size=+1>caption_place</font></tt> is <tt><font size=+1>ALtop</font></tt> or <tt><font size=+1>ALbottom</font></tt>. |
| Most of the remaining fields are reserved for use by the caller, |
| except <tt><font size=+1>tabletok</font></tt>, which is reserved for internal use. The type |
| <tt><font size=+1>Lay</font></tt> is not defined by the library; the caller can provide its |
| own definition. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| The <tt><font size=+1>Tablecol</font></tt> structure is defined for use by the caller. The library |
| ensures that the correct number of these is allocated, but leaves |
| them blank. The fields are as follows: |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>typedef struct Tablecol Tablecol;<br> |
| struct Tablecol<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| int width;<br> |
| Align align;<br> |
| Point pos;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| The rows in the table are specified as follows: |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>typedef struct Tablerow Tablerow;<br> |
| struct Tablerow<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| Tablerow* next;<br> |
| Tablecell* cells;<br> |
| int height;<br> |
| int ascent;<br> |
| Align align;<br> |
| Background background;<br> |
| Point pos;<br> |
| uchar flags;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Next</font></tt> is only used during parsing; it should be ignored by the |
| caller. <tt><font size=+1>Cells</font></tt> provides a list of all the cells in a row, linked |
| through their <tt><font size=+1>nextinrow</font></tt> fields (see below). <tt><font size=+1>Height</font></tt>, <tt><font size=+1>ascent</font></tt> and |
| <tt><font size=+1>pos</font></tt> are reserved for use by the caller. <tt><font size=+1>Align</font></tt> is the alignment |
| specification for the row, and <tt><font size=+1>background</font></tt> is the |
| background to use, if specified. <tt><font size=+1>Flags</font></tt> is used by the parser; |
| ignore this field. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| The individual cells of the table are described as follows: |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>typedef struct Tablecell Tablecell;<br> |
| struct Tablecell<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| Tablecell* next;<br> |
| Tablecell* nextinrow;<br> |
| int cellid;<br> |
| Item* content;<br> |
| Lay* lay;<br> |
| int rowspan;<br> |
| int colspan;<br> |
| Align align;<br> |
| uchar flags;<br> |
| Dimen wspec;<br> |
| int hspec;<br> |
| Background background;<br> |
| int minw;<br> |
| int maxw;<br> |
| int ascent;<br> |
| int row;<br> |
| int col;<br> |
| Point pos;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Next</font></tt> is used to link together the list of all cells within a table |
| (<tt><font size=+1>Table.cells</font></tt>), whereas <tt><font size=+1>nextinrow</font></tt> is used to link together all |
| the cells within a single row (<tt><font size=+1>Tablerow.cells</font></tt>). <tt><font size=+1>Cellid</font></tt> provides |
| a serial number for the cell within the table. <tt><font size=+1>Content</font></tt> is a linked |
| list of the items to be laid out within the cell. <tt><font size=+1>Lay |
| </font></tt>is reserved for the user to describe how these items have been |
| laid out. <tt><font size=+1>Rowspan</font></tt> and <tt><font size=+1>colspan</font></tt> are the number of rows and columns |
| spanned by this cell, respectively. <tt><font size=+1>Align</font></tt> is the alignment specification |
| for the cell. <tt><font size=+1>Flags</font></tt> is some combination of <tt><font size=+1>TFparsing</font></tt>, <tt><font size=+1>TFnowrap</font></tt> |
| and <tt><font size=+1>TFisth</font></tt> or’d together. Here |
| <tt><font size=+1>TFparsing</font></tt> is used internally by the parser, and should be ignored. |
| <tt><font size=+1>TFnowrap</font></tt> means that the contents of the cell should not be wrapped |
| if they don’t fit the available width, rather, the table should |
| be expanded if need be (this is set when the nowrap attribute |
| is supplied). <tt><font size=+1>TFisth</font></tt> means that the cell was created |
| by the <tt><font size=+1><th></font></tt> element (rather than the <tt><font size=+1><td></font></tt> element), indicating that |
| it is a header cell rather than a data cell. <tt><font size=+1>Wspec</font></tt> provides a |
| suggested width as a dimension specification, and <tt><font size=+1>hspec</font></tt> provides |
| a suggested height in pixels. <tt><font size=+1>Background</font></tt> gives a background specification |
| for the individual cell. <tt><font size=+1>Minw</font></tt>, <tt><font size=+1>maxw</font></tt>, |
| <tt><font size=+1>ascent</font></tt> and <tt><font size=+1>pos</font></tt> are reserved for use by the caller during layout. |
| <tt><font size=+1>Row</font></tt> and <tt><font size=+1>col</font></tt> give the indices of the row and column of the top |
| left-hand corner of the cell within the table grid.<br> |
| <p><font size=+1><b>Client-side Maps </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| The library builds a list of client-side maps, headed by <tt><font size=+1>Docinfo.maps</font></tt>, |
| and having the following structure: |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>typedef struct Map Map;<br> |
| struct Map<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| Map* next;<br> |
| Rune* name;<br> |
| Area* areas;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Next</font></tt> points to the next element in the list, <tt><font size=+1>name</font></tt> is the name |
| of the map (use to bind it to an image), and <tt><font size=+1>areas</font></tt> is a list of |
| the areas within the image that comprise the map, using the following |
| structure: |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>typedef struct Area Area;<br> |
| struct Area<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| Area* next;<br> |
| int shape;<br> |
| Rune* href;<br> |
| int target;<br> |
| Dimen* coords;<br> |
| int ncoords;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Next</font></tt> points to the next element in the map’s list of areas. <tt><font size=+1>Shape</font></tt> |
| describes the shape of the area, and is one of <tt><font size=+1>SHrect</font></tt>, <tt><font size=+1>SHcircle</font></tt> |
| or <tt><font size=+1>SHpoly</font></tt>. <tt><font size=+1>Href</font></tt> is the URL associated with this area in its role |
| as a hypertext link, and <tt><font size=+1>target</font></tt> is the target frame it should |
| be loaded in. <tt><font size=+1>Coords</font></tt> is an array of coordinates for |
| the shape, and <tt><font size=+1>ncoords</font></tt> is the size of this array (number of elements).<br> |
| <p><font size=+1><b>Frames </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| If the <tt><font size=+1>Docinfo.kidinfo</font></tt> field is set, the document is a frameset. |
| In this case, it is typical for <i>parsehtml</i> to return nil, as a |
| document which is a frameset should have no actual items that |
| need to be laid out (such will appear only in subsidiary documents). |
| It is possible that items will be returned by a malformed |
| document; the caller should check for this and free any such items. |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| The <tt><font size=+1>Kidinfo</font></tt> structure itself reflects the fact that framesets |
| can be nested within a document. If is defined as follows: |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <tt><font size=+1>typedef struct Kidinfo Kidinfo;<br> |
| struct Kidinfo<br> |
| {<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| Kidinfo* next;<br> |
| int isframeset;<br> |
| // fields for "frame"<br> |
| Rune* src;<br> |
| Rune* name;<br> |
| int marginw;<br> |
| int marginh;<br> |
| int framebd;<br> |
| int flags;<br> |
| // fields for "frameset"<br> |
| Dimen* rows;<br> |
| int nrows;<br> |
| Dimen* cols;<br> |
| int ncols;<br> |
| Kidinfo* kidinfos;<br> |
| Kidinfo* nextframeset;<br> |
| |
| </table> |
| };<br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>Next</font></tt> is only used if this structure is part of a containing frameset; |
| it points to the next element in the list of children of that |
| frameset. <tt><font size=+1>Isframeset</font></tt> is set when this structure represents a frameset; |
| if clear, it is an individual frame. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| Some fields are used only for framesets. <tt><font size=+1>Rows</font></tt> is an array of dimension |
| specifications for rows in the frameset, and <tt><font size=+1>nrows</font></tt> is the length |
| of this array. <tt><font size=+1>Cols</font></tt> is the corresponding array for columns, of |
| length <tt><font size=+1>ncols</font></tt>. <tt><font size=+1>Kidinfos</font></tt> points to a list of components contained |
| within this frameset, each of which may be a |
| frameset or a frame. <tt><font size=+1>Nextframeset</font></tt> is only used during parsing, |
| and should be ignored. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| The remaining fields are used if the structure describes a frame, |
| not a frameset. <tt><font size=+1>Src</font></tt> provides the URL for the document that should |
| be initially loaded into this frame. Note that this may be a relative |
| URL, in which case it should be interpretted using the containing |
| document’s URL as the base. <tt><font size=+1>Name</font></tt> gives the name of |
| the frame, typically supplied via a name attribute in the HTML. |
| If no name was given, the library allocates one. <tt><font size=+1>Marginw</font></tt>, <tt><font size=+1>marginh</font></tt> |
| and <tt><font size=+1>framebd</font></tt> are the values of the marginwidth, marginheight and |
| frameborder attributes, respectively. <tt><font size=+1>Flags</font></tt> can contain some combination |
| of the following: <tt><font size=+1>FRnoresize</font></tt> (the |
| frame had the noresize attribute set, and the user should not |
| be allowed to resize it), <tt><font size=+1>FRnoscroll</font></tt> (the frame should not have |
| any scroll bars), <tt><font size=+1>FRhscroll</font></tt> (the frame should have a horizontal |
| scroll bar), <tt><font size=+1>FRvscroll</font></tt> (the frame should have a vertical scroll |
| bar), <tt><font size=+1>FRhscrollauto</font></tt> (the frame should be automatically |
| given a horizontal scroll bar if its contents would not otherwise |
| fit), and <tt><font size=+1>FRvscrollauto</font></tt> (the frame gets a vertical scrollbar only |
| if required).<br> |
| |
| </table> |
| <p><font size=+1><b>SOURCE </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <tt><font size=+1>/usr/local/plan9/src/libhtml<br> |
| </font></tt> |
| </table> |
| <p><font size=+1><b>SEE ALSO </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <a href="../man1/fmt.html"><i>fmt</i>(1)</a> |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| W3C World Wide Web Consortium, “HTML 4.01 Specification”.<br> |
| |
| </table> |
| <p><font size=+1><b>BUGS </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| The entire HTML document must be loaded into memory before any |
| of it can be parsed.<br> |
| |
| </table> |
| |
| <td width=20> |
| <tr height=20><td> |
| </table> |
| <!-- TRAILER --> |
| <table border=0 cellpadding=0 cellspacing=0 width=100%> |
| <tr height=15><td width=10><td><td width=10> |
| <tr><td><td> |
| <center> |
| <a href="../../"><img src="../../dist/spaceglenda100.png" alt="Space Glenda" border=1></a> |
| </center> |
| </table> |
| <!-- TRAILER --> |
| </body></html> |