By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,245 Members | 1,309 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,245 IT Pros & Developers. It's quick & easy.

Html tag removing but keeping <a href tag

P: 7
By using Formatter.pm in perl we can remove all html tags. But I want to keep tag <a href and remove all other tags. Can any body help me to change Formatter.pm file to do this task.

Expand|Select|Wrap|Line Numbers
  1. sub a_start
  2. {
  3.     #shift->{anchor}++;
  4.     #1;
  5. }
  6.  
  7. sub a_end
  8. {
  9.     #shift->{anchor}--;
  10. }
Feb 6 '08 #1
Share this Question
Share on Google+
3 Replies


numberwhun
Expert Mod 2.5K+
P: 3,503
By using Formatter.pm in perl we can remove all html tags. But I want to keep tag <a href and remove all other tags. Can any body help me to change Formatter.pm file to do this task.

Expand|Select|Wrap|Line Numbers
  1. sub a_start
  2. {
  3.     #shift->{anchor}++;
  4.     #1;
  5. }
  6.  
  7. sub a_end
  8. {
  9.     #shift->{anchor}--;
  10. }
Just out of curiosity, is this a module that you or someone else you know, wrote? The only "Formatter" module I see is for report generation via a DBI query. There is nothing about HTML in it. If it is a specific module from CPAN, which one is it?

If it is your own, home grown module, then we don't have any clue what the code looks like or does.

Regards,

Jeff
Feb 6 '08 #2

P: 7
Just out of curiosity, is this a module that you or someone else you know, wrote? The only "Formatter" module I see is for report generation via a DBI query. There is nothing about HTML in it. If it is a specific module from CPAN, which one is it?

If it is your own, home grown module, then we don't have any clue what the code looks like or does.

Regards,

Jeff
I have writtern all detail about this module i n your private messages box. It is actually CPAN module and also used for removing or some partially removing html tags from html file. Waiting for your response.
Regards

ALI
Feb 8 '08 #3

P: 7
Title : yes it is CPAN Module Version: 2.04
--------------------------------------------------------------------------------
http://search.cpan.org/~sburke/HTML-...L/Formatter.pm

Aforementioned is the link of the CPAN formatter.pm file. When we use Formatter.pm and FormatText.pm files it removes all the Html tags present in Html file. What I want is to remove all the tags but keeping the tags which starts with <a href .

So following is a part of that formatter.pm file code we have to change to keep <a href tags by leaving all the code in Formatter.pm file as it is.
Expand|Select|Wrap|Line Numbers
  1. sub a_start
  2. {
  3.     shift->{anchor}++;
  4.     1;
  5. }
  6.  
  7. sub a_end
  8. {
  9.     shift->{anchor}--;
  10. }
  11.  
I have tried to change it but I am not good in writing code in perl so I cant do so.

Because you are expert and I am sure you can do it in very short time. This is why I need your help.

If you still have any question related to it please email me XXXXXXXXXX
I am waiting for you warm response.
Feb 8 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.