Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Formatting Input

by Anonymous Monk
on Jun 14, 2012 at 15:33 UTC ( #976234=note: print w/replies, xml ) Need Help??

in reply to Formatting Input

How can i prevent these blank lines between sentances or paragraphs from being removed?

The only way they get removed is if some code you wrote (or call) removes them -- the solution is to not do that

Without specific code we can't help you, see How do I post a question effectively?

Replies are listed 'Best First'.
Re^2: Formatting Input
by Fletch (Chancellor) on Jun 14, 2012 at 15:41 UTC

    Nah, the problem's on line 17. Bleedin' obvious.

    (Yeah, what he said. See also How (Not) To Ask A Question)

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re^2: Formatting Input
by akwe-xavante (Novice) on Jun 14, 2012 at 16:02 UTC

    My Perl / cgi script gets data from the webform in this way

    The script gets data from a webform then prints back to the browser, creates a PDF Document and sends an email with the PDF document as an attachment

    The script is long so i've only printed what i think you'l need here - i hope

    #!/usr/bin/perl use strict; use CGI ':standard'; use PDF::API2; use MIME::Lite; use utf8; $Name = param('name'); $Email = param('email'); $Subject = param('subject'); $Contents = param('contents');

    If the users data entered into the variable $Contents contains spaces between lines or paragraphs, these blank lines are removed somewhere during the process of printing it back to the browsers screen and into a PDF Document and the email

    Simplistically its printed back to the browser:

    print "Content-Type:text/html\n\n"; <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.or +g/TR/xhtml11/DTD/xhtml11.dtd\"> <html xmlns=\"\"> <head></head> <body> <p>Thank you $Name for your message entitled $Subject</p> <br> <p>Your Message was:</p> <br /> <p>$Contents</p> <br /> <p>I will contact you as soon as possible if a response is required.</ +p> <br /> <h2>$MyName</h2> <br /> <br /> <br /> </body </html>

    And Printed into the PDF Document:

    $txt->font($fnt, 8); $txt->translate(25,740); $txt->fillcolor('black'); $txt->text("$Contents");

    And added to an email:

    my $Message = " <p>Thank you $Name for your email.</p> <p>Subject: $Subject</p> <p>Your Message was:</p> <p>$Contents</p> "; my $msg = MIME::Lite->new ( From => $From, To => $To, Subject => "Subject: re: $Subject", Type =>'multipart/mixed' ) or die "Error creating multipart container: $!\n"; ###### Add the text message part # $msg->attach ( Type => 'HTML', Data => "$Message", ) or die "Error adding the text message part: $!\n"; ##### Send the Message $msg->send;
      The problem is that you don't know how HTML works. Consecutive whitespace, such as your line breaks, is collapsed into a single space for display purposes.

      That means before you print your variable contents in HTML, you need to prepare it appropriately. For example, you could wrap whole paragraphs of text into a <p>…</p> element.

        As far as i can see it is when written back to the browser and into the email. It isn't when printed to the PDF Document though

      Nice snippets... but they show nothing that removes common whitespace chars (\s\t\r\n).

      So, in a case of the blind (perhaps mis-) leading the blind, you might want to look at your cgi again, for something like one of these WAGs:

      •   chomp...
      •   s/\./\s$/\./; or s/\n/ /;
      • a regex ending in /s or /m

      This may not help, but it might rule out a few more possibilities.

      Update: Should have said earlier that the initial reply encapsulates the approach to a solution. + +. But also, I read, only after posting the initial version of this node, daxim's node re collapsing of white space and OP's reply, which, though ambiguous, may cast the issue in a different light.

        Thank you for your reply, not added anything to remove whitespace, wouldn't know how to

        If i have then i have done so as a typo somewhere by accident

        Someone is suggesting the problem is on line 17 but i can't find a line 17 that makes any sense no matter how i count down the number of lines, so i don't know which line of code the person is referring to!

      Thank you for your answer! doesn't really help though

      Line 17 is a blank line!

      Sometimes you just do not know what the question is to get the answer your looking for, i've obviously asked the wrong question or assumed my problem is a formatting issue, i don't know

      I'm still no wiser, smart arse!

      But thank you though, i'm assuming you think that i know what i'm doing - I don't!

        Hoping for a much more helpful answer

        Perhaps i need a better idea about what my problem is so that i can look and find an answer

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://976234]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2017-08-19 17:40 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (312 votes). Check out past polls.