Program: hrefsub
hrefsub makes substitutions in HTML files,
so that the changes only apply to the text in HREF fields of
<A
HREF="..."
> tags. For
instance, if you had the scooby.html file from the previous example,
and you’ve moved shergold.html to be cards.html, you need
simply say:
% hrefsub shergold.html cards.html scooby.html
<HTML><HEAD><TITLE>Hi!</TITLE></HEAD><BODY>
<H1>Welcome to Scooby World!</H1>
I have <A HREF="pictures.html" >pictures</A> of the crazy dog
himself. Here's one!<P>
<IMG SRC="scooby.jpg" ALT="Good doggy!"><P>
<BLINK>He's my hero!</BLINK> I would like to meet him some day,
and get my picture taken with him.<P>
P.S. I am deathly ill. <a href="cards.html" >Please send
cards</A>.
</BODY></HTML>
The HTML::Filter manual page has a BUGS section that says:
Comments in declarations are removed from the declarations and then inserted as separate comments after the declaration. If you turn on
strict_comment()
, then comments with embedded"-\|-"
are split into multiple comments.
This version of hrefsub will always lowercase the
<a>
and the attribute names within this tag
when substitution occurs. If $foo
is a multiword
string, then the text given to MyFilter->text
may be broken such that these words do not come together; i.e., the substitution does not work. There should probably be a new option to HTML::Parser to make it not return text until the whole segment has been seen. Also, some people may not be happy with having their 8-bit Latin-1 characters replaced by ...
Get Perl Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.