Jekyll - How can I make avoid a paragraph to be added on a YAML frontmatter markdownify item
Well... It's quite old question, but still actual.
You can use | remove: '<p>' | remove: '</p>'
like David Jacquel answered before. But it will remove every <p>
tag in the text.
But if you want to remove <p>
-tag wrapping only in cases there is only one <p>
node, you'll need more complex solution.
There are few ways to do that without external plugins and filters.
And this is my solution:
{%- assign arr = yourTextVar | markdownify | strip | split: "<p>" -%}{%- if arr.size > 2 -%} {{ arr | join: "<p>" | prepend: "<p>" }}{%- else -%} {{ arr[1] | remove: "</p>" }}{%- endif -%}
It'll split the text on empty <p>
tag and will ignore anything like <p id="my-id">