{smcl} {hline} help for {cmd:htmlutil}{right:(Roger Newson)} {hline} {title:Utilities for writing Hypertext Markup Language (HTML) files} {pstd} Open a HTML file {p 8 21 2} {cmd:htmlopen} {it:handle} {cmd:using} {help filename:{it:filename}} [ , {cmd:replace} {cmdab:at:tributes}{cmd:(}{it:attributes_list}{cmd:)} {break} {cmdab:he:ad} {cmdab:heada:ttributes}{cmd:(}{it:head_attributes_list}{cmd:)} {cmdab:ti:tle}{cmd:(}{it:string}{cmd:)} {cmdab:headf:rom}{cmd:(}{help filename:{it:filename}}{cmd:)} {break} {cmdab:bo:dy} {cmdab:bodya:ttributes}{cmd:(}{it:body_attributes_list}{cmd:)} {break} {opt bom(bom_option)} {break} ] {pstd} {pstd} where {it:attributes_list} is a list of attributes for the {cmd:} tag in HTML, {it:head_attributes_list} is a list of attributes for the {cmd:
} tag in HTML, {it:body_attributes_list} is a list of attributes for the {cmd:} tag in HTML, {it:handle} is a {help file:file handle} as recognized by the {helpb file} utility, and {it:bom_option} can be an empty string or {cmd:utf-8}. {pstd} Insert an image in an open HTML file {p 8 21 2} {cmd:htmlimg} {it:handle} [ , {cmdab:at:tributes}{cmd:(}{it:attributes_list}{cmd:)} ] {pstd} where {it:attributes_list} is a list of attributes for the {cmd:} tag in HTML, and {it:handle} is a {help file:file handle} as recognized by the {helpb file} utility. {pstd} Insert a hyperlink in an open HTML file {p 8 21 2} {cmd:htmllink} {it:handle} [ , {cmdab:at:tributes}{cmd:(}{it:attributes_list}{cmd:)} {cmdab:linkt:ext}{cmd:(}{it:link_text}{cmd:)} ] {pstd} where {it:attributes_list} is a list of attributes for the {cmd:} tag in HTML, {it:link_text} is a piece of HTML code, and {it:handle} is a {help file:file handle} as recognized by the {helpb file} utility. {pstd} Close an open HTML file {p 8 21 2} {cmd:htmlclose} {it:handle} [ , {cmdab:bo:dy} ] {pstd} where {it:handle} is a {help file:file handle} as recognized by the {helpb file} utility. {title:Description} {pstd} The {cmd:htmlutil} package is a suite of file handling utilities for producing Hypertext Markup Language (HTML) files in Stata. The user can open the file for input using {cmd:htmlopen}, and close the file using {cmd:htmlclose}. In between these statements, the user can insert linked images from files using {cmd:htmlimg}, insert hypertext links using {cmd:htmllink}, insert HTML tables using the {helpb listtab} package, and insert more HTML using the {helpb tfinsert} package. The packages {helpb listtab} and {helpb tfinsert} are downloadable from {help ssc:SSC}. {title:Options for {cmd:htmlopen}} {phang} {cmd:replace} specifies that any existing file with the name specified by the {it:filename} will be replaced. {phang} {cmd:attributes(}{it:attributes_list}{cmd:)} specifies a list of attributes, to be passed to the {cmd:} tag at the start of the HTML file. {phang} {cmd:head} specifies that a HTML head will be added to the new HTML file. If the {cmd:headattributes()}, {cmd:headfrom()} and {cmd:title()} options are not specified, then this HTML head will contain only the tags {cmd:} and {cmd:}. {phang} {cmd:headattributes(}{it:head_attributes_list}{cmd:)} specifies that a HTML head will be added to the new HTML file, with attributes for the {cmd:} tag specified by the {it:head_attributes_list}. The {cmd:headattributes()} option implies the {cmd:head} option, even if {cmd:head} is not specified by the user. {phang} {cmd:title(}{it:string}{cmd:)} specifies a title for the HTML document being created, which will be output in the document head between a {cmd:}{p_end} {p 8 12 2}{cmd:. Hello, World!!!!}{p_end} {p 8 12 2}{cmd:.
}{p_end} {p 8 12 2}{cmd:. }{p_end} {p 8 12 2}{cmd:. END_OF_HTML}{p_end} {p 8 12 2}{cmd:. {c )-}}{p_end} {p 8 12 2}{cmd:. htmlclose `handle1'}{p_end} {pstd} The following example generates a document {cmd:mydoc2.htm}, which contains a HTML table of the mileages and weights of the 22 non-American cars in the {cmd:auto} data. This table is generated using the {helpb listtab} package, downloadable from {help ssc:SSC}. The rest of the HTML is generated using the {helpb tfinsert} package. {p 8 12 2}{cmd:. sysuse auto, clear}{p_end} {p 8 12 2}{cmd:. keep if foreign==1}{p_end} {p 8 12 2}{cmd:. tempname handle2}{p_end} {p 8 12 2}{cmd:. htmlopen `handle2' using "mydoc2.htm", attributes(lang=en-US) replace}{p_end} {p 8 12 2}{cmd:. capture noisily {c -(}}{p_end} {p 8 12 2}{cmd:. tfinsert `handle2', terminator(END_OF_HTML)}{p_end} {p 8 12 2}{cmd:. }{p_end} {p 8 12 2}{cmd:.Make | Mileage (mpg) | Weight (lb) |
---|
View the .pdf version of this image
")}{p_end} {p 8 12 2}{cmd:. listtab make mpg weight, handle(`handle3') rstyle(html) head("Make | Mileage (mpg) | Weight (lb) |
---|
Make | Mileage (mpg) | Weight (lb) |
---|