HighDots Forums  

white-space help

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss white-space help in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Brent
 
Posts: n/a

Default white-space help - 08-13-2006 , 12:28 PM






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 <pre> tag 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
<pre> and 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


Reply With Quote
  #2  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: white-space help - 08-13-2006 , 03:38 PM






Brent <bkraymond (AT) gmail (DOT) com> scripsit:

Quote:
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/



Reply With Quote
  #3  
Old   
Jim Moe
 
Posts: n/a

Default Re: white-space help - 08-13-2006 , 06:28 PM



Brent wrote:
Quote:
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 <pre> tag 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)


Reply With Quote
  #4  
Old   
Chris F.A. Johnson
 
Posts: n/a

Default Re: white-space help - 08-13-2006 , 06:40 PM



On 2006-08-13, Jim Moe wrote:
Quote:
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 <pre> tag 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)


Reply With Quote
  #5  
Old   
Brent
 
Posts: n/a

Default Re: white-space help - 08-13-2006 , 06:51 PM



Jim Moe wrote:
Quote:
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 <pre> tag 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 <pre> tag 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?



Reply With Quote
  #6  
Old   
Brent
 
Posts: n/a

Default Re: white-space help - 08-13-2006 , 06:55 PM




Chris F.A. Johnson wrote:
Quote:
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 <pre> tag 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.



Reply With Quote
  #7  
Old   
Chris F.A. Johnson
 
Posts: n/a

Default Re: white-space help - 08-13-2006 , 07:32 PM



On 2006-08-13, Brent wrote:
Quote:
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 <pre> tag 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)


Reply With Quote
  #8  
Old   
Brent
 
Posts: n/a

Default Re: white-space help - 08-13-2006 , 07:54 PM




Chris F.A. Johnson wrote:
Quote:
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 <pre> tag 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. :-(



Reply With Quote
  #9  
Old   
Nik Coughlin
 
Posts: n/a

Default Re: white-space help - 08-13-2006 , 08:51 PM



Brent wrote:
Quote:
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 <pre> tag 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 <pre> and 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 <p> to the beginning of the document and </p> to 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.




Reply With Quote
  #10  
Old   
Chris F.A. Johnson
 
Posts: n/a

Default Re: white-space help - 08-13-2006 , 09:23 PM



On 2006-08-13, Brent wrote:
Quote:
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 <pre> tag 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. :-(
What whitespace are you talking about? If you want a paragraph
indent, use style="text-indent: 2em; /* adjust to taste */".

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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.