My input is pretty simple. I'm pulling from a data file to fill <p>
with content then running the method markdownify
, but the output duplicates the <p>
element in (to me) unexpected ways.
Please advise! And thank you.
Sample Input:
{% for item in site.data.filename.item %}
<p style="display:{{ item.display }}" id="{{ item.nav }}">{{ item.content | markdownify }}</p>
{% endfor %}
And the Output:
<p id="test" style="display:block"></p>
<p>testing output</p>
<p></p>
Is there something going on with my liquid syntax? Many thanks in advance
This is typically what happens when you nest paragraphs. You should remove HTML tags from your content.
{{ item.content | strip_HTML}}
https://docs.shopify.com/themes/liquid/filters/string-filters#strip_html
If you want to keep the html formatting, you can use a div to wrap the content, like this:
{% for item in site.data.filename.item %}
<div style="display:{{ item.display }}" id="{{ item.nav }}">{{ item.content | markdownify }}</div>
{% endfor %}
Did you try removing markdownify? Internally jekyll framework will apply markdownify
so we do not need to write markdownify
I tried your code with markdownify
removed and got single lines of <p>
duplicates.
strip_HTML
option also works.
Either remove markdownify
or put strip_HTML
Instead of display:{{ item.display }}
try
display:{{ display }}
Should do the job! :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.