473,695 Members | 3,090 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

white-space help

I want to paste a lengthly text document into a web page and have it
retain all of whitespace and line breaks.

I first tried the <pretag but that didn't work because it doesn't
wrap the text. I then moved to CSS and the white-space property, but I
can't seem to get it to work either. white-space: pre does the same as
<preand white-space: pre-wrap doesn't seem to be supported by any
browsers I've tested with. I tried word-wrap: break-word, but that is
only supported my IE and it messed up my white-space: pre anyhow.
*sigh*

Can anyone suggest to me what properties and values I should use to get
the browsers (IE and Firefox, mostly) to preserve whitespace and
newlines, as well as wrapping the text.

Thank you so much!

Brent

Aug 13 '06 #1
22 3063
Brent <bk*******@gmai l.comscripsit:
I want to paste a lengthly text document into a web page and have it
retain all of whitespace and line breaks.
What could possibly constitute the need for such an operation? If it's
preformatted plain text and should be kept that way, it can be turned into a
plain text www document.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Aug 13 '06 #2
Brent wrote:
I want to paste a lengthly text document into a web page and have it
retain all of whitespace and line breaks.

I first tried the <pretag but that didn't work because it doesn't
wrap the text.
You want it to preserve the linebreaks and not preserve the linebreaks.
I think this is where your difficulty lies.

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Aug 13 '06 #3
On 2006-08-13, Jim Moe wrote:
Brent wrote:
>I want to paste a lengthly text document into a web page and have it
retain all of whitespace and line breaks.

I first tried the <pretag but that didn't work because it doesn't
wrap the text.
You want it to preserve the linebreaks and not preserve the linebreaks.
I think this is where your difficulty lies.
There's nothing inconsistent in the OPP's request. He wants the
existing linebreaks to remain, and not join with the next line. HE
want long lines to wrap.

What he wants is very hard to read, and not recommended.

--
Chris F.A. Johnson <http://cfaj.freeshell. org>
=============== =============== =============== =============== =======
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
Aug 13 '06 #4
Jim Moe wrote:
Brent wrote:
I want to paste a lengthly text document into a web page and have it
retain all of whitespace and line breaks.

I first tried the <pretag but that didn't work because it doesn't
wrap the text.
You want it to preserve the linebreaks and not preserve the linebreaks.
I think this is where your difficulty lies.

--
jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
I do want to preserve linebreaks (just like the <pretag does), but I
also want the text to wrap at the right edge of the browser.

Basically put, I have a text document that was written with MS Notepad,
that contains indents, tabs, paragraphs, etc... When I use
white-space: pre the paragraphs run as single lines (they don't wrap at
the right edge of the browser). The only way I found to wrap the
paragraphs causes me to loose the white-space property (indents and
tabs disappear, and paragraphs mesh together as one very long
paragraph, sort of like how text in html behaves normally.)

Is there a way preserve whitespace and have the text wrap? Or is that
simply not possible to do?

Aug 13 '06 #5

Chris F.A. Johnson wrote:
On 2006-08-13, Jim Moe wrote:
Brent wrote:
I want to paste a lengthly text document into a web page and have it
retain all of whitespace and line breaks.

I first tried the <pretag but that didn't work because it doesn't
wrap the text.
You want it to preserve the linebreaks and not preserve the linebreaks.
I think this is where your difficulty lies.

There's nothing inconsistent in the OPP's request. He wants the
existing linebreaks to remain, and not join with the next line. HE
want long lines to wrap.

What he wants is very hard to read, and not recommended.
Why would it be hard to read? Will it not justify properly? The way I
look at it, if the existing linebreaks remain and the text wraps, it
should appear on the browser perfectly. Please let me know if I'm
missing something.

Aug 13 '06 #6
On 2006-08-13, Brent wrote:
>
Chris F.A. Johnson wrote:
>On 2006-08-13, Jim Moe wrote:
Brent wrote:
I want to paste a lengthly text document into a web page and have it
retain all of whitespace and line breaks.

I first tried the <pretag but that didn't work because it doesn't
wrap the text.

You want it to preserve the linebreaks and not preserve the linebreaks.
I think this is where your difficulty lies.

There's nothing inconsistent in the OPP's request. He wants the
existing
linebreaks to remain, and not join with the next line. HE wants
long
lines to wrap.

What he wants is very hard to read, and not recommended.

Why would it be hard to read? Will it not justify properly? The
way I look at it,
if the existing linebreaks remain and the text wraps, it should
appear on
the browser perfectly. Please let me know if I'm missing
something.
What you are asking for will give you long lines, followed by short
lines
that should really be connected to the next line, if the text is
going
to be readable. The short lines break the flow. You would be better
off using
style="overflow : auto;".

--
Chris F.A. Johnson <http://cfaj.freeshell. org>
=============== =============== =============== =============== =======
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
Aug 13 '06 #7

Chris F.A. Johnson wrote:
On 2006-08-13, Brent wrote:

Chris F.A. Johnson wrote:
On 2006-08-13, Jim Moe wrote:
Brent wrote:
I want to paste a lengthly text document into a web page and have it
retain all of whitespace and line breaks.

I first tried the <pretag but that didn't work because it doesn't
wrap the text.

You want it to preserve the linebreaks and not preserve the linebreaks.
I think this is where your difficulty lies.

There's nothing inconsistent in the OPP's request. He wants the
existing
linebreaks to remain, and not join with the next line. HE wants
long
lines to wrap.

What he wants is very hard to read, and not recommended.
Why would it be hard to read? Will it not justify properly? The
way I look at it,
if the existing linebreaks remain and the text wraps, it should
appear on
the browser perfectly. Please let me know if I'm missing
something.

What you are asking for will give you long lines, followed by short
lines
that should really be connected to the next line, if the text is
going
to be readable. The short lines break the flow. You would be better
off using
style="overflow : auto;".
I tried style="overflow : auto" and still can't get both whitespace
preserved and wrapping at once. If I put <pre style="overflow : auto">
I get single lined paragraphs that stretch for miles of the right of
the browser. If I use <div style="overflow : auto"I loose whitespace.

I still don't understand why you think I will get long lines, followed
by short lines. The text has no character returns, except for at the
end of each paragraph.

Is there really no way to force the text to wrap while preserving
whitespace? This is really bumming me out. :-(

Aug 13 '06 #8
Brent wrote:
I want to paste a lengthly text document into a web page and have it
retain all of whitespace and line breaks.

I first tried the <pretag but that didn't work because it doesn't
wrap the text. I then moved to CSS and the white-space property, but I
can't seem to get it to work either. white-space: pre does the same
as <preand white-space: pre-wrap doesn't seem to be supported by any
browsers I've tested with. I tried word-wrap: break-word, but that is
only supported my IE and it messed up my white-space: pre anyhow.
*sigh*

Can anyone suggest to me what properties and values I should use to
get the browsers (IE and Firefox, mostly) to preserve whitespace and
newlines, as well as wrapping the text.

Thank you so much!
I'd just reformat the original document, I'd say it would be easier,
provided you use the right tools and judicious use of search/replace. I use
Notepad++, great for stuff like this.

You could just add <pto the beginning of the document and </pto the end
of the document. Then do a search/replace and replace all of the cr/lf in
the document with </p><p>. You could do the same with tabs and spaces if
you want. Use a regular expression (can't give it to you off the top of my
head sorry) to find all the runs of spaces that are 2 or more long and
replace all but the first space with &nbsp;

Should give you what you want.
Aug 14 '06 #9

Nik Coughlin wrote:
>
I'd just reformat the original document, I'd say it would be easier,
provided you use the right tools and judicious use of search/replace. I use
Notepad++, great for stuff like this.

You could just add <pto the beginning of the document and </pto the end
of the document. Then do a search/replace and replace all of the cr/lf in
the document with </p><p>. You could do the same with tabs and spaces if
you want. Use a regular expression (can't give it to you off the top of my
head sorry) to find all the runs of spaces that are 2 or more long and
replace all but the first space with &nbsp;

Should give you what you want.
Alright, I guess that's the best I can hope for at this point. Seems
like a lot of work for something that should be able to be handled by
stylesheets. Thanks.

Aug 14 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3315
by: qwweeeit | last post by:
Hi all, I need to limit as much as possible the lenght of a source line, stripping white spaces (except indentation). For example: .. . max_move and AC_RowStack.acceptsCards ( self, from_stack, cards ) must be reduced to: .. . max_move and AC_RowStack.acceptsCards(self,from_stack,cards) My solution has been (wrogly): ''.join(source_line.split())
1
1700
by: Bob Bedford | last post by:
I've about 50`000 jpg images on a dir. Some images have a white frame, other only 2 white lines, sometimes vertically, sometimes horizontally. I've to show those image on a darkgrey background, and the result is ugly. It's there any way to detect those white lines, then change their color for showing on the screen ? I won't change the color of the frame on the image itself, but when showing them. Also take in mind that some parts of...
11
15010
by: gopal srinivasan | last post by:
Hi, I have a text like this - "This is a message containing tabs and white spaces" Now this text contains tabs and white spaces. I want remove the tabs and white spaces(if it more than once between two words). Is there any function we have in C which will find out the tabs and white spaces and returns the text in the follwong way -
2
2451
by: headware | last post by:
I've been getting a strange bug occurring in my ASP.NET pages. If while waiting for a page to load, the user clicks a dropdown listbox that causes postbacks, the whole screen turns white and it apparently cannot be refreshed. I have a framed layout and only the main frame turns white. If you click on menu options on the left frame (which remain intact) you can see that the pages are loading but nothing appears in the main frame. It remains...
11
1611
by: Dennis D. | last post by:
Back a few decades the proper way to learn a language began with a white paper. Do they exist for dot net, or would a person begin by studying the compiler specs? Guess what I'm asking is: Where does it all start? -- http://www.dennisys.com/
7
10846
by: marfi95 | last post by:
I'm trying to implement some code in vb.net to allow the user to adjust the brightness or contrast on an image (through the use of a slider) that is already black & white in the bitmap. I have tried to use the colormatrix and even down to the pixel using GetPixel and SetPixel in system.drawing, but I'm really not up on using gdi+ and haven't really gotten anywhere. I've seen some examples for VB6, but I need vb.net. I know that all...
9
3776
by: martin1 | last post by:
Hi, All, how to flash button with 2 color( eg. red and white)? then when user click button, the button stop flash and stay red color? Thanks
1
2044
by: bmjnine | last post by:
Hi all, I am converting image files of various formats to JPEG using: System.Drawing.Image img = System.Drawing.Image.FromFile(myfilepath); Works great except that transparent GIF's are over a black background instead of white. What would be the simplest way to convert GIF's to an Image object over a white background?
2
1532
by: origenes | last post by:
Hi forum, Below is a sample code that creates a "white" gif image. I want to know... why the background result color is FEFCFE intead of white (FFFFFF)? When I use imagecreate instead of imagecreatetruecolor, the white color is OK. Thanks in advance! <?php $file= "image.gif"; $img = imagecreatetruecolor(100,20);
4
3716
by: ashokprem18 | last post by:
I have a problem when we load the image into the movie clip, I have to replace the transparent pixels instead of white. If the image contain white pixel it has remove it completely from the image and has to give the final image without the White background . If the image dosent have any white background we can use the image as it is. Please provide me the code as soon as possible. Flash Action Script 2.0 is being used.
0
8582
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9122
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9001
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7672
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6498
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4587
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3018
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2281
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1984
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.