【问题标题】:Jekyll produces different output than using kramdown directlyJekyll 产生的输出与直接使用 kramdown 不同
【发布时间】:2014-08-12 09:28:29
【问题描述】:

我想使用 jekyll 创建一个包含项目编号列表的 HTML 文档;即 HTML 中的 <ol>。有些项目包含一个表格。该列表在表格之后停止,但前提是我使用 jekyll,而不是直接使用 kramdown。

我正在运行 jekyll 2.2.0 版和 kramdown 1.4.1 版。

为了重现这一点,我使用jekyll new that 创建了一个新站点。然后我创建一个名为this.md的新降价文档:

---
layout: page
title: This
permalink: /this/
---

1. first

   |table|table|
   |-----|-----|
   |conte|nt   |

1. second
1. third

然后运行jekyll serve

这会为http://localhost:4000/this/ 生成以下 HTML 代码(仅引用相关部分):

  <ol>
  <li>first</li>
</ol>

<table>
  <thead>
    <tr>
      <th>table</th>
      <th>table</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>conte</td>
      <td>nt</td>
    </tr>
  </tbody>
</table>

<ol>
  <li>second</li>
  <li>third</li>
</ol>

这显然不是我想要的。并且运行 kramdown this.md 给出了我想要的:

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

    <table>
      <thead>
        <tr>
          <th>table</th>
          <th>table</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>conte</td>
          <td>nt</td>
        </tr>
      </tbody>
    </table>
  </li>
  <li>second</li>
  <li>third</li>
</ol>

即我想要一个包含多个项目的 &lt;ol&gt; 列表,而不是每个表之后的新列表。

jekyll 有什么不同?我该如何解决这个问题?

【问题讨论】:

    标签: jekyll kramdown


    【解决方案1】:

    正如kramdown doc 中所见,多行列表很棘手,您需要调整列表和表格的缩进:

    1. first (0 space indentation) NOT WORKING
    
       |table|  - 3 spaces indent|
       |-----|-----|
       |conte|nt   |
    
    2. second (0 space indentation) NOT WORKING
    
        |table|  - 4 spaces indent|
        |-----|-----|
        |conte|nt   |
    
     3. third (1 space indentation) NOT WORKING
    
       |table|  - 3 spaces indent|
       |-----|-----|
       |conte|nt   |
    
     4. fourth (1 space indentation) **WORKS GOOOOOD !!**
    
        |table|  - 4 spaces indent|
        |-----|-----|
        |conte|nt   |
    
    
     5. fifth - tip of the day - add a class to table
    
        {:.table}
        |table|  - 4 spaces indent|
        |-----|-----|
        |conte|nt   |
    

    【讨论】:

      猜你喜欢
      • 2020-02-07
      • 2019-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-26
      • 1970-01-01
      • 2016-11-19
      • 1970-01-01
      相关资源
      最近更新 更多