Showing all spaces without using the  

  • Thread starter Nathan Sokalski
  • Start date
N

Nathan Sokalski

I am using ASP to read code from a text file that I am displaying on my
page. Because I do not want the code from the text file to be executed, I
used the Server.HTMLEncode() method to display it as it is in the file.
However, the spaces used to indent lines is still removed by the browser. I
cannot use VBScript's replace function to replace all spaces with  
because that would replace all spaces, including ones that I do not want
replaced as well as majorly increasing the size of my file. Is there any
way to display the spaces used to indent the lines without manually writing
a function to do it? Thank You.
 
J

Jeff Cochran

I am using ASP to read code from a text file that I am displaying on my
page. Because I do not want the code from the text file to be executed, I
used the Server.HTMLEncode() method to display it as it is in the file.
However, the spaces used to indent lines is still removed by the browser. I
cannot use VBScript's replace function to replace all spaces with  
because that would replace all spaces, including ones that I do not want
replaced as well as majorly increasing the size of my file. Is there any
way to display the spaces used to indent the lines without manually writing
a function to do it?

Yes. First, don't post to so many groups. This isn't DHTML or an ASP
component. It doesn't involve the HTML object model, and isn't
related to the SDK's. It's not even server side, so the ASP group is
also technically out. In fact, none of the groups you selected are
actually appropriate.

Look at the <pre></pre> tags in HTML. Google for a reference if you
don't understand them, or repost in a HTML group.

Jeff
 
D

David C. Holley

Please only post to one newsgroup. You'll find that it makes life easier
for everyone.
 
N

Nathan Sokalski

What about making long lines wrap around? Some lines in code (such as HTML
tags with a lot of attributes) will be too long to fit on one line, but the
PRE tag prevents text wrap. Based on the website I usually use as a
reference, the width attribute (which sets the maximum characters in a line)
is deprecated, but it does not state what technology is used in it's place.
I can use it, but I prefer not to use deprecated attributes. Any ideas?

(I apologize for sending to multiple newsgroups. I tend to do that because
some groups are rarely used, I don't always know which group is the precise
one I want, and I don't want to subscribe to ALL newsgroups. I will do my
best to lessen this habit)
 
A

AStr

I am using ASP to read code from a text file that I am displaying on my
page. Because I do not want the code from the text file to be executed, I
used the Server.HTMLEncode() method to display it as it is in the file.
However, the spaces used to indent lines is still removed by the browser. I
cannot use VBScript's replace function to replace all spaces with &nbsp;
because that would replace all spaces, including ones that I do not want
replaced as well as majorly increasing the size of my file. Is there any
way to display the spaces used to indent the lines without manually writing
a function to do it? Thank You.

Use <pre> tag or, if the whole your page is just text,
assign "text/plain" mime type to it.

HTH
 
J

Jeff Cochran

What about making long lines wrap around? Some lines in code (such as HTML
tags with a lot of attributes) will be too long to fit on one line, but the
PRE tag prevents text wrap. Based on the website I usually use as a
reference, the width attribute (which sets the maximum characters in a line)
is deprecated, but it does not state what technology is used in it's place.
I can use it, but I prefer not to use deprecated attributes. Any ideas?

Plenty. But again, it's not an ASP issue. It's a client-side display
issue. Try a client-side HTML group for solutions.

Jeff
 
M

McKirahan

Nathan Sokalski said:
I am using ASP to read code from a text file that I am displaying on my
page. Because I do not want the code from the text file to be executed, I
used the Server.HTMLEncode() method to display it as it is in the file.
However, the spaces used to indent lines is still removed by the browser. I
cannot use VBScript's replace function to replace all spaces with &nbsp;
because that would replace all spaces, including ones that I do not want
replaced as well as majorly increasing the size of my file. Is there any
way to display the spaces used to indent the lines without manually writing
a function to do it? Thank You.


Write a function to only replace only the leading spaces of each line using
a regular expression.
 

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,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top