Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embedding Markdown in Jekyll HTML

I'm trying to nest markdown in an HTML file while using Jekyll. Is there a way to achieve something like the following?

# index.html  --- layout: default ---   <p>[Stack Overflow](http://www.stackoverflow.com)</p> 

Note: I'm aware that I could do this instead.

# index.html  --- layout: default ---   <p><a href="http://www.stackoverflow.com">Stack Overflow</a></p> 
like image 576
sunnyrjuneja Avatar asked Apr 10 '13 05:04

sunnyrjuneja


People also ask

How do I embed a Markdown in HTML?

For any markup that is not covered by Markdown's syntax, you simply use HTML itself. There's no need to preface it or delimit it to indicate that you're switching from Markdown to HTML; you just use the tags. The only restrictions are that block-level HTML elements — e.g. <div> , <table> , <pre> , <p> , etc.

Does Jekyll support Markdown?

By default, Jekyll uses the kramdown Markdown processor with stock settings, but you can enable other kramdown options or even switch Jekyll to another Markdown processor. See the Jekyll Markdown configuration options documentation for more information.

Can I use HTML in Jekyll?

Your Jekyll pages consist of HTML, CSS, and JavaScript, so pretty much any code you need to embed will work without a problem. As you integrate code for these services, note that if a page in your Jekyll site doesn't have front matter tags, Jekyll won't process any of the content in that page.

Can I write HTML in Md file?

Not only is it okay to do, but it is encouraged. As the rules state: For any markup that is not covered by Markdown's syntax, you simply use HTML itself.


1 Answers

If you are using Kramdown, based on their doc you can do this:

<div markdown="1">    My text with **markdown** syntax </div> 

And this way, the text within the div is rendered as markdown.

Make sure to use the .md or .markdown extension for the file, as .html files aren't sent to Kramdown for processing!

like image 81
Cristian Avatar answered Sep 28 '22 04:09

Cristian