summaryrefslogtreecommitdiff
path: root/_plugins/admonition_md.rb
blob: d22ccebbdb5ed2e747af6309b74b0ac4feec9dd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module Jekyll
	class AdmonitionMarkdownBlock < Liquid::Block
		@type = ""

		def initialize(tag_name, text, tokens)
			super

			@type = text
		end

		require "redcarpet"

		def render(context)
			content = super

			'<section class="admonition">
				<div class="admonition-title">' + @type + '</div>
				<div class="admonition-content">
					' + Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(content) + '
				</div>
			</section>'
		end
	end
end

Liquid::Template.register_tag('admonition_md', Jekyll::AdmonitionMarkdownBlock)