in reply to Re^2: text formatting
in thread text formatting

I did not understand that either. If you want my help and you can't find a means of expressing yourself in English or French, just provide I should be able to figure out the rest

Replies are listed 'Best First'.
Re^4: text formatting
by karun.jiju (Initiate) on Feb 17, 2010 at 08:50 UTC

    Hi,

    I was in the process of implementing a custom Email interface using Perl. For this I used, POP::MailClient (for downloading mails from Qmail server), MIME::Parser(for reading the body content).
    Initially we had issues when displaying the mail content in the web interface, where special symbols like =A0, =, some HTML tags would be shown in the mail content. This was fixed after introducing MIME::Base64 and MIME::QuotedPrint.
    Now, we are trying to figure a way to format the mail message that needs to be displayed in the web interface. As you may be aware, we can use either text/plain or text/html part of actual mail file for displaying the mail message. Here we can use only text/html as it supports formatting like "Bold" "Italics" Colors etc. We were able to strip that part but, at some times, the message doesn't get wrapped after a fixed number of characters, and hence the readers will have to scroll from left to right to read the message. So we tried to word wrap the contents using Text::Format module. But here, it gets word wrapped in random places. We gave the option to word wrap after 70 characters but it is not working as expected. Maybe we interpreted the working of the module in a wrong way. Please go through the script which we are using to display the mail message and also a typical mail file that we are trying to display the message in the web interface.We are interested in displaying the contents that comes under Content Type: text/html in the mail file.

    If I had an option to include the screenshot, it would've been better to show the current formatting. But I don't know how I can show the current text formatting without it. But I will give a try. Please go through.


    ##################CURRENT MAIL INTERFACE OUTPUT########################
    Hi Lara,
    The Email Issue (matter
    getting shattering/ numbers coming in between etc..) was addressed to
    Joseph and he is looking into this with highest priority. This
    will be fixed ASAP.
    Thanks,






    Scott Valentine
    QC - Manager (Sales)
    Xxxxxxxx Software
    Solutions, Inc.
    XXXXXXXXXXX Medical Transcription Services
    XXXX
    Martins Rd.
    Xxxxxxxx, AZ XXXXX
    Phone:
    XXX-XXX-XXXX
    www.xxxxxxxxxxx.com

    ###################################EXPECTED MAIL INTERFACE OUTPUT########################################

    Hi Lara,
    The Email Issue (matter getting shattering/ numbers coming in between
    etc..) was addressed to Joseph and he is looking into this with highest
    priority. This will be fixed ASAP.
    Thanks,

    Scott Valentine
    DS - Manager (Mktng)
    Xxxxxxxx Software Solutions, Inc.
    XXXXXXXXXXX Medical Transcription Services
    XXXX Martins Rd.
    Xxxxxxxx, AZ XXXXX
    Phone: XXX-XXX-XXXX
    www.xxxxxxxxxxx.com
    ##################################QMAIL FILE - RAW###############################

    Subject: Email Issue
    Date: Mon, 8 Feb 2010 00:45:32 -0500
    X-Mailer: Perl script "cms.pl" using Mail::Sender 0.8.16 by Jenda Krynicky, Czechlands
    running on xxx.yyyyyyyyyyy.com (127.0.0.1) under account "apache"
    Message-ID: <20100208_054532_075707.ds_mgr1@xxxxx.yyyyyyyyyyy.com>
    MIME-Version: 1.0
    Content-type: text/html

    Hi Lara,
        The Email Issue (matter getting shattering/ numbers coming in between etc..) was addressed to Joseph and he is looking into this with highest priority. This will be fixed ASAP.

    Thanks,







    Scott Valentine
    DS - Manager (Mktng)
    Xxxxxxxx Software Solutions, Inc.
    XXXXXXXXXXX Medical Transcription Services
    XXXX Martins Rd.
    Xxxxxxxx, AZ XXXXX
    Phone: XXX-XXX-XXXX
    www.xxxxxxxxxxx.com
    ###################################################################################

    I would apprciate if you can suggest some ideas or any clues. Thank you.

    #!/usr/bin/perl use CGI; use CGI::Carp qw(fatalsToBrowser); use Text::Format; my $q = new CGI; print $q->header(); my $body = "<pre></pre>Hi Lara,<br>&nbsp;&nbsp;&nbsp; The Email Issue +(matter getting shattering/ numbers coming in between etc..) was addr +essed to Joseph and he is looking into this with highest priority. Th +is will be fixed ASAP.<br><br>Thanks,<br> <br/><br/><br/><br/><b +r/><br/> <br/> Scott Valentine<br>DS - Manager (Mktng)<br>Xxxxxxxx Software Solutions +, Inc.<br>XXXXXXXXXXX Medical Transcription Services<br>XXXX Martins +Rd.<br>Xxxxxxxx, AZ XXXXX<br>Phone: XXX-XXX-XXXX<br>www.xxxxxxxxxxx.c +om<br/>"; $body = Text::Format->new({columns => 70,firstIndent => 0})->form +at($body); print $body;
      That's not the output I get at all. I get the following (minus the rulers):
      1 2 3 4 5 6 7 1234567890123456789012345678901234567890123456789012345678901234567890 <pre></pre>Hi Lara,<br>&nbsp;&nbsp;&nbsp; The Email Issue (matter getting shattering/ numbers coming in between etc..) was addressed to Joseph and he is looking into this with highest priority. This will be fixed ASAP.<br><br>Thanks,<br> <br/><br/><br/><br/><br/><br/> <br/> Scott Valentine<br>DS - Manager (Mktng)<br>Xxxxxxxx Software Solutions, Inc.<br>XXXXXXXXXXX Medical Transcription Services<br>XXXX Martins Rd.<br>Xxxxxxxx, AZ XXXXX<br>Phone: XXX-XXX-XXXX<br>www.xxxxxxxxxxx.com<br/> 1234567890123456789012345678901234567890123456789012345678901234567890 1 2 3 4 5 6 7

      That looks well wrapped to me, and that's exactly what I'd expect. Now, it looks like you're treating the wrapped text as HTML. That makes no sense.

      I'm not sure what you're trying to do exactly. It sounds like you want to limit the width of some paragraphs in an HTML document (although you don't even use paragraph tags to mark your paragraphs). If so, limit the width of the paragraphs. Consult your CSS reference with respect to the width property.