Click here to Skip to main content
15,885,141 members
Please Sign up or sign in to vote.
5.00/5 (3 votes)
See more:
When I'm viewing articles on CodeProject (in IE9), <pre> blocks render with every line left-justified. If I copy and paste the code, it seems to have the spaces, though.

EDITORS: IF YOU MAKE THESE SNIPPETS "PRETTY", THE QUESTION MAKES NO SENSE. PLEASE *READ* BEFORE CHANGING FORMATTING. THANK YOU!

For example (and without using any code block tags so as not to hide the question about the error by invoking the error!), this html:
--------------------------------------------------------------------
<pre lang="cs"> <span class="code-keyword">protected</span> <span class="code-keyword">override</span> <span class="code-keyword">void</span> OnTextChanged(EventArgs e)
{
<span class="code-keyword">base</span>.OnTextChanged(e);
<span class="code-keyword">foreach</span> (<span class="code-keyword">string</span> UnapprovedChars <span class="code-keyword">in</span> UnapprovedChar)
{
<span class="code-keyword">if</span> (<span class="code-keyword">this</span>.Text.Contains(UnapprovedChars))
{
<span class="code-keyword">this</span>.Text = <span class="code-keyword">this</span>.Text.Replace(UnapprovedChars, <span class="code-SDKkeyword">String</span>.Empty);
}
}
}
}</pre>
--------------------------------------------------------------------



Renders as:
--------------------------------------------------------------------
protected override void OnTextChanged(EventArgs e)
{
base.OnTextChanged(e);
foreach (string UnapprovedChars in UnapprovedChar)
{
if (this.Text.Contains(UnapprovedChars))
{
this.Text = this.Text.Replace(UnapprovedChars, String.Empty);
}
}
}
--------------------------------------------------------------------
Clearly, this isn't desirable. Spaces should be significant in a <pre> block. I haven't chased down the styles being applied to the <span>s inside the <pre> block; they aren't applied to every line that gets mis-rendered, though.

Any idea what's going on? I assume most people don't see this?
Posted
Updated 22-Apr-11 8:52am
v3
Comments
Seth Morris 22-Apr-11 14:32pm    
Please, don't edit the question unless you read it. Those two snippets should *not* be in code blocks.

Really.

You had the "Ignore HTML" checkbox checked (under the text entry field). I unchecked it and escaped the <pre> blocks your regular text, and it looks fine now.

If you select the Improve question link, you'll see what I did.
 
Share this answer
 
Comments
Seth Morris 22-Apr-11 14:34pm    
I did look.

After your "improvement," the rendering on my machine was exqactlky the error I want to ask about--in both sections.

I left them plain for a reason: to show what the source was without the broken rendering. Turning on the rendering styles for it makes the question moot.
AspDotNetDev 23-Apr-11 1:22am    
It's an IE9 problem. Looks fine in all browsers, except in IE9 the indents are gone.
I have the same issue, on Internet Explorer 9.

Try use Chrome.
Or even the compatibilty mode of IE9 should do the trick (that icon shaped like a shredded sheet of paper, near the address bar, on the right).
 
Share this answer
 
Ok. Thanks for informing.
This has been raised to CP Admins and they will look into it.
This is a similar thread reported: http://www.codeproject.com/Messages/3866045/Indents-Missing-from-PRE-blocks-in-IE9.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900