Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jekyll/Markdown HTML comment tag converted to literals

I'm using Markdown in Jekyll v1.4.2 for Windows, and I currently have my excerpt tag set to "<--excerpt-->"

However when I put the comment tag in my .markdown file as follows:

blog entry excerpt is here
<!--excerpt-->

blog entry continues

Jekyll converts the < and > in the comment tags to > and <, and the comment shows up in my final HTML, which looks like this:

<p> blog entry excerpt is here &lt;!--excerpt&gt;</p>
<p> blog entry continues</p>

Funnily, the tag is still recognized and excerpt works in the blog

To get the tag as an actual comment, I have to do this:

blog entry excerpt is here

<!--excerpt-->

blog entry continues

which gives me:

<p> blog entry excerpt is here</p>
<!--excerpt-->
<p> blog entry continues</p>

Is this intended behavior in Jekyll? I couldn't find anybody else with this issue and it took me hours to figure out, so hopefully at the very least this is helping someone else.

like image 772
Anthony C Avatar asked Feb 28 '14 22:02

Anthony C


1 Answers

It looks like this is the intended behavior for Jekyll and its Markdown processor. Per the Markdown specification for Paragraph elements,

A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines.

Essentially, your excerpt was being interpreted as part of the Paragraph element. When you added the blank line between your Comment and the preceding line, it was then placed after the closing </p> tag, and appeared as you intended.

like image 82
nicksuch Avatar answered Oct 03 '22 17:10

nicksuch