HTML document/page management

Description

Opens and closes an HTML page/document, allowing a sequential building of an HTML page.

Usage

1
2
3
4
5
openPage(filename, dirname=NULL, title=filename, link.javascript=NULL, 
link.css=NULL, css=NULL, head=NULL, charset="utf-8", lang="en",
head.attributes=NULL, body.attributes=NULL)

closePage(page, splash=TRUE)

Arguments

filename

a character string containing the filename or the path of the HTML file to be created.

dirname

an optional character string containing the path of the directory where the file should be written.

title

an optional character string containing the title of the HTML page.

link.javascript

an optional character vector containing the URL of Javascripts to be associated with the page.

link.css

an optional character vector containing the URL of CSS stylesheets to be associated with the page.

css

an optional character vector containing inline CSS stylesheets to be associated with the page.

head

an optional character string containing an HTML fragment to be added in the <head> section of the page.

charset

an optional character string containing the current charset. Default is "utf-8".

lang

an optional character string containing the current langage. Default is "en".

head.attributes

an optional named list of character strings, containing the <head> attributes.

body.attributes

an optional named list of character strings, containing the <body> attributes.

page

a page handle returned by a previous openPage call.

splash

a logical, indicating whether the hwriter splash tag 'generated by...' should be written at the end of the page.

Details

openPage opens a new file for writing and returns a page handle which is used by hwrite to append HTML elements in a current page. Any previous existing file will be overwritten.

The argument head is useful to add extra HTML code in the <head> header code.

closePage ends the HTML page formatting, flushes the pending writing operations and closes the file.

Value

A connection which is a handle to the current HTML page.

Author(s)

Gregoire Pau, gpau@ebi.ac.uk, 2008

See Also

hwrite, hmakeTag.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Creates a new web page 'test.html' in the R temporary directory
tmpdir <- tempdir()
p <- openPage('test.html', dirname=tmpdir,
              link.css='http://www.ebi.ac.uk/~gpau/hwriter/hwriter.css')
hwrite('Iris example', p, center=TRUE, heading=1)
hwrite(paste('This famous (Fisher\'s or Anderson\'s) iris data set',
             'gives the measurements in centimeters of the variables',
             'sepal length and width and petal length and width, respectively,',
             'for 50 flowers from each of 3 species of iris.'),
       p, class='king')
hwrite(iris, p, row.bgcolor='#ffffaa')
closePage(p)

## Opens a web browser on the web page
if (interactive()) try(browseURL(file.path(tmpdir, 'test.html')))

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.