Nick
Nick

Reputation: 1025

Jekyll rendering Markdown in _include not working

I'm attempting to render some markdown within an _include file in my Jekyll site but for some reason I can't get it to work. I'm trying 2 different methods, here is my markdown document

---
layout: post
title: "About"
description: 
---
# This is a test

> pop

Here is my include file

<div class="tab">
    {% markdown about.markdown %}

    {% capture my-include %}{% include about.markdown %}{% endcapture %}
    {{ my-include | markdownify }}
</div>

As you can see, the first method I'm trying is using a plugin, shown below and sourced from here http://wolfslittlestore.be/2013/10/rendering-markdown-in-jekyll/, the second method is using markdownify,

=begin
  Jekyll tag to include Markdown text from _includes directory preprocessing with Liquid.
  Usage:
    {% markdown <filename> %}
  Dependency:
    - kramdown
=end
module Jekyll
  class MarkdownTag < Liquid::Tag
    def initialize(tag_name, text, tokens)
      super
      @text = text.strip
    end
    require "kramdown"
    def render(context)
      tmpl = File.read File.join Dir.pwd, "_includes", @text
      site = context.registers[:site]
      tmpl = (Liquid::Template.parse tmpl).render site.site_payload
      html = Kramdown::Document.new(tmpl).to_html
    end
  end
end
Liquid::Template.register_tag('markdown', Jekyll::MarkdownTag)

Unfortunately all it's doing (using both methods) is outputting the raw, unparsed markdown.

Any idea what I'm doing incorrectly?

Upvotes: 2

Views: 568

Answers (1)

Nick
Nick

Reputation: 1025

Okay so I was mistaken, it does parse the markdown file, using both methods. It's just that the produced styles do not match what I was expecting to see. Plus it doesn't support the YAML front matter, so I removed that and tweaked my markdown file to look like I wanted it to originally.

One style that looks totally different is the Blockquote. It's not the correct font, so that will be my style sheet that needs amending.

Upvotes: 1

Related Questions