<P><B>txt2html</B> is a simple tool for converting text files into HTML files.
Text files can contain simple formatting and mark-up commands that
<B>txt2html</B> converts into HTML.
</P>
<P><B>txt2html</B> was written by <A HREF = "http://www.cs.sandia.gov/~sjplimp">Steve Plimpton</A>. I use it for
<A HREF = "http://www.cs.sandia.gov/~sjplimp/lammps.html">documentation</A> and <A HREF = "http://www.cs.sandia.gov/~sjplimp">WWW pages</A>. Anna Reese added the table
formatting options.
</P>
<P>See the <A HREF = "example.txt">example.txt</A> and <A HREF = "example.html">example.html</A>
files in the <B>txt2html</B> directory for examples of what all the
formatting commands and mark-up syntax end up looking like in HTML.
</P>
<HR>
<P><B>Syntax:</B>
</P>
<DL><DT>txt2html file
<DD> read from text file, write HTML to standard output
<DT>txt2html file1 file2 file3 ...
<DD> read each argument as text file, write one HTML file per argument
</DL>
<P>Input files are first opened with the specified name. If that fails,
a ".txt" suffix is added. Output files are created with an ".html"
suffix, which is either added or replaces the ".txt" suffix.
</P>
<HR>
<P><B>Compiling:</B>
</P>
<P>The source for <B>txt2html</B> is a single C++ file. Compile it by typing:
</P>
<PRE>g++ -o txt2html txt2html.cpp
</PRE>
<HR>
<P><B>How the tool works:</B>
</P>
<P><B>txt2html</B> reads a text file, one <I>paragraph</I> at a time. A paragraph
ends with:
</P>
<UL><LI> a blank line
<LI> a line whose final word starts with ":" (a format string)
<LI> the end of the file
</UL>
<P>Any line in the paragraph which ends with "\" is concatenated to the
following line by removing the "\" character and following newline.
This can be useful for some of the formatting commands described below
that operate on individual lines in the paragraph.
</P>
<P>If a paragraph starts with a "<" character and ends with a ">"
character, it is treated as raw HTML and is written directly into the
output file.
</P>
<P>If a paragraph does not end with a format string, then it is
surrounded with HTML paragraph markers (<P> and </P>),
<A HREF = "#markup">mark-up</A> is performed, and the paragraph is written to the
output file.
</P>
<P>If the paragraph ends with a format string, then <A HREF = "#format">formatting</A>
is performed, <A HREF = "#markup">mark-up</A> is performed, and the paragraph is
written to the output file.
</P>
<HR>
<A NAME = "format"></A><B>Formatting:</B>
<P>A format string is the last word of a paragraph if it starts with a
":" character. A format string contains one or more comma-separated
commands, like ":ulb,l" or ":c,h3". Note that a format string cannot
contain spaces, else it would not be the last word. An individual
command can have 0 or more arguments:
</P>
<UL><LI> <I>b</I> or <I>line()</I> = 0 arguments
<LI> <I>image(file)</I> = 1 argument
<LI> <I>link(alias,value)</I> = 2 or more comma-separated arguments
</UL>
<P>Format commands add HTML markers at the beginning or end of the
paragraph and individual lines. Commands are processed in the order
they appear in the format string. Thus if two commands add HTML
markers to the beginning of the paragraph, the 2nd command's marker
will appear 2nd. The reverse is true at the end of the paragraph; the
2nd command's marker will appear 1st. Some comands, like <I>line</I> or
<I>image</I> make most sense if used as stand-alone commands without an
accompanying paragraph.
</P>
<P>Commands that format the entire paragraph:
</P>
<UL><LI> p --> surround the paragraph with <P> </P>
<LI> b --> put <BR> at the end of the paragraph
<LI> pre --> surround the paragraph with <PRE> </PRE>
<LI> c --> surround the paragraph with <CENTER> </CENTER>
<LI> h1,h2,h3,h4,h5,h6 --> surround the paragraph with <H1> </H1>, etc
</UL>
<P>Commands that format the lines of the paragraph as a list:
</P>
<UL><LI> ul --> surround the paragraph with <UL> </UL>, put <LI> at start of every line
<LI> ol --> surround the paragraph with <OL> </OL>, put <LI> at start of every line
<LI> dl --> surround the paragraph with <DL> </DL>, alternate <DT> and <DD> at start of every line
</UL>
<P>Commands that treat the paragraph as one entry in a list:
</P>
<UL><LI> l --> put <LI> at the beginning of the paragraph
<LI> dt --> put <DT> at the beginning of the paragraph
<LI> dd --> put <DD> at the beginning of the paragraph
<LI> ulb --> put <UL> at the beginning of the paragraph
<LI> ule --> put </UL> at the end of the paragraph
<LI> olb --> put <OL> at the beginning of the paragraph
<LI> ole --> put </OL> at the end of the paragraph
<LI> dlb --> put <DL> at the beginning of the paragraph
<LI> dle --> put </DL> at the end of the paragraph
</UL>
<P>Commands applied to each line of the paragraph:
</P>
<UL><LI> all(p) --> surround each line with <P> </P>
<LI> all(c) --> surround each line with <CENTER> </CENTER>
<LI> all(b) --> append a <BR> to each line
<LI> all(l) --> prepend a <LI> to each line
</UL>
<P>Special commands (all HTML is inserted at beginning of paragraph):
</P>
<UL><LI> line --> insert a horizontal line = <HR>