13.0204 perl script for browser problem

Humanist Discussion Group (humanist@kcl.ac.uk)
Wed, 22 Sep 1999 07:33:01 +0100 (BST)

Humanist Discussion Group, Vol. 13, No. 204.
Centre for Computing in the Humanities, King's College London
<http://www.princeton.edu/~mccarty/humanist/>
<http://www.kcl.ac.uk/humanities/cch/humanist/>

Date: Wed, 22 Sep 1999 06:28:20 +0100
From: Chuck Bearden <cbearden@rice.edu>
Subject: Re: 13.0199 ideas on browser problem

On Mon, 20 Sep 1999, Humanist Discussion Group wrote:

> --[4]------------------------------------------------------------------
> Date: Mon, 20 Sep 1999 21:12:37 +0100
> From: Garvin Tate <gltate@d-a-c.com>
> >
[etc.]
>
> I looked at the source code for one of the right-hand frames. If I
> understand the proposed problem, one possible remedy might be to move
> the <a name="...."> tags outside the <td> tags. Also, the way the code
> is marked up, anchors split across table columns -- not recommended.

I wrote a small Perl script to un-split the anchor tags and move them
all into the first table cell, around just the number:

<tr><td valign="TOP"><a name="1.018">18</a></td><td><pre>obstabatque aliis
aliud quia corpore in uno</pre></td></tr>

instead of

<tr><td valign="TOP"><a name="1.018">18</td><td><pre>obstabatque aliis
aliud qui a corpore in uno</a></pre></td></tr>

I am appending the script to this message. It saves the original
files by appending '.bak' to their names. Once this problem is fixed,
and a DOCTYPE is added, your text pages should validate as HTML 4.0
Transitional.

> In other words, replace
>
> <tr><td valign="TOP"><a name="10.021">21</td><td><pre>Tartara, descendi,
> nec uti villosa colubris</a>
>
> with something like
>
> <tr><a name="10.021"></a><td valign="TOP">21</td><td><pre>Tartara,
> descendi, nec uti villosa colubris

I modified the script to do this as well, but it didn't remedy the
problem with the Win/Netscape workstations I was able to test it on.
In fact, putting the anchor tags between the <tr> and the <td> cause
links like:

<a href="http://wlm.cc.kcl.ac.uk/onomasticon-sample/txt/met-01.htm#1.018">

to stop working altogether: the page/frame just stays at the top of
the page instead of jumping down to the anchor name.

Chuck
======================================================================
Chuck Bearden Electronic Resources Librarian Rice University
cbearden@rice.edu 713.527.8101x3634 713.737.5859 (fax)
======================================================================

---------------Begin Script---------------
#!/usr/bin/perl -wni.bak

chomp;
if (m|^(.*?<a name=".*?">\d+)(.*?)(</a>)(.*)$|) {
print $1, $3, $2, $4, "\n";
} else {
print $_, "\n";
}

-------------------------------------------------------------------------
Humanist Discussion Group
Information at <http://www.kcl.ac.uk/humanities/cch/humanist/>
<http://www.princeton.edu/~mccarty/humanist/>
=========================================================================