r44178 - in /packages/mrmpi/trunk/debian: changelog patches/series patches/txt2html.patch

malat-guest at users.alioth.debian.org malat-guest at users.alioth.debian.org
Thu Dec 15 17:06:16 UTC 2011


Author: malat-guest
Date: Thu Dec 15 17:06:16 2011
New Revision: 44178

URL: http://svn.debian.org/wsvn/debian-science/?sc=1&rev=44178
Log:
Redo documentation

Added:
    packages/mrmpi/trunk/debian/patches/txt2html.patch
Modified:
    packages/mrmpi/trunk/debian/changelog
    packages/mrmpi/trunk/debian/patches/series

Modified: packages/mrmpi/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/debian-science/packages/mrmpi/trunk/debian/changelog?rev=44178&op=diff
==============================================================================
--- packages/mrmpi/trunk/debian/changelog (original)
+++ packages/mrmpi/trunk/debian/changelog Thu Dec 15 17:06:16 2011
@@ -1,4 +1,4 @@
-mrmpi (1.0~20110621-1) UNRELEASED; urgency=low
+mrmpi (1.0~20110620-1) UNRELEASED; urgency=low
 
   * Build documentation
 

Modified: packages/mrmpi/trunk/debian/patches/series
URL: http://svn.debian.org/wsvn/debian-science/packages/mrmpi/trunk/debian/patches/series?rev=44178&op=diff
==============================================================================
--- packages/mrmpi/trunk/debian/patches/series (original)
+++ packages/mrmpi/trunk/debian/patches/series Thu Dec 15 17:06:16 2011
@@ -1,3 +1,4 @@
 addcmake.patch
 tweakcmake.patch
 add_config.patch
+txt2html.patch

Added: packages/mrmpi/trunk/debian/patches/txt2html.patch
URL: http://svn.debian.org/wsvn/debian-science/packages/mrmpi/trunk/debian/patches/txt2html.patch?rev=44178&op=file
==============================================================================
--- packages/mrmpi/trunk/debian/patches/txt2html.patch (added)
+++ packages/mrmpi/trunk/debian/patches/txt2html.patch Thu Dec 15 17:06:16 2011
@@ -1,0 +1,1400 @@
+Index: mrmpi-1.0~20110620/txt2html/README.html
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ mrmpi-1.0~20110620/txt2html/README.html	2011-07-25 21:33:38.000000000 +0200
+@@ -0,0 +1,237 @@
++<HTML>
++<H3>txt2html - a text to HTML conversion tool 
++</H3>
++<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>
++<LI>  image(file) --> insert an image = <IMG SRC = "file">
++<LI>  image(file,link) --> insert an image that when clicked on goes to link
++<LI>  link(name) --> insert a named link that can be referred to     elsewhere (see <A HREF = "#markup">mark-up</A>) = <A NAME = "name"></A>
++<LI>  link(alias,value) --> define a link alias that can be used     elsewhere in this file (see <A HREF = "#markup">mark-up</A>) 
++</UL>
++<P>Table command:
++</P>
++<UL><LI>  tb(c=3,b=5,w=100%,a=c) --> format the paragraph as a table 
++</UL>
++<P>Arguments within tb() can appear in any order and are all optional,
++since they each have default values.
++</P>
++<UL><LI>  c=N --> Make an N-column table.  Treat the paragraph as one
++  long list of entries (separated by the separator character) and put
++  them into N columns one after the other.  If N = 0, treat each line
++  of the paragraph as one row of the table with as many columns as
++  there are maximum entries in any line.  Default is c=0. 
++
++<LI>  s=: --> Use the character string following the equal sign as
++  the separator between entries.  Default separator is a comma "," which
++  you cannot specify directly since the comma delimits the tb() arguments 
++
++<LI>  b=N --> Create a border N pixels wide.  If N is 0, there is no
++  border between or outside the cells.  If N is 1, there is a minimal
++  border between and outside all cells.  For N > 1, the border between
++  cells does not change but the outside border gets wider.  Default is
++  b=1. 
++
++<LI>  w=N or w=N% --&gt The first form makes each cell of the table at
++  least N pixels wide.  The second form makes the entire table take up
++  N% of the width of the browser window.  Default is w=0 which means
++  each cell will be just as wide as the text it contains.  
++
++<LI>  a=X --&gt Align the entire table at the left, center, or right of the
++  browser window, for X = "l", "c", or "r".  Default is a=c. 
++
++<LI>  ea=X --&gt Align the text in each entry at the left, center, or
++  right of its cell, for X = "l", "c", or "r".  Default is browser's 
++  default (typically left). 
++
++<LI>  eva=X --&gt Vertically align the text in each entry at the
++  top, middle, baseline, or bottom of its cell, for X = "t", "m", "ba", 
++  or "bo".  Default is browser's default (typically middle). 
++
++<LI>  cwM=N or cwM=N% --&gt The first form makes column M be at least
++  N pixels wide.  The second form makes column M take up N% of the
++  width of the browser window.  This setting overrides the "w"
++  argument for column M.  Only one column per table can be tweaked
++  with this argument.  Default is no settings for any column. 
++
++<LI>  caM=X --&gt Align the text in each entry of column M at the left,
++  center, or right of its cell, for X = "l", "c", or "r".  This
++  setting overrides the "ea" argument for column M.  Only one column
++  per table can be tweaked with this argument.  Default is no settings
++  for any column. 
++
++<LI>  cvaM=X --&gt Vertically align the text in each entry of column m
++  at the top, middle, baseline, or bottom of its cell, for X = "t",
++  "m", "ba", or "bo".  This setting overrides the "eva" argument for
++  column M.  Only one column per table can be tweaked with this
++  argument.  Default is no settings for any column. 
++</UL>
++<HR>
++
++<A NAME = "markup"></A><B>Mark-up:</B> 
++
++<P>The text of the paragraph is scanned for special mark-up characters
++which are converted into HTML.
++</P>
++<P>Bold and italic characters:
++</P>
++  <UL> <LI> "[" (left brace) --> turn-on bold by inserting a <B>
++  <LI> "]" (right brace) --> turn-off bold by inserting a </B>
++  <LI> "{" (left bracket) --> turn-on italics by inserting a <I>
++  <LI> "}" (right bracket) --> turn-off italics by 
++    inserting a </I> </UL>
++
++<P>If a backspace '\' preceeds any of the bold/italic mark-up characters,
++then mark-up is not performed; the mark-up character is simply left in
++the text.
++</P>
++<P>Links are inserted by enclosing a section of text in double quotes,
++and appending an underscore to the ending quote, followed by the link.
++The link ends when whitespace is found, except that trailing
++punctuation characters (comma, period, semi-colon, colon, question
++mark, exclamation point, parenthesis) are not considered part of the
++link.
++</P>
++<P> A link of the form "text"_link becomes <A HREF =
++"link">text</A> in the HTML output.  The only exception is if
++"link" is defined elsewhere in the file as an alias (see the link
++command above).  In that case, the value is used instead of the alias
++name. </P>
++
++<P>With these rules, links can take several forms.
++</P>
++<UL> <LI> "This links"_#abc to another part of this file which is
++labeled with a :link(abc) command. <BR>
++<LI> "This links"_other.html to another file named other.html. <BR>
++<LI> "This links"_other.html#abc to another file which has an "abc"
++location defined internally. <BR>
++<LI> "This links"_http://www.google.com to a WWW site. <BR>
++<LI> "This"_M12 could be used in place of any of the above forms.  It
++requires an alias like :link(M12,http://www.google.com) to be defined
++elsewhere in the file. </UL>
++
++</HTML>
+Index: mrmpi-1.0~20110620/txt2html/README.txt
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ mrmpi-1.0~20110620/txt2html/README.txt	2011-07-25 21:33:38.000000000 +0200
+@@ -0,0 +1,239 @@
++txt2html - a text to HTML conversion tool :h3
++
++[txt2html] is a simple tool for converting text files into HTML files.
++Text files can contain simple formatting and mark-up commands that
++[txt2html] converts into HTML.
++
++[txt2html] was written by "Steve Plimpton"_sjp.  I use it for
++"documentation"_doc and "WWW pages"_www.  Anna Reese added the table
++formatting options.
++
++See the "example.txt"_example.txt and "example.html"_example.html
++files in the [txt2html] directory for examples of what all the
++formatting commands and mark-up syntax end up looking like in HTML.
++
++:link(sjp,http://www.cs.sandia.gov/~sjplimp)
++:link(www,http://www.cs.sandia.gov/~sjplimp)
++:link(doc,http://www.cs.sandia.gov/~sjplimp/lammps.html)
++
++:line
++
++[Syntax:]
++
++txt2html file
++  read from text file, write HTML to standard output
++txt2html file1 file2 file3 ...
++  read each argument as text file, write one HTML file per argument :dl
++
++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.
++
++:line
++
++[Compiling:]
++
++The source for [txt2html] is a single C++ file.  Compile it by typing:
++
++g++ -o txt2html txt2html.cpp :pre
++
++:line
++
++[How the tool works:]
++
++[txt2html] reads a text file, one {paragraph} at a time.  A paragraph
++ends with:
++
++  a blank line
++  a line whose final word starts with ":" (a format string)
++  the end of the file :ul
++
++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.
++
++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.
++
++If a paragraph does not end with a format string, then it is
++surrounded with HTML paragraph markers (<P> and </P>),
++"mark-up"_#markup is performed, and the paragraph is written to the
++output file.
++
++If the paragraph ends with a format string, then "formatting"_#format
++is performed, "mark-up"_#markup is performed, and the paragraph is
++written to the output file.
++
++:line
++
++[Formatting:] :link(format)
++
++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:
++
++  {b} or {line()} = 0 arguments
++  {image(file)} = 1 argument
++  {link(alias,value)} = 2 or more comma-separated arguments :ul
++
++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 {line} or
++{image} make most sense if used as stand-alone commands without an
++accompanying paragraph.
++
++Commands that format the entire paragraph:
++
++  p --> surround the paragraph with <P> </P>
++  b --> put <BR> at the end of the paragraph
++  pre --> surround the paragraph with <PRE> </PRE>
++  c --> surround the paragraph with <CENTER> </CENTER>
++  h1,h2,h3,h4,h5,h6 --> surround the paragraph with \
++                           <H1> </H1>, etc :ul
++
++Commands that format the lines of the paragraph as a list:
++
++  ul --> surround the paragraph with <UL> </UL>, \
++    put <LI> at start of every line
++  ol --> surround the paragraph with <OL> </OL>, \
++    put <LI> at start of every line
++  dl --> surround the paragraph with <DL> </DL>, \
++    alternate <DT> and <DD> at start of every line :ul
++
++Commands that treat the paragraph as one entry in a list:
++
++  l --> put <LI> at the beginning of the paragraph
++  dt --> put <DT> at the beginning of the paragraph
++  dd --> put <DD> at the beginning of the paragraph
++  ulb --> put <UL> at the beginning of the paragraph
++  ule --> put </UL> at the end of the paragraph
++  olb --> put <OL> at the beginning of the paragraph
++  ole --> put </OL> at the end of the paragraph
++  dlb --> put <DL> at the beginning of the paragraph
++  dle --> put </DL> at the end of the paragraph :ul
++
++Commands applied to each line of the paragraph:
++
++  all(p) --> surround each line with <P> </P>
++  all(c) --> surround each line with <CENTER> </CENTER>
++  all(b) --> append a <BR> to each line
++  all(l) --> prepend a <LI> to each line :ul
++
++Special commands (all HTML is inserted at beginning of paragraph):
++
++  line --> insert a horizontal line = <HR>
++  image(file) --> insert an image = <IMG SRC = "file">
++  image(file,link) --> insert an image that when clicked on goes to link
++  link(name) --> insert a named link that can be referred to \
++    elsewhere (see "mark-up"_#markup) = <A NAME = "name"></A>
++  link(alias,value) --> define a link alias that can be used \
++    elsewhere in this file (see "mark-up"_#markup) :ul
++
++
++Table command:
++
++  tb(c=3,b=5,w=100%,a=c) --> format the paragraph as a table :ul
++
++Arguments within tb() can appear in any order and are all optional,
++since they each have default values.
++
++  c=N --> Make an N-column table.  Treat the paragraph as one
++  long list of entries (separated by the separator character) and put
++  them into N columns one after the other.  If N = 0, treat each line
++  of the paragraph as one row of the table with as many columns as
++  there are maximum entries in any line.  Default is c=0. :ulb,l
++
++  s=: --> Use the character string following the equal sign as
++  the separator between entries.  Default separator is a comma "," which
++  you cannot specify directly since the comma delimits the tb() arguments :l
++
++  b=N --> Create a border N pixels wide.  If N is 0, there is no
++  border between or outside the cells.  If N is 1, there is a minimal
++  border between and outside all cells.  For N > 1, the border between
++  cells does not change but the outside border gets wider.  Default is
++  b=1. :l
++
++  w=N or w=N% --&gt The first form makes each cell of the table at
++  least N pixels wide.  The second form makes the entire table take up
++  N% of the width of the browser window.  Default is w=0 which means
++  each cell will be just as wide as the text it contains.  :l
++
++  a=X --&gt Align the entire table at the left, center, or right of the
++  browser window, for X = "l", "c", or "r".  Default is a=c. :l
++
++  ea=X --&gt Align the text in each entry at the left, center, or
++  right of its cell, for X = "l", "c", or "r".  Default is browser's 
++  default (typically left). :l
++
++  eva=X --&gt Vertically align the text in each entry at the
++  top, middle, baseline, or bottom of its cell, for X = "t", "m", "ba", 
++  or "bo".  Default is browser's default (typically middle). :l
++
++  cwM=N or cwM=N% --&gt The first form makes column M be at least
++  N pixels wide.  The second form makes column M take up N% of the
++  width of the browser window.  This setting overrides the "w"
++  argument for column M.  Only one column per table can be tweaked
++  with this argument.  Default is no settings for any column. :l
++
++  caM=X --&gt Align the text in each entry of column M at the left,
++  center, or right of its cell, for X = "l", "c", or "r".  This
++  setting overrides the "ea" argument for column M.  Only one column
++  per table can be tweaked with this argument.  Default is no settings
++  for any column. :l
++
++  cvaM=X --&gt Vertically align the text in each entry of column m
++  at the top, middle, baseline, or bottom of its cell, for X = "t",
++  "m", "ba", or "bo".  This setting overrides the "eva" argument for
++  column M.  Only one column per table can be tweaked with this
++  argument.  Default is no settings for any column. :l,ule
++
++:line
++
++[Mark-up:] :link(markup)
++
++The text of the paragraph is scanned for special mark-up characters
++which are converted into HTML.
++
++Bold and italic characters:
++
++  <UL> <LI> "[" (left brace) --> turn-on bold by inserting a <B>
++  <LI> "]" (right brace) --> turn-off bold by inserting a </B>
++  <LI> "{" (left bracket) --> turn-on italics by inserting a <I>
++  <LI> "}" (right bracket) --> turn-off italics by 
++    inserting a </I> </UL>
++
++If a backslash ESCAPE character '\' preceeds any of the bold/italic
++mark-up characters, then mark-up is not performed; the mark-up
++character is simply left in the text.
++
++Links are inserted by enclosing a section of text in double quotes,
++and appending an underscore to the ending quote, followed by the link.
++The link ends when whitespace is found, except that trailing
++punctuation characters (comma, period, semi-colon, colon, question
++mark, exclamation point, parenthesis) are not considered part of the
++link.
++
++<P> A link of the form "text"_link becomes <A HREF =
++"link">text</A> in the HTML output.  The only exception is if
++"link" is defined elsewhere in the file as an alias (see the link
++command above).  In that case, the value is used instead of the alias
++name. </P>
++
++With these rules, links can take several forms.
++
++<UL> <LI> "This links"_#abc to another part of this file which is
++labeled with a :link(abc) command. <BR>
++<LI> "This links"_other.html to another file named other.html. <BR>
++<LI> "This links"_other.html#abc to another file which has an "abc"
++location defined internally. <BR>
++<LI> "This links"_http://www.google.com to a WWW site. <BR>
++<LI> "This"_M12 could be used in place of any of the above forms.  It
++requires an alias like :link(M12,http://www.google.com) to be defined
++elsewhere in the file. </UL>
+Index: mrmpi-1.0~20110620/txt2html/equation.gif
+===================================================================
+Binary files /dev/null	1970-01-01 00:00:00.000000000 +0000 and mrmpi-1.0~20110620/txt2html/equation.gif	2011-07-25 21:33:38.000000000 +0200 differ
+Index: mrmpi-1.0~20110620/txt2html/txt2html.cpp
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ mrmpi-1.0~20110620/txt2html/txt2html.cpp	2011-07-25 21:33:38.000000000 +0200
+@@ -0,0 +1,906 @@
++// txt2html - written by Steve Plimpton, May 2004
++// table formatting by Anna Reese, Jul 2004
++// Sandia National Labs, www.cs.sandia.gov/~sjplimp
++//
++// txt2html converts a text file with simple formatting & markup into HTML
++// formatting & markup specification is given in README
++//
++// Syntax: txt2html options file                read one file, write to stdout
++//         txt2html optoins file1 file2 ...     read files, write files.html
++//
++// options:
++//   -b = add a page-break comment to end of each HTML file
++//     useful when set of HTML files will be converted to PDF
++//   -x file = skip a file even if it appears in file list
++//     specify full file name of input file
++// input files are first opened as-is
++//   if that fails a .txt suffix is added
++// output files have an .html suffix added or replaced
++//   (unless written to stdout)
++
++#include <string>
++#include <vector>
++#include <iostream>
++#include <cstdio>
++#include <cstdlib>
++#include <cstring>
++
++using namespace std;
++
++#define MAXLINE 1024
++
++// function prototypes
++
++int next_paragraph(FILE *fp, string &paragraph);
++int index_of_first_char_of_last_word(string &paragraph);
++void process_commands(int flag, string &s, string &pre, string &post);
++void substitute(string &s);
++string td_tag(int currentc);
++int find_n(string &s, int nend, int &n1);
++void file_open(int npair, string &infile, FILE **in, FILE **out);
++
++// global variables for links, tables, lists, all command
++
++vector<string> alias1;
++vector<string> alias2;
++int nlink;
++
++int tableflag;       // makes a table if tb command specified
++int rowquit;         // number of cols per row if c=N specified (default = 0)
++string dwidth;       // width for all of the columns
++string tabledelim;   // speciallized separator
++string tablealign;   // alignment for the table as an image
++string dataalign;    // alignment for data in table
++string rowvalign;    // vertical alignment for table
++
++int ncnum;             // # of columns with specified width
++vector<int> cnum;      // column IDs
++vector<string> cwidth; // column widths
++
++int ncalign;              // # of columns with specified alignment
++vector<int> acolnum;      // column IDs
++vector<string> colalign ; // column alignment
++
++int ncvalign;              // # of columns with specified vertical alignment
++vector<int> vacolnum;      // column IDs
++vector<string> colvalign ; // column vertical alignment
++
++string listflag;
++string allflag;
++
++// main program
++
++int main(int narg, char **arg)
++{
++  int i,n,npair;
++  string *infile;
++  FILE *in,*out;
++  int style,ifirst,ilast;
++  string raw,pre,post,body,commands,final;
++
++  // parse command-line options and args
++  // setup list of files to process
++  // npair = # of files to process
++  // infile = input file names
++
++  if (narg == 1) {
++    fprintf(stderr,"Syntax: txt2html options file\n");
++    fprintf(stderr,"        txt2html options file1 file2 ...\n");
++    exit(1);
++  }
++
++  int breakflag = 0;
++  int nskip = 0;
++  char **skipfiles = NULL;
++
++  int iarg = 1;
++  while (arg[iarg][0] == '-') {
++    if (strcmp(arg[iarg],"-b") == 0) breakflag = 1;
++    else if (strcmp(arg[iarg],"-x") == 0) {
++      skipfiles = (char **) realloc(skipfiles,(nskip+1)*sizeof(char *));
++      n = strlen(arg[iarg+1]) + 1;
++      skipfiles[nskip] = new char[n];
++      strcpy(skipfiles[nskip],arg[iarg+1]);
++      nskip++;
++      iarg++;
++    } else {
++      fprintf(stderr,"Syntax: txt2html options file\n");
++      fprintf(stderr,"        txt2html options file1 file2 ...\n");
++      exit(1);
++    }
++    iarg++;
++  }
++
++  if (narg-iarg == 1) {
++    npair = 1;
++    infile = new string[npair];
++    infile[0] = arg[narg-1];
++  } else {
++    npair = narg-iarg;
++    infile = new string[npair];
++    for (int i = 0; i < npair; i++) infile[i] = arg[i+iarg];
++  }
++
++  // loop over files
++
++  for (int ipair = 0; ipair < npair; ipair++) {
++
++    // skip file if matches -x switch
++
++    int flag = 0;
++    for (int i = 0; i < nskip; i++)
++      if (strcmp(infile[ipair].c_str(),skipfiles[i]) == 0) flag = 1;
++    if (flag) continue;
++
++    // clear global variables before processing file
++
++    alias1.clear();
++    alias2.clear();
++    nlink = 0;
++    tableflag = 0;
++    listflag = "";
++    allflag = "";
++
++    // open files & message to screen
++
++    file_open(0,infile[ipair],&in,&out);
++    fprintf(stderr,"Converting %s ...\n",infile[ipair].c_str());
++
++    // scan file for link definitions
++    // read file one paragraph at a time
++    // process commands, looking only for link definitions
++
++    while (style = next_paragraph(in,raw)) {
++
++      if (style == 2) {
++	int n = index_of_first_char_of_last_word(raw);
++	commands = raw.substr(n+1);
++	process_commands(0,commands,pre,post);
++      }
++
++      raw.erase();
++    }
++
++    // close & reopen files
++
++    fclose(in);
++    file_open(npair,infile[ipair],&in,&out);
++
++    // write leading <HTML>
++
++    fprintf(out,"<HTML>\n");
++
++    // process entire file
++    // read file one paragraph at a time
++    // delete newlines when line-continuation char at end-of-line
++    // process commands for each paragraph
++    // substitute text for each paragraph
++    // write HTML to output file
++
++    while (style = next_paragraph(in,raw)) {
++
++      n = raw.find("\\\n");
++      while (n != string::npos) {
++	raw.erase(n,2);
++	n = raw.find("\\\n");
++      }
++
++      ifirst = raw.find_first_not_of(" \t\n");
++      ilast = raw.find_last_not_of(" \t\n");
++
++      pre.erase();
++      post.erase();
++
++      if (raw[ifirst] == '<' && raw[ilast] == '>') {
++	body = raw;
++      } else if (style == 1) {
++	body = raw;
++	commands = "p\n";
++	process_commands(1,commands,pre,post);
++	substitute(body);
++      } else {
++	int n = index_of_first_char_of_last_word(raw);
++	body = raw.substr(0,n) + "\n";
++	commands = raw.substr(n+1);
++	process_commands(1,commands,pre,post);
++	substitute(body);
++      }
++      
++      final = pre + body + post;
++      fprintf(out,"%s\n",final.c_str());
++
++      raw.erase();
++    }
++
++    // write trailing </HTML>
++
++    if (breakflag) fprintf(out,"<!-- PAGE BREAK -->\n");
++    fprintf(out,"</HTML>\n");
++
++    // close files
++
++    fclose(in);
++    if (out != stdout) fclose(out);
++  }
++  
++  // clean up memory
++  
++  for (i = 0; i < nskip; i++) delete [] skipfiles[i];
++  if (skipfiles) free(skipfiles);
++  delete [] infile;
++}
++
++// return next paragraph as string
++// discard leading blank lines
++// paragraph is terminated by:
++//   EOF or blank line or line ending with command that starts with ":"
++// return 0 if EOF and no paragraph
++// return 1 if no trailing command
++// return 2 if trailing command
++
++int next_paragraph(FILE *fp, string &paragraph)
++{
++  char *ptr;
++  char str[MAXLINE];
++  int first = 1;
++
++  while (1) {
++    ptr = fgets(str,MAXLINE,fp);
++    if (ptr == NULL && first) return 0;
++    if (ptr == NULL) return 1;
++    if (strlen(str) == MAXLINE-1) {
++      fprintf(stderr,"ERROR: File has too-long a string - increase MAXLINE\n");
++      exit(1);
++    }
++    if (strspn(str," \t\n") == strlen(str) && first) continue;
++    if (strspn(str," \t\n") == strlen(str)) return 1;
++    first = 0;
++    paragraph += str;
++    if (paragraph[index_of_first_char_of_last_word(paragraph)] == ':')
++      return 2;
++  }
++}
++
++// return index of first char in last word of paragraph string
++
++int index_of_first_char_of_last_word(string &paragraph)
++{
++  int n = paragraph.find_last_not_of(" \t\n");
++  int m = paragraph.find_last_of(" \t\n",n);
++  if (m == string::npos) return 0;
++  else return m+1;
++}
++
++// apply commands one after the other to the paragraph
++
++void process_commands(int flag, string &s, string &pre, string &post)
++{
++  int start,stop,last,narg;
++  string command;
++  vector<string> arg;
++
++  start = 0;
++  last = s.find_last_not_of(" \t\n");
++
++  while (start <= last) {
++
++    // grab a single command with optional arguments
++    // command = name of command
++    // narg = # of args
++    // arg = list of argument strings
++
++    stop = s.find_first_of(",( \t\n",start);
++    if (s[stop] == '(') {
++      command = s.substr(start,stop-start);
++      start = stop+1;
++      narg = 0;
++      while (1) {
++	stop = s.find_first_of(",)",start);
++	if (stop == string::npos) {
++	  fprintf(stderr,"ERROR: No trailing parenthesis in %s\n",s.c_str());
++	  exit(1);
++	}
++	arg.resize(narg+1);
++	arg[narg] = s.substr(start,stop-start);
++	narg++;
++	start = stop+1;
++	if (s[stop] == ')') {
++	  start++;
++	  break;
++	}
++      }
++    } else {
++      command = s.substr(start,stop-start);
++      start = stop+1;
++      narg = 0;
++    }
++
++    // if only in scan mode, just operate on link command
++
++    if (flag == 0) {
++      if (command == "link" && narg == 2) {
++	//	s.erase(s.length()-1,1);
++	for (int i = 0; i < nlink; i++)
++	  if (alias1[i] == arg[0]) {
++	    fprintf(stderr,"ERROR: Link %s appears more than once\n",
++		    arg[0].c_str());
++	    exit(1);
++	  }
++	alias1.resize(nlink+1);
++	alias2.resize(nlink+1);
++	alias1[nlink] = arg[0];
++	alias2[nlink] = arg[1];
++	nlink++;
++      } else continue;
++    }
++
++    // process the command
++
++    if (command == "line") {
++      pre.append("<HR>");
++    } else if (command == "p") {
++      pre.append("<P>");
++      post.insert(0,"</P>");
++    } else if (command == "pre") {
++      pre.append("<PRE>");
++      post.insert(0,"</PRE>");
++    } else if (command == "c") {
++      pre.append("<CENTER>");
++      post.insert(0,"</CENTER>");
++    } else if (command == "h1") {
++      pre.append("<H1>");
++      post.insert(0,"</H1>");
++    } else if (command == "h2") {
++      pre.append("<H2>");
++      post.insert(0,"</H2>");
++    } else if (command == "h3") {
++      pre.append("<H3>");
++      post.insert(0,"</H3>");
++    } else if (command == "h4") {
++      pre.append("<H4>");
++      post.insert(0,"</H4>");
++    } else if (command == "h5") {
++      pre.append("<H5>");
++      post.insert(0,"</H5>");
++    } else if (command == "h6") {
++      pre.append("<H6>");
++      post.insert(0,"</H6>");
++    } else if (command == "b") {
++      post.insert(0,"<BR>");
++    } else if (command == "ulb") {
++      pre.append("<UL>");
++    } else if (command == "ule") {
++      post.insert(0,"</UL>");
++    } else if (command == "olb") {
++      pre.append("<OL>");
++    } else if (command == "ole") {
++      post.insert(0,"</OL>");
++    } else if (command == "dlb") {
++      pre.append("<DL>");
++    } else if (command == "dle") {
++      post.insert(0,"</DL>");
++    } else if (command == "l") {
++      pre.append("<LI>");
++    } else if (command == "dt") {
++      pre.append("<DT>");
++    } else if (command == "dd") {
++      pre.append("<DD>");
++    } else if (command == "ul") {
++      listflag = command;
++      pre.append("<UL>");
++      post.insert(0,"</UL>");
++    } else if (command == "ol") {
++      listflag = command;
++      pre.append("<OL>");
++      post.insert(0,"</OL>");
++    } else if (command == "dl") {
++      listflag = command;
++      pre.append("<DL>");
++      post.insert(0,"</DL>");
++    } else if (command == "link") {
++      if (narg == 1) {
++	string aname = "<A NAME = \"" + arg[0] + "\"></A>";
++	pre.append(aname);
++      }
++    } else if (command == "image") {
++      if (narg == 1) {
++	string img = "<IMG SRC = \"" + arg[0] + "\">";
++	pre.append(img);
++      } else if (narg == 2) {
++	string img = "<A HREF = \"" + arg[1] + "\">" +
++	  "<IMG SRC = \"" + arg[0] + "\">" + "</A>";
++	pre.append(img);
++      }
++    }else if (command == "tb") {   // read the table command and set settings
++      tableflag = 1;
++
++      string tableborder = "1";    // these are the table defaults
++      rowquit = 0;
++      tablealign = "c";
++      dataalign = "0";
++      rowvalign = "0";
++
++      ncnum = 0;
++      ncalign = 0;
++      ncvalign = 0;
++
++      cnum.clear();
++      acolnum.clear();
++      vacolnum.clear();
++
++      cwidth.clear();
++      colalign.clear();
++      colvalign.clear();
++
++      tabledelim = ",";
++      string tw = "";
++      dwidth = "0";
++
++      for (int i = 0; i < narg; i++) {     // loop through each tb() arg
++	int tbstop;
++	string tbcommand;
++	tbstop = 0;
++	tbstop = arg[i].find("=");
++	tbcommand = arg[i].substr(0,tbstop);
++	int n = arg[i].length();
++	if (tbstop == -1) {
++	  continue;
++	} else if (tbcommand == "c") {
++	  string collumn= arg[i].substr (tbstop+1,n-(tbstop+1));
++	  rowquit = atoi(collumn.c_str());
++	} else if (tbcommand == "s") {
++	  tabledelim= arg[i].substr (tbstop+1,n-(tbstop+1));
++	} else if (tbcommand == "b") {
++	  tableborder= arg[i].substr (tbstop+1,n-(tbstop+1));
++	} else if (tbcommand == "w") {
++	  string width = "0";       
++	  if (arg[i].substr (n-1,1) == "%") {
++	    string width = arg[i].substr (tbstop+1,n-(tbstop+1));
++	    tw = " WIDTH=\"" + width + "\"";
++	  } else
++	    dwidth = arg[i].substr (tbstop+1,n-(tbstop+1));
++	} else if (tbcommand == "ea") {
++	  dataalign= arg[i].substr (tbstop+1,n-(tbstop+1));
++	} else if (tbcommand == "eva") {
++	  rowvalign= arg[i].substr (tbstop+1,n-(tbstop+1));
++	} else if (tbcommand == "a") {
++	  tablealign= arg[i].substr (tbstop+1,n-(tbstop+1));
++	} else if (tbcommand.substr(0,2) == "cw") {
++	  string cwnum= tbcommand.substr(2,tbstop-1);
++	  cnum.resize(ncnum+1);
++	  cnum[ncnum] = atoi(cwnum.c_str());
++	  cwidth.resize(ncnum+1);
++	  cwidth[ncnum]= arg[i].substr(tbstop+1,n-(tbstop+1));
++	  ncnum++;
++	} else if (tbcommand.substr(0,2) ==  "ca") {
++	  string canum= tbcommand.substr(2,tbstop-1);
++	  acolnum.resize(ncalign+1);
++	  acolnum[ncalign] = atoi(canum.c_str());
++	  colalign.resize(ncalign+1);
++	  colalign[ncalign]= arg[i].substr(tbstop+1,n-(tbstop+1));
++	  ncalign++;
++	} else if (tbcommand.substr(0,3) ==  "cva") {
++	  string cvanum= tbcommand.substr(2,tbstop-1);
++	  vacolnum.resize(ncvalign+1);
++	  vacolnum[ncvalign] = atoi(cvanum.c_str());
++	  colvalign.resize(ncvalign+1);
++	  colvalign[ncvalign]= arg[i].substr(tbstop+1,n-(tbstop+1));
++	  ncvalign++;
++	} else {
++	  fprintf(stderr,
++		  "ERROR: Unrecognized table command %s\n",tbcommand.c_str());
++	  exit(1);
++	}
++	
++	tbstop = s.find("=");
++      }
++      
++      string align;
++      if (tablealign=="c") align="center";
++      else if (tablealign=="r") align="right ";
++      else if (tablealign=="l") align="left  ";
++      else align="center";
++      string tablea = "<DIV ALIGN=" + align + ">" ;
++      pre.append(tablea);
++      pre.append("<TABLE ");
++      pre.append(tw);
++      string border=" BORDER=" + tableborder + " >\n";
++      pre.append(border);
++      post.insert(0,"</TD></TR></TABLE></DIV>\n"); 
++      
++    } else if (command == "all") {
++      if (narg == 1) allflag = arg[0];
++      
++    } else {
++      fprintf(stderr,"ERROR: Unrecognized command: %s\n",command.c_str());
++      exit(1);
++    }
++  }
++}
++  
++// perform substitutions within text of paragraph
++
++void substitute(string &s)
++{
++  int n,m,p;
++  char c;
++  string text,link,href;
++  string punctuation = ".,?!;:()";
++
++  // substitute for bold & italic markers
++  // if preceeded by \ char, then leave markers in text
++
++  n = s.find_first_of("[]{}");
++  while (n != string::npos) {
++    c = s[n];
++    if (n > 0 && s[n-1] == '\\') s.erase(n-1,1);
++    else {
++      s.erase(n,1);
++      if (c == '[') s.insert(n,"<B>");
++      else if (c == ']') s.insert(n,"</B>");
++      else if (c == '{') s.insert(n,"<I>");
++      else if (c == '}') s.insert(n,"</I>");
++    }
++    n = s.find_first_of("[]{}",n);
++  }
++
++  // substitute for links
++
++  n = s.find("\"_");
++  while (n != string::npos) {
++    m = s.rfind("\"",n-1);
++    if (m == string::npos) {
++      fprintf(stderr,"ERROR: Could not find matching \" for \"_ in %s\n",
++	      s.c_str());
++      exit(1);
++    }
++
++    p = s.find_first_of(" \t\n",n) - 1;
++    if (p == string::npos) {
++      fprintf(stderr,"ERROR: Could not find end-of-link in %s\n",s.c_str());
++      exit(1);
++    }
++    while (s.find_first_of(".,?!;:()",p) == p) p--;
++
++    text = s.substr(m+1,n-m-1);
++    link = s.substr(n+2,p-n-1);
++    for (int i = 0; i < nlink; i++)
++      if (alias1[i] == link) {
++	link = alias2[i];
++	break;
++      }
++
++    s.erase(m,p-m+1);
++    href = "<A HREF = \"" + link + "\">" + text + "</A>";
++    s.insert(m,href);
++    n = s.find("\"_");
++  }
++
++  // format the paragraph as a table
++  
++  if (tableflag) {
++    tableflag = 0;
++
++    string DT;
++
++    // set up <TR> tag
++    // alignment for data in rows
++
++    string tbalign;
++    if (dataalign != "0"){
++      string align;                                
++      if (dataalign=="c") align="\"center\"";
++      else if (dataalign=="r") align="\"right\"";
++      else if (dataalign=="l") align="\"left\"";
++      else {
++	fprintf(stderr,
++		"ERROR: Unrecognized table alignment argument %s for ea=X\n",
++		dataalign.c_str());
++	exit(1);
++      }
++      tbalign = " ALIGN=" + align;
++    } else tbalign="";
++    
++    // set up vertical  alignment for particular columns
++
++    string va;
++    if (rowvalign != "0"){
++      string valign;
++      if (rowvalign == "t") valign= "top";
++      else if (rowvalign == "m") valign= "middle";
++      else if (rowvalign == "ba") valign= "baseline";
++      else if (rowvalign == "bo") valign= "bottom";
++      else {
++	fprintf(stderr,
++		"ERROR: Unrecognized table alignment argument %s for eva=X\n",
++		rowvalign.c_str());
++	exit(1);
++      }
++      va = " VALIGN =\"" + valign + "\"";
++    } else va="";
++
++    //tr_tag is keyword for data in rows
++
++    string tr_tag= "<TR" + tbalign + va + ">";
++
++    //declare integers to help with counting and finding position
++    
++    int currentc=0; // current column
++    int nend = 0;
++    int n1=0;
++    int n = find_n(s,nend,n1);    
++    
++    // if there are no separators, go to the end of the stringx
++
++    if (n < 0) n = s.length();
++
++    // while n exists:
++
++    while (n != string::npos) {
++
++      // ignore = 0 when pass by \n because looking for delimiters only
++      // when ignore==0 do not put in a <tr>
++      int ignore=1;
++
++      // For each loop starts nend at n
++      nend=n;
++      
++      // current column is 0, (very first loop), insert first <TR>
++      if (currentc == 0){    
++	currentc++;
++	DT=td_tag(currentc);
++	s.insert(0,tr_tag);
++	s.insert(tr_tag.length(),DT);
++	nend=nend+tr_tag.length()+DT.length();
++	n = find_n(s,nend,n1);
++	if (n==n1) currentc++;  
++	else { 
++	  // currentc will remain one if rowquit==0
++	  if (rowquit>0){
++	    s.erase(n,1);
++	    n = find_n(s,nend,n1);
++	    currentc++;
++	  }
++	}
++      } else {
++      
++	// if n is separator
++	if (n == n1){
++	  s.erase(n,tabledelim.length());
++	  if(currentc==(rowquit+1)&& rowquit!=0){
++	    s.insert(nend,"</TD></TR>\n");
++	    nend=nend+11;
++	    // set current column back to one to start new line
++	    currentc=1;
++	  }else{
++	    DT= td_tag(currentc);
++    	    s.insert (nend,"</TD>");
++	    nend=nend+5;
++	    s.insert (nend,DT);
++	    nend=nend+DT.length();
++	    // add one so current column is updated
++	    currentc++;   
++	    n = find_n(s,nend,n1);
++	  }
++
++	}
++	//if n is newline character
++	else{
++	  s.erase(n,1);
++	  // if columns == 0 means ARE searching for newlines
++	  // else erase and ignore insert <tr> later and
++	  // search for next separator
++
++	  if (rowquit==0){
++	    s.insert(nend,"</TD></TR>\n");
++	    nend=nend+11;
++	    // set current column back to one to start new line
++	    currentc=1;
++	  }else{
++	    ignore=0;
++	    n = find_n(s,nend,n1);
++	  }
++	}
++
++	// if we are at the beginning of the row then insert <TR>
++
++	if (currentc==1&&ignore) {
++	  DT = td_tag(currentc); // find DT for currentc=1
++	  s.insert(nend,tr_tag);
++	  nend=nend+tr_tag.length();
++	  s.insert(nend,DT);
++	  n = find_n(s,nend,n1); // search for next separator
++	  currentc++;
++	}
++      } // end to else statement
++    } // end to while loop
++  } // end to if tableflag
++
++  // if listflag is set, put list marker at beginning of every line
++
++  if (listflag != "") {
++    string marker;
++    int toggle = 0;
++
++    n = s.find('\n');
++    while (n != string::npos) {
++      m = s.rfind('\n',n-1);
++      if (listflag == "dl" && toggle == 0) marker = "<DT>";
++      else if (listflag == "dl" && toggle == 1) marker = "<DD>";
++      else marker = "<LI>";
++      if (m == string::npos) s.insert(0,marker);
++      else s.insert(m+1,marker);
++      n = s.find('\n',m+1);
++      n = s.find('\n',n+1);
++      if (toggle) toggle = 0;
++      else toggle = 1;
++    }
++
++    listflag = "";
++  }
++
++  // if allflag is set, add markers to every line
++
++  if (allflag != "") {
++    string marker1,marker2;
++    if (allflag == "p") {
++      marker1 = "<P>";
++      marker2 = "</P>";
++    } else if (allflag == "c") {
++      marker1 = "<CENTER>";
++      marker2 = "</CENTER>";
++    } else if (allflag == "b") {
++      marker1 = "";
++      marker2 = "<BR>";
++    } else if (allflag == "l") {
++      marker1 = "<LI>";
++      marker2 = "";
++    } else marker1 = marker2 = "";
++
++    n = s.find('\n');
++    while (n != string::npos) {
++      m = s.rfind('\n',n-1);
++      if (m == string::npos) s.insert(0,marker1);
++      else s.insert(m+1,marker1);
++      n = s.find('\n',m+1);
++      s.insert(n,marker2);
++      n = s.find('\n',n);
++      n = s.find('\n',n+1);
++    }
++
++    allflag = "";
++  }
++}
++
++// open input file as-is or as file.txt
++// if npair = 0, don't open output file (is just initial pass thru input)
++// if npair = 1, open output file as stdout
++// if npair > 1, open output file with .html suffix
++//   either replace .txt in input file, or append .html
++
++void file_open(int npair, string &infile, FILE **in, FILE **out)
++{
++  *in = fopen(infile.c_str(),"r");
++  if (*in == NULL) {
++    string root = infile;
++    infile = infile + ".txt";
++    *in = fopen(infile.c_str(),"r");
++    if (*in == NULL) {
++      fprintf(stderr,"ERROR: Could not open %s or %s\n",
++	      root.c_str(),infile.c_str());
++      exit(1);
++    }
++  }
++
++  if (npair == 0) return;
++  else if (npair == 1) *out = stdout;
++  else {
++    string outfile;
++    int pos = infile.rfind(".txt");
++    if (pos == infile.length()-4) outfile = infile.substr(0,pos) + ".html";
++    else outfile = infile + ".html";
++    *out = fopen(outfile.c_str(),"w");
++    if (*out == NULL) {
++      fprintf(stderr,"ERROR: Could not open %s\n",outfile.c_str());
++      exit(1);
++    }
++  }
++}
++
++// for tables:
++// build <TD> string (DT) based on current column
++
++string td_tag(int currentc) {
++
++  // eacolumn gives the alignment printout of a specific column
++  string eacolumn;
++  // va gives vertical alignment to a specific column
++  string va;
++  // DT is the complete <td> tag, with width and align
++  string DT; 
++  // dw is the width for tables.  It is also the <dt> tag beginning
++  string dw;
++  
++  // set up alignment for particular columns
++
++  for (int counter=0; counter < ncalign; counter++){
++    if (ncalign != 0 && acolnum[counter] == currentc){
++      string align;
++      if (colalign[counter] == "l") align= "left";
++      else if (colalign[counter] == "r") align= "right";
++      else if (colalign[counter] == "c") align= "center";
++      else {
++	fprintf(stderr,
++		"ERROR: Unrecognized table alignment argument %s for caM=X\n",
++		colalign[counter].c_str());
++	exit(1);
++      }
++      eacolumn= " ALIGN =\"" + align +"\"";
++    }else eacolumn= "";
++  }
++
++  // set up vertical  alignment for particular columns
++
++  for (int counter=0; counter < ncvalign; counter++){
++    if (ncvalign != 0 && vacolnum[counter] == currentc){
++      string valign;
++      if (colvalign[counter] == "t") valign= "top";
++      else if (colvalign[counter] == "m") valign= "middle";
++      else if (colvalign[counter] == "ba") valign= "baseline";
++      else if (colvalign[counter] == "bo") valign= "bottom";
++      else {
++	fprintf(stderr,
++		"ERROR: Unrecognized table alignment argument %s for cvaM=X\n",
++		colvalign[counter].c_str());
++	exit(1);
++      }
++      va = " VALIGN =\"" + valign + "\"";
++    } else va = " ";
++  }
++
++  // put in special width if specified
++  // new code
++  // if dwidth has not been set, dw is blank
++  // if dwidth has been set, dw has that... unless
++
++  if (dwidth=="0") dw = " ";       
++  else dw =" WIDTH=\""+ dwidth + "\"";
++
++  for (int counter = 0; counter < ncnum; counter++){ 
++    // if it is the right column, dw = cwidth property
++    if (cnum[counter] == currentc) dw= " WIDTH=\"" + cwidth[counter] + "\"";
++  }
++  
++  // DT is set for all of this particular separator : reset next separator
++
++  DT = "<TD" + dw + eacolumn + va + ">"; 
++  
++  return DT;
++}
++
++// for tables:
++// find the next separator starting at nend(the end of the last .insert)
++// if there is either a delim or newline 
++// decide which is first
++// set n = to that position
++// nsep is position of the next separator. changes in here.
++
++int find_n(string &s, int nend, int &nsep)
++{
++  int n;
++  nsep = s.find(tabledelim,nend);
++  int n2 = s.find('\n',nend);
++  int m = s.length() - 1;
++  if (nsep >= 0 && n2 >= 0) {
++    if (nsep <= n2) n = nsep;
++    else n = n2;
++  } else {
++    if (nsep >= 0) n = nsep;
++    else{
++      if (n2 < m) n = n2;
++      else n = string::npos;
++    }
++  }
++      
++  return n;
++}




More information about the debian-science-commits mailing list