Jekyll: Cannot render YAML front matter field as markdown correctly

依然范特西╮ 提交于 2019-12-10 18:16:52

问题


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
---

And then:

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

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

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

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.


回答1:


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



来源:https://stackoverflow.com/questions/27701911/jekyll-cannot-render-yaml-front-matter-field-as-markdown-correctly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!