本文介绍了我可以停止CodeProject上的块以使其左对齐吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我查看有关CodeProject(在IE9中)的文章时,< pre>块渲染,每行左对齐.如果我复制并粘贴代码,则似乎有空格.

如果您将这些片段记为"Pretty",则该问题没有任何意义.更改格式前,请*阅读*.谢谢!

例如(并且不使用任何代码块标签,以免通过调用错误隐藏有关错误的问题!),此html:
-------------------------------------------------- ------------------
< pre lang ="cs"> < span class ="code-keyword"> protected</span> < span class ="code-keyword">覆盖</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>
-------------------------------------------------- ------------------



呈现为:
-------------------------------------------------- ------------------
受保护的重写void OnTextChanged(EventArgs e)
{
base.OnTextChanged(e);
foreach(UnapprovedChar中的字符串UnapprovedChars)
{
如果(this.Text.Contains(UnapprovedChars))
{
this.Text = this.Text.Replace(UnapprovedChars,String.Empty);
}
}
}
-------------------------------------------------- ------------------
显然,这是不可取的.在< pre>中,空格应该很大.堵塞.我没有追究应用于< pre>内部的< span>的样式.堵塞;但是,它们不会应用于错误渲染的每一行.

知道发生了什么吗?我认为大多数人看不到吗?

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?

推荐答案




这篇关于我可以停止CodeProject上的块以使其左对齐吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 15:02