weaveRhtml
reads a file that is written according to
the rules of the noweb
system and performs a simple kind
of weaving. As a result a html-file is generated.weaveRhtml(in.file,out.file,replace.umlaute=TRUE)
.html
noweb
file consists of a mixture of text
and code chunks. An @
character (in column 1 of a line)
indicates the beginning of a text chunk. <>=
(starting at column 1 of a line) is a header line of a code chunk with
a name defined by the text between <<
and >>=
.
A code chunk is finished by the beginning of hte next text chunk.
Within the code chunk you are allowed to use other code chunks by referencing
them by name ( for example by: <>
).
In this way you can separate a big job in smaller ones. Rweb speciality: A code chunk with a code chunk name containing "Rweb"
as the first four characters will be translated to a text input field and
a submit button compute via Rweb
.
By pressing this button the code of the text field will be
sent for evaluation to Rweb http://rweb.stat.umn.edu/Rweb/
and the results appears in a new browser window.
This link to Rweb has been inspirited by web pages like
Technical remarks:
To format small pieces of code in text chunks you have to put them in
[[...]]
-brackets: text text [[code]] text text
.
One occurence of such a code in a text line is assumed to work always.
If an error emerges caused by formatting code in a text chunk
simplify the line by splitting it.
Sometimes you want to use
[[
- or even <<
-characters in your text. Then it
may be necessary to escape them by an @
-sign and
you have to type in: @<<
, @[[
and so on.
weaveRhtml
expands the input by adding a simple html-header
as well as some links for navigation.
Chunk numbers are written in front of the code chunk headers.
Further details: Some LaTeX macros are transformed to improve the html document.
1. weaveRhtml
looks for the LaTeX macros \author, \title and \date at the beginning of the input text.
If these macros are found their arguments are used to construct a simple
html-head.
2. \section{...}, \subsection{...}, \paragraph{...} macros will be extracted to include some section titles, subsection titles, paragraph titles in bold face fonts. Additionally a simple table of contents is generated.
3. Text lines between \begin{center} and \end{center} are centered.
4. Text lines between \begin{quote} and \end{quote} are shifted a little bit to the right.
5. Text lines between \begin{itemize} and \end{itemize} define a listing. The items of such a list have to begin with \item.
6. \emh{xyz} is transformed to xyz -- xyz will appear italic.
7. \texttt{xyz} is transformed to xyz
-- this is formated like code.
weaveR
, tangleR
## This example cannot be run by examples() but should be work
## in an interactive R session
weaveRhtml("testfile.rev","testfile.tex")
weaveR("testfile.rev")
## The function is currently defined as
weaveRhtml<-function(in.file,out.file){
# german documentation of the code:
# look for file webR.pdf, P. Wolf 060910
...
}
Run the code above in your browser using DataLab