6

I'm creating a site using jekyll.rb.
I have a page called about.html:

<div class="grid_10 page">
    {% include about_content.markdown %}
</div>

In about_content.markdown I have some dummy markdown:

A First Level Header
====================

A Second Level Header
---------------------

Hello!

For some reason, when the page is rendered, the result is this:

result http://gabrielecirulli.com/p/20120107-203135.png

Even if I add the YAML front matter to my markdown file nothing changes.

This is my _config.yml

safe:        false
auto:        false
server:      false
server_port: 4000
baseurl:    /

source:      .
destination: ./_site
plugins:     ./_plugins

future:      true
lsi:         false
pygments:    false
markdown:    maruku
permalink:   date

maruku:
  use_tex:    false
  use_divs:   false
  png_engine: blahtex
  png_dir:    images/latex
  png_url:    /images/latex

rdiscount:
  extensions: []

kramdown:
  auto_ids: true,
  footnote_nr: 1
  entity_output: as_char
  toc_levels: 1..6
  use_coderay: false

  coderay:
    coderay_wrap: div
    coderay_line_numbers: inline
    coderay_line_numbers_start: 1
    coderay_tab_width: 4
    coderay_bold_every: 10
    coderay_css: style

How can I make jekyll interpret markdown?

kettlepot
  • 10,574
  • 28
  • 71
  • 100

1 Answers1

14

You will have to pass it through the markdownify filter:

<div class="grid_10 page">
  {% capture about_content %}
    {% include about_content.markdown %}
  {% endcapture %}
  {{ about_content | unindent | markdownify }}
</div>

To keep the Markdown code indented but remove the indentation before markdownification, I would write a dedicated plugin, called for example _plugins/unindent.rb:

module Jekyll
  module UnindentFilter
    def unindent input
      input.lstrip
    end
  end
end

Liquid::Template.register_filter Jekyll::UnindentFilter
manatwork
  • 1,689
  • 1
  • 28
  • 31
  • Thanks, that solution worked but I'm having a problem where having an indentation before `{%include about_content.markdown %}` will make the first line of markdown invalid by putting spaces before it. Can this be avoided without having to sacrifice the indentation? – kettlepot Jan 08 '12 at 13:01
  • It should be noted that this (and all plugins) do NOT work with GitHub Pages. Took me a while to figure that out and it seems there is no good solution other than outdenting the include line (looks weird) or pushing compiled pages WITHOUT source files (pointless). [https://help.github.com/articles/pages-don-t-build-unable-to-run-jekyll](Reference) – user478798 Nov 21 '13 at 23:06