PruitIgoe
PruitIgoe

Reputation: 6384

Jekyll include markdown file not rendering html

I have a Jekyll site with an include file. Within that include file I am trying to include another file:

<div class="api-doc api-off api-definition" id="debugging">{% include_relative _apiDocs/debugging.md %}</div>

but this displays the markdown as a string:

--- title: API Reference | Debugging --- #### Debugging Turn on debugging: ```Javascript pbjs.setConfig({ debug: true }); ```

Is there a way to get this to render as HTML?

Upvotes: 1

Views: 488

Answers (1)

Max Gardner
Max Gardner

Reputation: 301

If you're using Kramdown as your processor, you can handle this by adding the markdown="1" attribute to the parent div:

<div class="api-doc api-off api-definition" id="debugging" markdown="1">{% include_relative _apiDocs/debugging.md %}</div>

If not, you can apply a filter on the included Markdown to convert it to HTML (see the Jekyll docs on the markdownify filter):

{%- capture debugging-doc -%}{% include_relative _apiDocs/debugging.md %}{%- endcapture -%}
<div class="api-doc api-off api-definition" id="debugging">{{ debugging-doc | markdownify }}</div>

Upvotes: 1

Related Questions