Jekyll:无法正确将YAML前项字段呈现为markdown [英] Jekyll: Cannot render YAML front matter field as markdown correctly

查看:104
本文介绍了Jekyll:无法正确将YAML前项字段呈现为markdown的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用YAML前端中的节点列表来构建网站中的页面,如下所示:

I am building the pages in my site with a list of nodes in the YAML front matter, like so:

---
title: My page
layout: default
nodes:
  - header: Node header
    text_block: >
        This is supposed to be markdown.

        [This works](http://example.com)

        But:  
        - this
        - doesn't
        - work
---

然后:

{% for node in page.nodes %}
    {{ node.text_block | markdownify }}
{% endfor %}

在上面的示例中,text_block的呈现方式如下:

In the above example, the text_block will be rendered like this:

这应该是降价促销. 这有效但是:-此-不起作用

This is supposed to be markdown. This works But: - this - doesn't - work

不显示换行符和列表,而只是将它们放在一个大的<p>标记中.

The line breaks and lists are not being rendered, it's all just put together in one big <p> tag.

将渲染引擎更改为redcarpet不起作用,将unindent添加到markdownify调用中也不会

Changing rendering engine to redcarpet doesn't work, and neither does adding unindent to the markdownify call

有些东西告诉我,这与缩进级别有关,但我无法解决.

Something tells me this has to do with the indentation level, but I just can't work it out.

推荐答案

我发现了问题,这与YAML有关.我使用|代替了在字段开头使用>的方法,从而解决了该问题.

I found the problem, it was YAML related. Instead of using > in the beginning of the field, I used |, and it solved the problem.

这篇关于Jekyll:无法正确将YAML前项字段呈现为markdown的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆