1

这就是我想要的页面:

<ol>
  <li>first</li>
  <li>second
    <code></code>
  </li>
  <li>third</li>
</ol>

这就是我要写的:

1. first
2. second
  {% highlight ruby %}
  code here
  {% endhighlight %}
3. third

这就是它的呈现方式:

<ol>
  <li>first</li>
  <li>second</li>
</ol>
<div class="highlight>
  code here
</div>
<ol>
  <li>third</li>
</ol>

那么我该怎么写,它会呈现出我想要的样子呢?

4

2 回答 2

1

I haven't been able to figure out how to use the "Pygments" highlighting for code blocks inside of lists. It is possible to do a basic code block without highlighting with the following:

1. first
2. second

        code here

3. third

The white space placement here is important. The way that snippet of code works, there is a a blank line between 2. second and the code here line. Additionally, there are two tabs before the code here text (Eight spaces should also work).

The output from the above using jekyll 1.0.3 with markdown: kramdown set in the _config.yml file produces:

<ol>
  <li>first</li>
  <li>
    <p>second</p>

    <pre><code> code here
</code></pre>
  </li>
  <li>third</li>
</ol> 
于 2013-08-05T15:21:39.517 回答
1

我想出了一个办法:

1. first
2. second
 : {% highlight ruby %}
code
code
code
{% endhighlight %}
3. third

这呈现为定义列表(<dt><dd>标签),这可能在技术上不正确地使用该标记,所以如果你对那种东西非常严格,你可能不喜欢它,但我无法找到另一种方法编写您自己的插件来生成列表,这将完全改变您编写它们的方式。

于 2015-10-27T01:51:45.277 回答