Jekyll - How can I make avoid a paragraph to be added on a YAML frontmatter markdownify item

江枫思渺然 提交于 2019-12-06 23:23:57

问题


Okay... I have a project where I'm using Jekyll for a podcast project. And I chose to list the hosts in the shownotes by a YAML Front Matter item:

hosts:
  - Name A
  - Name B
  - Name C

Using this piece of code

<li> <strong>Hosts:</strong>
<ul>
  {% for host in page.hosts %}
<li>{{ host }}
{% endfor %}
</ul>

I receive the correct list

<ul>
<li> <strong>Hosts:</strong> 
<ul> 
  <li>Name A </li>
  <li>Name B </li>
  <li>Name C </li>
</ul>
</ul>

However, I want to markdownify this by doing

<li> <strong>Hosts:</strong>
<ul>
  {% for host in page.hosts %}
<li>{{ host | markdownify }}
{% endfor %}
</ul>

But Jekyll returns:

<ul>
<li> <strong>Hosts:</strong> 
<ul> 
  <li><p>Name A </p></li>
  <li><p>Name B </p></li>
  <li><p>Name C </p></li>
</ul>
</ul>

Any way to forbid Jekyll to add the <p> tag into the list item? Actually, if I want to add any rich formatting, I need to put HTML directly into the items, but I want to add it via Markdown'ing the Front Matter text. Any suggestions?

PS: my site is hosted at Github Pages


回答1:


You can use the remove filter like this :

{{ host | markdownify | remove: '<p>' | remove: '</p>' }}


来源:https://stackoverflow.com/questions/30824395/jekyll-how-can-i-make-avoid-a-paragraph-to-be-added-on-a-yaml-frontmatter-mark

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