Text to HTML

  • Thread starter Thread starter Tina
  • Start date Start date
T

Tina

I have a text file perfectly formatted with carriage returns, indents,
spacing etc in NotePad. I want to put text that looks exactly like that
into a <div> and get it formatted exactly the same way in Visual Studio.
But I can't seem to get this done in Visual Studio other than pasting it
into a textbox - which I don't want to do.

If I paste it into a div in design view it removes all formatting. Same in
source view. If I put it into MS Word and save as plain html it puts all
sorts of gargage in it that doesn't work in VS.

Is there any program that will do this?

Thanks,
T
 
Put the text into a <PRE>...</PRE> tag, which will hold on to the whitespace
formatting. You can put the PRE tag into a DIV tag if you want.
 
Well, that works pretty good. Thanks.
Is there a way to get the text to wrap inside the PRE or the DIV?
Thanks,
T
 
Oh, I also notice that text inside the PRE will not follow CSS specified
fonts so it looks like
it acts just like text in a text box and these are the reasons I did not
want to use a textbox.
T
 
Sorry, you can't have it both ways. Use PRE and WYSIWYG, no more and no
less - don't use PRE and all white space is stripped.
 
Again, that's what PRE does - uses a monospaced font.

You've got to remember the language you are working in. HTML is a language
where whitespace stripping occurs. If you want to build space back in, you
could look into entities such as &nbsp; (which will get messy). You could
read your text file and parse that file into <P>, <BR> and &nbsp; where you
read line breaks and spaces.
 
PRE
{
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
 
Back
Top