html - Jekyll:标记出现在 <p> 标签中

标签 html jekyll

我有一个问题,我的一些标记来 self 的 _/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 -->

我试图关闭一些元素,并在我的 .image-gallery 之后重新打开它们.但出于某种原因,我的结束标签和开始标签打印在 <p> 内标签

像这样:

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

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

有什么办法可以阻止这种情况发生吗?它似乎只影响非封闭标签,就像我例子中的标签一样。里面的一切 .image-gallery正确显示。

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

最佳答案

好的,我明白了。

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

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

编辑:

解决方案是用 :

包围您的代码
{::nomarkdown}
your code here
{:/nomarkdown}

这可以避免您的 html 被 kramdown 解析。

关于html - Jekyll:标记出现在 <p> 标签中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29053280/

相关文章:

html - 使用 Jekyll 创建自定义主页

ruby - 生成博客时 octopress image_tag 插件的语法错误

html - Jekyll - 不同类别的下一个和上一个链接

javascript - 用对 Angular 线拆分两个 div 文本

javascript - 如何将元素的背景图像设置为用户上传的图像

jquery - 如何从每个子元素中选择第一个元素

jekyll - 检查 Jekyll 数据文件中的空字段

php - mysql 从表中选择第n列

html - 在 css 中使用相邻选择器的边距

sass - 在 GitHub 页面的 Jekyll 站点中包含多个 sass 目录?