/    Sign up×
Community /Pin to ProfileBookmark

Is there a tag that displays all of its contents as pure text (or at least break a line without <br />, but with the enter key)?

Thanks!

to post a comment
HTML

7 Comments(s)

Copy linkTweet thisAlerts:
@savvykmsJun 22.2011 — The [B]pre[/B] tag works fine. You can also use CSS in most browsers nowadays to modify another element to do the same (see [URL=http://www.w3schools.com/CSS/pr_text_white-space.asp]here[/URL]).
Copy linkTweet thisAlerts:
@AJAXnubauthorJun 22.2011 — Thanks!

I'll probably just use character replacing in the server side instead, to make it more controllable, but I might get to use that two.
Copy linkTweet thisAlerts:
@savvykmsJun 22.2011 — You can always send the header content-type: text/plain if you want a whole page to be plaintext. Also, note that fixed-width fonts (monospace) are great if you intend whitespace behavior to include newline characters as line breaks.
Copy linkTweet thisAlerts:
@AJAXnubauthorJun 22.2011 — Why are mono-space fonts better for that?

I'm checking this for a comment feature, so what I wanted to do was to take in the information in a textarea, and then, on the server side, replace all of the rn characters with <br />, all < characters with &lt and all > characters with &gt. Does that cause any problems?
Copy linkTweet thisAlerts:
@savvykmsJun 22.2011 — I just like monospace fonts; chances are if you care about newline characters being involved you care about lining up characters in a grid. I just thought it worth stating.

As for a comment feature, it is a simple matter in PHP to validate it and throw it onto a page. PHP has built-in functions: [URL=http://w3schools.com/php/func_string_htmlspecialchars.asp]htmlspecialchars()[/URL], [URL=http://w3schools.com/php/func_string_nl2br.asp]nl2br()[/URL]
Copy linkTweet thisAlerts:
@AJAXnubauthorJun 22.2011 — Oh.. thanks!

I don't know PHP-I use ASP.NET (C#), but its not a complicated function to make.

I will probably eventually learn it, but not before I know ASP.NET.
Copy linkTweet thisAlerts:
@savvykmsJun 22.2011 — I know C#, VC++, enough VB to get by, and a ton of other languages too. I tried learning ASP, but it seemed like an ineffiecient way of doing things to me. I do like the concent of a master file and some good object-orientation, but other than that I don't like ASP much.

C#:
[code=php]
String br = "<br />";
//turn the following into the proper System.String function notation
replace("rn",br);
replace("nr",br);
replace("r",br);
replace("n",br);
[/code]


By replacing sequences (pairs) first, you eliminate the individual components of said pairs, then you can track down and replace individual components independant of pairs. E.g. you get rid of rn before you get rid of r and get rid of n, so that you don't get <br><br>
×

Success!

Help @AJAXnub spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...