20.21. Program: hrefsubhrefsub makes substitutions in HTML files, so changes apply only to text in <A HREF="..." > tags. For instance, if you had the scooby.html file from the previous recipe, and you've moved shergold.html to be cards.html, you need but 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:
This version of hrefsub (shown in Example 20-13) always lowercases 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 ugly entities, so htmlsub does that, too. Example 20-13. hrefsub
Copyright © 2003 O'Reilly & Associates. All rights reserved. |
|