我不确定我是否做错了什么,但我无法让 codehilite 正确生成代码,例如:
from markdown import markdown
self.content_html = markdown(self.content, ['codehilite'])
我正在使用来自维基百科的这个 C# 来测试
public class GenericList<T>
{
void Add(T input) { }
}
class TestGenericList
{
private class ExampleClass { }
static void Main()
{
// Declare a list of type int.
GenericList<int> list1 = new GenericList<int>();
// Declare a list of type string.
GenericList<string> list2 = new GenericList<string>();
// Declare a list of type ExampleClass.
GenericList<ExampleClass> list3 = new GenericList<ExampleClass>();
}
}
结果是
<p>public class GenericList<T>
{
void Add(T input) { }
}</p>
<p>class TestGenericList
{
private class ExampleClass { }
static void Main()
{
// Declare a list of type int.
GenericList<int> list1 = new GenericList<int>();</p>
<div class="codehilite"><pre> <span class="c1">// Declare a list of type string.</span>
<span class="nx">GenericList</span><span class="o"><</span><span class="kt">string</span><span class="o">></span> <span class="n">list2</span> <span class="o">=</span> <span class="nb">new</span> <span class="nx">GenericList</span><span class="o"><</span><span class="kt">string</span><span class="o">></span><span class="p">();</span>
<span class="c1">// Declare a list of type ExampleClass.</span>
<span class="nx">GenericList</span><span class="o"><</span><span class="nx">ExampleClass</span><span class="o">></span> <span class="n">list3</span> <span class="o">=</span> <span class="nb">new</span> <span class="nx">GenericList</span><span class="o"><</span><span class="nx">ExampleClass</span><span class="o">></span><span class="p">();</span>
<span class="p">}</span>
</pre></div>
<p>}</p>
可以看到,它没有标记前几行,然后开始注释 有 // Declare a list of type string.
什么问题?