Jekyll:Markup出现在<p>标签中

rea*_*lph 1 html jekyll

我有一个问题,我的文件_/includes夹中的文件中的一些标记正在打印到<p>标签内的页面.

这是我的_includes/gallery.html文件里面的内容:

{% assign rows = page.gallery[include.gallery] %}

    </section> <!-- close this -->
  </div> <!-- and this -->
</div> <!-- this too -->

<section class="image-gallery">
  ...
</section>

<div class="container"> <!-- open this -->
  <div> <!-- and this -->
    <section> <!-- this too -->
Run Code Online (Sandbox Code Playgroud)

我试图关闭一些元素,并在我之后重新打开它们.image-gallery.但由于某些原因,正在被打印在我的关闭和开启的标签<p>标签

像这样:

<pre><code>&lt;/section&gt;
  </code></pre>
    <p>&lt;/div&gt;
    &lt;/div&gt;</p>

    <section class="image-gallery">
        ...
Run Code Online (Sandbox Code Playgroud)

有没有办法阻止这种情况发生?它似乎只影响非闭合标签,就像我的例子中那样.里面的一切都.image-gallery正确显示.

任何人都知道为什么会这样吗?任何帮助表示赞赏.提前致谢!

Dav*_*uel 6

好的我明白了.

你包括_includes/gallery.html一个.md文件,所以markdown首先包含,然后尝试解析代码.

由于您的代码在开头(</section></div></div>)处有未打开的标签,因此它们被视为markdown,而不是html.

编辑:

解决方案是用以下代码包围您的代码:

{::nomarkdown}
your code here
{:/nomarkdown}
Run Code Online (Sandbox Code Playgroud)

这可以避免kramdown解析你的html.