FormatText/TreeBuilder Removes Line Breaks

Discussion in 'Perl Misc' started by afrinspray, Sep 8, 2005.

  1. afrinspray

    afrinspray Guest

    I'm working on a program that removes html formatting from an IM
    conversation. Right now, I'm storing the conversation in a variable,
    where each line of the conversation is broken up by line feeds (a
    single \n). Then I do the following:

    my $formatter = HTML::FormatText->new;
    my $tree = HTML::TreeBuilder->new;
    $tree->parse($body);
    if ($tree) {
    $body = $formatter->format($tree);
    $tree->delete;
    }

    where $body is the entire IM conversation.


    This strips the line feeds but I needs to keep those in there. Does
    anyone have any other suggestions?

    Thanks,
    Mike
     
    afrinspray, Sep 8, 2005
    #1
    1. Advertising

  2. afrinspray

    afrinspray Guest

    I just found the FAQ in comp.lang.perl.misc and I'm considering the
    line:

    s/<(?:[^>'"]*|(['"]).*?\1)*>//gs

    Does anyone have any objections?

    Thanks,
    Mike
     
    afrinspray, Sep 8, 2005
    #2
    1. Advertising

  3. "afrinspray" <> wrote in news:1126212207.757886.146020
    @g14g2000cwa.googlegroups.com:

    > I just found the FAQ in comp.lang.perl.misc and I'm considering the
    > line:
    >
    > s/<(?:[^>'"]*|(['"]).*?\1)*>//gs
    >
    > Does anyone have any objections?


    Uhmmmm ... to what?

    Sinan


    --
    A. Sinan Unur <>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
     
    A. Sinan Unur, Sep 8, 2005
    #3
  4. afrinspray wrote:
    > I just found the FAQ in comp.lang.perl.misc and I'm considering the
    > line:
    >
    > s/<(?:[^>'"]*|(['"]).*?\1)*>//gs
    >
    > Does anyone have any objections?


    Yes, I strenuously object!


    John
    --
    use Perl;
    program
    fulfillment
     
    John W. Krahn, Sep 11, 2005
    #4
  5. afrinspray

    afrinspray Guest

    "are you english or retarded?"
    - Alex Trabek
     
    afrinspray, Sep 21, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Greg Aumann
    Replies:
    0
    Views:
    336
    Greg Aumann
    Jun 28, 2006
  2. Fredrik Lundh
    Replies:
    0
    Views:
    443
    Fredrik Lundh
    Jul 1, 2006
  3. John W. Kennedy

    Equivalent of Perl HTML::TreeBuilder?

    John W. Kennedy, Jul 29, 2004, in forum: Ruby
    Replies:
    2
    Views:
    138
  4. Bruce Horrocks
    Replies:
    1
    Views:
    112
    Bruce Horrocks
    Jun 12, 2005
  5. Marek Stepanek
    Replies:
    12
    Views:
    417
    Peter J. Holzer
    Sep 2, 2006
Loading...

Share This Page