Click here to Skip to main content
15,896,063 members

Can I stop blocks on CodeProject from rendering left-justified?

Seth Morris asked:

Open original thread
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?
Tags: Internet Explorer 9

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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