Formatting data to output in web browser from web form

Discussion in 'Python' started by Harlin Seritt, Jul 9, 2005.

  1. Hi,

    I am using CherryPy to make a very small Blog web app.

    Of course I use a textarea input on a page to get some information.
    Most of the time when text is entered into it, there will be carriage
    returns.

    When I take the text and then try to re-write it out to output (in html
    on a web page), I notice the Python strings don't translate these
    special characters (carriage returns) to a "<p>" so that these
    paragraphs show up properly in html for output. I tried doing something
    like StringData.replace('\n', '<p>'). Of course this doesnt work
    because it appears that '\n' is not being used.

    Is there anything I can do to make sure paragraphs show up properly?

    Thanks,

    Harlin Seritt
     
    Harlin Seritt, Jul 9, 2005
    #1
    1. Advertising

  2. Harlin Seritt

    John Machin Guest

    Harlin Seritt wrote:
    > Hi,
    >
    > I am using CherryPy to make a very small Blog web app.
    >
    > Of course I use a textarea input on a page to get some information.
    > Most of the time when text is entered into it, there will be carriage
    > returns.
    >
    > When I take the text and then try to re-write it out to output (in html
    > on a web page), I notice the Python strings don't translate these
    > special characters (carriage returns) to a "<p>" so that these
    > paragraphs show up properly in html for output. I tried doing something
    > like StringData.replace('\n', '<p>'). Of course this doesnt work
    > because it appears that '\n' is not being used.
    >
    > Is there anything I can do to make sure paragraphs show up properly?
    >


    The ASCII carriage return (CR) is represented in Python as "\x0d" or
    "\r". The line feed (LF) is "\x0a" or "\n". Does this info help you with
    your problem? If, not perhaps you might like to

    print repr(StringData)

    so that we can see what you are calling "carriage returns".

    HTH,
    John
     
    John Machin, Jul 9, 2005
    #2
    1. Advertising

  3. This is perfect. Thanks!
     
    Harlin Seritt, Jul 12, 2005
    #3
    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. Carl Lafferty
    Replies:
    3
    Views:
    330
    Carl Lafferty
    Jul 23, 2006
  2. rashmi

    formatting output in the form of table

    rashmi, Jun 21, 2005, in forum: C Programming
    Replies:
    1
    Views:
    268
    Rajan
    Jun 21, 2005
  3. Kevin DeValck
    Replies:
    1
    Views:
    737
    7stud --
    May 17, 2011
  4. John
    Replies:
    6
    Views:
    139
    John W. Kennedy
    Mar 11, 2006
  5. murrayatuptowngallery
    Replies:
    0
    Views:
    91
    murrayatuptowngallery
    Feb 11, 2008
Loading...

Share This Page