realph
realph

Reputation: 4681

Jekyll: Markup Appearing in <p> Tag

I've got an issue where my some of my markup from a file in my _/includes folder, is being printed to my page inside <p> tags.

Here's what's inside my _includes/gallery.html file:

{% assign rows = page.gallery[include.gallery] %}

    </section> <!-- close this -->
  </div> <!-- and this -->
</div> <!-- this too -->

<section class="image-gallery">
  ...
</section>

<div class="container"> <!-- open this -->
  <div> <!-- and this -->
    <section> <!-- this too -->

I'm trying to close out some elements, and re-open them after my .image-gallery. But for some reason, my closing and opening tags are being printed inside <p> tags

Like this:

<pre><code>&lt;/section&gt;
  </code></pre>
    <p>&lt;/div&gt;
    &lt;/div&gt;</p>

    <section class="image-gallery">
        ...

Is there any way to stop this from happening? It seems to only affect non-closed tags, like the ones in my example. Everything inside .image-gallery displays correctly.

Anyone know why this is happening? Any help is appreciated. Thanks in advance!

Upvotes: 2

Views: 897

Answers (1)

David Jacquel
David Jacquel

Reputation: 52829

Ok, I get it.

You including _includes/gallery.html from a .md file, so markdown first includes, then try to parse the code.

As you code has unopened tags at the beginning (</section></div></div>) they are treated as markdown, not html.

Edit:

The solution is to surround your code with :

{::nomarkdown}
your code here
{:/nomarkdown}

This avoid your html to be parsed by kramdown.

Upvotes: 6

Related Questions