Skip to content

Instantly share code, notes, and snippets.

@themattchan
Last active August 29, 2015 14:14
Show Gist options
  • Save themattchan/8e99554eed11fcab0dd4 to your computer and use it in GitHub Desktop.
Save themattchan/8e99554eed11fcab0dd4 to your computer and use it in GitHub Desktop.
# MarkdownBlock
# Insert & parse Markdown anywhere, even nested in html
#
# Author: Matthew Chan <matt@themattchan.com>
# Date: January 2015
# License: GNU GPL
#
# Usage:
# {% markdown %}
# <md_text>
# {% endmarkdown %}
module Jekyll
class MarkdownBlock < Liquid::Block
def initialize(tag_name, text, tokens)
super
end
require "kramdown"
def render(context)
content = super
"#{Kramdown::Document.new(content,:input => 'GFM').to_html}"
end
end
end
Liquid::Template.register_tag('markdown', Jekyll::MarkdownBlock)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment