#!/usr/local/bin/perl

# 
# dehtml: 
# 
#     [199?/??/??] Naoki OSHIRO.
#     [1997/05/14] Naoki OSHIRO.
#     [1998/08/19] OSHIRO Naoki. Image tag option added.
# 
#     $Log:$
#

require "getopts.pl";
&Getopts("li");

$href="";
while (<>) {
    $href=$1 if /href="?([^\s"]+)"?[\s>]/i;
    $image=$2 if /img ([^>]+\s+)*src="?([^\s"]+)"?[\s>]/i;
    $alt=$2   if /img ([^>]+\s+)*alt="?([^"]+)"?[\s>]/i;
    $image=$2 if /body ([^>]+s+)*background="?([^\s"]+)"?[\s>]/i;
    s/<[^>]*>//g;
    if ($opt_l) {
      if ($href) {print "$href\n"; $href="";}
    } elsif ($opt_i) {
      if ($image) {print "$image\n"; $image="";}
      #if ($alt)   {print "  $alt\n"; $alt="";}
    } else {
      if ($href) {print "$href\n"; $href="";}
      if ($image) {print "$image\n"; $image="";}
      if ($alt)   {print "  $alt\n"; $alt="";}
      print;
    }
}

# magjor-mode: perl
