Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8223539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:44:19+00:00 2026-06-07T14:44:19+00:00

I have a web.py app that takes input from a textarea and inputs it

  • 0

I have a web.py app that takes input from a textarea and inputs it to a database. I can get the information from the database and post it to the page but the NEWLINES are gone. How do I preserver newlines when posting back into HTML? The data does have \r\n in it but that isn’t rendered as NEWLINES in HTML. Any thoughts? Here is a small example:

(2, u'Title', u'content here...hey\r\nthis\r\nhas\r\nbreaks in it....?', 
    datetime.datetime(2012, 7, 5, 21, 5, 14, 354516))

That is my return from the data base. I need the \r\n to represent a <br /> and if there is two a <p> would be awesome. Any direction would be very much appreciated.

Also is there a library for this? I have heard of markdown and mark up but I can find no examples of how to post html data from python strings?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T14:44:21+00:00Added an answer on June 7, 2026 at 2:44 pm

    Two main ways to do this. The easiest one is to wrap the output in <pre></pre> which will format it as entered.

    Or, you can replace newlies with <br /> (and not with <p>) as the characters represent a line break and not a paragraph.

    For the second option, this is one approach:

    >>> s
    'hello\nthere\r\nthis\n\ris a test'
    >>> r = '<br />'
    >>> s.replace('\r\n',r).replace('\n\r',r).replace('\r',r).replace('\n',r)
    'hello<br />there<br />this<br />is a test'
    >>> 
    

    Or the third option – which is to use one of the many text entry libraries/formats and render the content through them (as mentioned by others – like markdown).

    However, that would be overkill if all you want to do is a simple replace.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php web service that takes the request from android/iphone app and
I have a web app that takes in variables from the client and generates
Say I want to have a simple web app that takes some user input,
Background I have a web app that will create an image from user input.
We have a command line exe that takes input from a text file and
I have a very simple ColdFusion web app that takes one URL parameter and
We have an web app that is talking to Netsuite via Netsuite's web services.
I have a web app that I've recently applied a jQuery ThemeRoller theme to.
I have a web app that lets a client define a daily rate for
We have a web app that we update and release almost daily. We use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.