django-markdown和codehilite
我不确定我是否做错了什么,但我无法让codehilite正确生成代码,例如:django-markdown和codehilite,django,markdown,Django,Markdown,我不确定我是否做错了什么,但我无法让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
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>();
}
}
公共类泛型列表
{
void Add(T输入){}
}
类TestGenericList
{
私有类示例类{}
静态void Main()
{
//声明int类型的列表。
GenericList list1=新的GenericList();
//声明字符串类型的列表。
GenericList list2=新的GenericList();
//声明ExampleClass类型的列表。
GenericList list3=新的GenericList();
}
}
结果是
<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>
公共类泛型列表
{
void Add(T输入){}
}
类TestGenericList
{
私有类示例类{}
静态void Main()
{
//声明int类型的列表。
GenericList list1=新的GenericList()
//声明字符串类型的列表。
GenericListstring list2=新的GenericListstring();
//声明ExampleClass类型的列表。
GenericListExampleClass list3=新的GenericListExampleClass();
}
}
如您所见,它没有标记前几行,然后以注释开始。//声明一个类型字符串列表。怎么了?您应该使用
然后尝试在代码块之前的降价中添加一个:
块
我写了一系列关于这一点的文章,可能也会有所帮助
编辑(我想这就是问题所在)
在每行代码前面需要4个空格,codehilite才能在上面拾取。此外,代码的第一行和最后一行在前后都需要一个\n
,您的代码不能与常规文本对接(不缩进4个空格)。此外,您的代码不能嵌入到项目符号列表中