Embedding Markdown in Jekyll HTML

后端 未结 7 469
一向
一向 2020-12-29 01:47

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
--         


        
7条回答
  •  独厮守ぢ
    2020-12-29 02:15

    To convert the markdown-formatted string to HTML in a Jekyll page, there are THREE WAYS can be selected as below:


    1. Kramdown:

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

    ## Some Markdown Title Let's have a look. `snippet` _italic_ **bold**

    The markdown attribute:

    • If an HTML tag has an attribute markdown="0", then the tag is parsed as raw HTML block.
    • If an HTML tag has an attribute markdown="1", then the default mechanism for parsing syntax in this tag is used.
    • If an HTML tag has an attribute markdown="block", then the content of the tag is parsed as block level elements.
    • If an HTML tag has an attribute markdown="span", then the content of the tag is parsed as span level elements.

    Requirments:

    • The markdown content need to be within the DIV tag.
    • Make sure to use the .md or .markdown extension for the file as .html files aren't sent to Kramdown for processing)

    2. Liquid Extension Filter

    There is a liquid extension filter called markdownify, it also can help you convert a Markdown-formatted string into HTML.

    {{ "Renders as markdown. `snippet` _italic_ **bold**" | markdownify }}

    3. Jekyll plugin:

    jekyll-spaceship -

提交回复
热议问题