Text to HTML

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
 
S

Scott M.

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.
 
T

Tina

Well, that works pretty good. Thanks.
Is there a way to get the text to wrap inside the PRE or the DIV?
Thanks,
T
 
T

Tina

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
 
S

Scott M.

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.
 
S

Scott M.

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.
 
T

Tips

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+ */
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,088
Latest member
JeremyMedl

Latest Threads

Top