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