如何在网页中显示缩进的源代码? HTML? CSS?

如何在网页中显示缩进的源代码? HTML? CSS?

问题描述:

我想在winform上显示一些WebBrowser控件的源代码。我想用HTML标签来装饰源代码,例如颜色,字体和大小。但我发现很难正确显示缩进

I want to show some source code with the WebBrowser control on a winform. And I want to decorate the source code with HTML tags, such as color, font, and size. But I found it difficult to display the indent properly.

准确地说,我的源代码保存在String []中,持有适当的缩进(空格或制表符)。

To be precise, my source code are held in String[], and each String holds the proper indent (space or tab) already. But it seems these kinds of indent are just ignored by the WebBrowser control.

有人可以告诉我怎么办?

Could someone tell me how to?

< pre> 元素(使用 < code> 元素,以标记要语法高亮的部分)

The <pre> element (using <code> elements with appropriate class names to mark up the parts you want to syntax highlight)

<pre><code class="javascript"><code class="keyword">function</code> <code class="name">foo</code>()…