Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: ASCII to HTML

by turnstep (Parson)
on Apr 05, 2000 at 02:16 UTC ( [id://6890]=note: print w/replies, xml ) Need Help??


in reply to ASCII to HTML

Don't forget the classic

$ascii = "<PRE>$ascii</PRE>";

While not technically HTML, it will probably emulate your textarea (including tabs!) better than any regex will. :)

Replies are listed 'Best First'.
RE: Re: ASCII to HTML
by httptech (Chaplain) on Apr 05, 2000 at 03:28 UTC
    You just need to be careful on this one how you set up the textarea... if the textarea wraps the text automatically the browser doesn't necessarily insert linebreaks for you.
    So your users may type in an entire story with absolutely no linebreaks, and the <pre> tags will force it all on one line. In this case it's best to turn wrapping off in the textarea, so the output will be a faithful reproduction of what the user typed.

      Excellent point. I have a script that uses PRE tags and TEXTAREA input, and I have to manually wrap the long lines using some code that makes a good guess at where to insert a break if the line is too long. Why some people don't hit the 'Enter' key once in a while* is beyond me! Just goes to show you always have to check for all possible cases when dealing with user input.

      I've gotten people who put over 1000 characters on one line. Sheesh!

RE: Re: ASCII to HTML
by little_mistress (Monk) on Apr 05, 2000 at 02:53 UTC
    Good Point!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://6890]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-19 06:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found