{\def {\eaddr \=subject \addr}
{\tt <{\a \href={mailto:\addr
\/{\if \subject
{?subject=\subject}}} \addr}>}}
{\def {\compare \latte \html}
{\table \border=1 \bgcolor=#f0f0ff
{\tr \valign=top
{\th Latte}
{\th HTML}}
{\tr \valign=top
{\td {\tt \latte}}
{\td {\tt \html}}}}}
{\page \name={Latte examples}
{\h3 Plain text}
In HTML, several common typographical symbols are "magic." If you
want to include ", &, <, or > in your text, you must write them using
special codes: {\tt "}, {\tt &}, {\tt <}, and {\tt
>}. This tends to make your text hard to read, especially since
the codes don't look anything like the characters they replace.
Latte's only magic characters are \\, \{, and \}, which are far less
common in ordinary text than HTML's magic characters are; and to
include them in a document, you need only precede them with \\.
{\compare
{In "fish & chips," the "&" is between "fish" and "chips."}
{In "fish & chips," the "&" is between
"fish" and "chips."}}
{\h3 Paragraph breaks}
In HTML, every paragraph must begin with {\tt <p>}, even though in
most other contexts we only need to insert a blank line to denote a
paragraph break. Thus it is easy to forget the {\tt <p>} in some
places where it's needed, causing paragraphs to run together
confusingly.
Latte, on the other hand, allows you to separate paragraphs with a
blank line as you're already accustomed to do.
{\compare
{This is one paragraph.
This is another.}
{This is one paragraph.
<p>This is another.}}
{\h3 E-mail addresses}
The function {\tt \\eaddr} is defined and used on the {\a
\href=correspond.html Correspond} page. It's for denoting clickable
e-mail addresses. Here's a simple version of the function
definition:
{\example
\{\\def \{\\eaddr \\addr\}
\{\\tt <\{\\a \\href=\{mailto:\\addr\} \\addr\}>\}\}}
With this definition, here's how one can write `Send a message with
the subject "subscribe" to {\eaddr latte-request@zanshin.com}':
{\compare
{Send a message with the subject "subscribe" to
\{\\eaddr{\c-nbsp}latte-request@zanshin.com\}}
{Send a message with the subject "subscribe" to <tt><<a
href="mailto:latte-request@zanshin.com"> latte-request@zanshin.com
</a>></tt>}}
{\h3 Alternating colors}
In the user survey form on the {\a \href=download.html Download}
page, we use alternating background colors to visually distinguish
the different questions. The basic HTML structure is this:
{\example
<table>
<tr bgcolor="{\i first color}"> {\i ...} </tr>
<tr bgcolor="{\i second color}"> {\i ...} </tr>
<tr bgcolor="{\i first color}"> {\i ...} </tr>
<tr bgcolor="{\i second color}"> {\i ...} </tr>
{\i ...}
</table>}
Rather than repeat those colors throughout the document, we define
the colors in one place:
{\example
\{\\def \\colors \{{\i first color}
{\i second color}\}\}}
and then define a function, {\tt \\next-color}, that automatically
alternates colors each time it's used. So the basic Latte structure
is this:
{\example
\{\\table
\{\\tr \\bgcolor=\{\\next-color\} {\i ...}\}
\{\\tr \\bgcolor=\{\\next-color\} {\i ...}\}
{\i ...}\}}
and if we ever wish to change the color scheme, we only have to do it
in one place. Also, inserting new questions in the middle of the
survey won't mess up the alternation of colors; it'll just continue
working.
Of course, this is Latte; even the simplified structure just
described is more repetitive than necessary. So we defined another
function, {\tt \\survey-question}, that automatically includes the
setting of {\tt bgcolor} (among other things). So the real structure
is this:
{\example
\{\\table
\{\\survey-question {\i ...}\}
\{\\survey-question {\i ...}\}
{\i ...}\}}
}