my html & text version method

---------

Jason W. Hinson (hinson@physics.purdue.edu)
Thu, 20 Jun 1996 13:12:00 -0500 (EST)


Well, for anyone interested, I thought I'd explain how I do my 4 part
"Relativity and FTL Travel" FAQ so as to get a good HTML version and a
good text version. I warn you though, I am quite picky about having
very good looking versions of each.

First, I keep one copy of the FAQ which I call a "source" version. It
is not pure HTML, nor is it pure text. It contains various tags which
a perl script of mine recognizes to produce both an HTML version and a
semi-text version (I'll explain that in a bit). I can put in a "for
text" tag (<!--#fortext"text"-->) or a "for html" tag to put things
only in the text version or html version (e.g. In the text version, I
can put a note about the html version and its home; I can put an (R)
in the text and a &#169; in the html version; I can put the text
"_both_ways_" in the text version and "<strong>both ways</strong>" in
the html, etc.). Further, I use tags to, for example, note links to
earlier shown equations and diagrams by using a name I give to the
particular equation/diagram. As my perl script goes through the
source file the first time, it notes the various equations/diagrams
along with their names (given in my own tag), it numbers them in the
html and semi-text files, and it keeps up with the numbers so that the
next time through the source file it can replace "equation name" tags
with the appropriate equation number.

For example, the first time through, my perl script will see a line
like this:

<!--#etag"relenergy1"-->

This tells my script to go to my equation directory and look for a
file called relenergy1.txt which contains the text for the equation
called "relenergy1". If this is the third equation found in section
one, it puts in the text " (Eq 1:3)" followed by the text for the
equation gotten from relenergy1.txt. In the HTML version, it also
puts in an anchor for that equation. Then, the next time through the
source file, the script might find a tag like
<!--#eelink"relenergy1"--> in which case it would put in "Equation
1:3" for the text version and it will put in the same text in the html
version but it will link it to the appropriate anchor. I could also
use the tag <!--#elinkrelenergy1"defined"--> which would put in the
text "defined" but link it to the correct equation in the html
version.

It's even more involved that this: my perl script keeps up with
section names and part names and numbers, etc. But anyway...

Now, HERE's the odd part. I don't like the way lynx output looks at
all--I much prefer Netscape "save as text" (if I could find a way to
automate that or find something like lynx which makes a text output as
nice as netscape, I'd be VERY happy!). Anyway, the text produced by
netscape still doesn't quite do it for me either. For example, I just
like paragraphs which are not separated by spaces but have an
indention at the beginning. So, my "semi-text" version will replace a
stand alone line which says "</p><p>" (which is how I separate every
paragraph) with "<br>-on-". Then when I do a "save as text" on this
semi-text (but really still html) version, netscape puts in a break
and the end of every paragraph and begins the next paragraph with
"-on-". Then it properly wraps the paragraph with this text at the
beginning. Finally, after netscape produced its text version, a
separate perl script replaces "-on-" with four spaces. This produces
a properly wrapped paragraph which is right underneath the previous
paragraph and indented.

So, my procedure is (1) run a perl script which produces the html
version and an semi-text (but still html-ed) version, (2) run the
semi-text version of all 4 parts + an introduction through netscape
saving each as text (if there were only some way to automate this!!!),
and finally, run a final perl script on the netscape output to make
the actual text version which looks just like I want it.

Well, I know that was all long winded, but that's how I do it if
anyone is interested. If anyone knows of an automatic html->text
process which produces text output as well as netscape does, PLEASE
let me know.

-Jay



[ Usenet Hypertext FAQ Archive | Search Mail Archive | Authors | Usenet ]
[ 1993 | 1994 | 1995 | 1996 | 1997 ]

---------

faq-admin@landfield.com

© Copyright The Landfield Group, 1997
All rights reserved