groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] Tabular html output.


From: Larry Kollar
Subject: Re: [Groff] Tabular html output.
Date: Sun, 23 May 2004 20:29:24 -0400

Heinz-Jürgen Oertel wrote:

I got simple tables working.
We often are using '#' as a table separator. Here the script the fist time
did something wrong with interpreting the line
tab(#);
in your code, the line:
 sub( /tab *\(([^)]*)\)/, "\1", ts ); # get parameter for tab
should extract the separator. It didn't with my example.
That leads to the question which awk are you using ?

It's the awk that comes with MacOS X, which I think is a no-frills
BSD awk....

% awk -V
awk version 981019
%

Personally, I'd like to avoid extensions as much as possible to keep
things portable ("my" awk doesn't have gensub, for example), at least
until someone comes up with something better -- like making tbl do
this stuff for us. :-)

To that effect, here's a different approach to fixing tab(#) parsing:

--- htbl.awk.orig       Sun May 23 20:20:37 2004
+++ htbl.awk    Sun May 23 20:19:26 2004
@@ -23,9 +23,10 @@
 # BUG here: you pretty much have to have options or at least a ";"!
 state == "options" && /box/ { border = 1 }
 state == "options" && /tab/ {
-       ts = $0
-       sub( /tab *\(([^)]*)\)/, "\1", ts ); # get parameter for tab
-       tabFS = ts;
+       t1 = index( $0, "tab(" );
+       ts = substr( $0, t1 );
+       t2 = index( ts, ")" );
+       tabFS = substr( ts, 5, (t2-5) );
 }
 state == "options" && /;/ {
        state = "format";
@@ -47,7 +48,6 @@

 # process the body
 state == "body" {
-       if( bodystart ) { bodystart = 0; next } # skip last format line

        if( $0 ~ /^\.TE/ ) {
                print ".HTML </table>";


Question to the list. Is this discussion, improving Larry's script, OT?

I don't think so -- it's designed to work with groff, after all.

--
Larry Kollar     k  o  l  l  a  r  @  a  l  l  t  e  l  .  n  e  t
Unix Text Processing: "UTP Revival"
http://home.alltel.net/kollar/utp/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]