lynx-dev
[Top][All Lists]
Advanced

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

Re: LYNX-DEV Lynx and JavaScript -Reply


From: Filip M Gieszczykiewicz
Subject: Re: LYNX-DEV Lynx and JavaScript -Reply
Date: Fri, 15 Nov 1996 17:19:20 -0600 (CST)

You (Doug Lawson) wrote:
> On Thu, 14 Nov 1996, Filip M Gieszczykiewicz wrote:
> > Greetings. And it's soo easy to ask users to include a valid date in a
> > custom comment line. I use:
> > <!-- TLJSETDATE 01/01/01 -->
> > and
> > <!-- TLJSETVERSION 1.01 -->
> 
> OK, I'll bite - how are you processing this html (or proto-html) ? 

Greetings. Easy - with awk (or perl, but that doesn't work yet). I
use TLJxxxxxxxx because it's not really likely that I will find
a word/pattern like that in the data (it's keyword of sorts). So,
set up an awk script that:

# Scan for pattern, leave everything else alone
/TLJSETDATE/ {
        blah
}
{print $0}

where blah is code that extracts the date (or the filename of the
file where where we're supposed to fix the date) and then print
whatever we want into the data stream. I just scan for a bunch of
these in a file - much like a global "macro" that I can apply to
any file. For example, the code for that is (alpha given here,
newer versions are on my home machine, sorry)

AutoDate.awk:
-----------------chop-with-axe----------------chop-with-axe---------------------
# Scan for pattern, don't touch anything else..
/TLJAUTODATE/ {
        # It can be of two forms:
        # $0 = "<!-- TlJHdR TLJAUTODATE [filename] -->"
        #      I use "TlJHdR" to make easy to snip out later - keyword
        # or
        # $0 = "<!-- TLJAUTODATE [filename] -->"
        date=""
        if (match($0,"TlJHdR")) # case #1
                file=$4
        else
                file=$3
        # suck on that file and get the actual date
        # TODO: recursive rewrite to handle multiple references
        while (getline line < file > 0) {
                if (index(line,"TLJSETDATE")) {
                        split (line,temp) # break up line
                        date = temp[4]    # extract date
                        break
                }
        }
        # don't need it anymore...
        close (file)
        if (date == "") # didn't find a date set!
        {
                "date" | getline sys_date # so we put in CURRENT date
                split (sys_date,da)
                printf("(%s_%s_%s!) <!-- TlJHdR AutoDate 1.01 -->\n",
                       da[2],da[3],da[6]);
                # we use that "!" to know it wasn't found...
                # ie. fall on our face
                #     with grace
        }
        else
                printf("(%s) <!-- TlJHdR AutoDate 1.01 -->\n",date);
        getline # grab next line so below don't print current line (twice)
}
{print $0}
-----------------chop-with-axe----------------chop-with-axe---------------------

You can either have a bunch of these in one file or have individual files
for each "macro" (I do - makes it easy to up keep)... Now, wasn't this
simple?

perl rewrite is in progress.. alas, I'm wondering why fix what ain't broke..
so it's going slowly... ;-)

Take care.
;
; To UNSUBSCRIBE:  Send a mail message to address@hidden
;                  with "unsubscribe lynx-dev" (without the
;                  quotation marks) on a line by itself.
;


reply via email to

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