Set TOC data for Markdown & override Haml filter

This commit is contained in:
Olivier Lacan 2017-03-23 03:48:28 +01:00
parent 76d8c70889
commit 7adec560c8

View File

@ -55,12 +55,14 @@ activate :automatic_image_sizes
activate :syntax
set :markdown_engine, :redcarpet
set :markdown, {
$markdown_config = {
fenced_code_blocks: true,
footnotes: true,
smartypants: true,
tables: true
tables: true,
with_toc_data: true
}
set :markdown, $markdown_config
# --------------------------------------
# Helpers
@ -117,3 +119,19 @@ activate :autoprefixer do |config|
config.browsers = ['last 2 versions', 'Explorer >= 10']
config.cascade = false
end
# Haml doesn't pick up on Markdown configuration so we have to remove the
# default Markdown Haml filter and reconfigure one that follows our
# global configuration.
module Haml::Filters
remove_filter("Markdown") #remove the existing Markdown filter
module Markdown
include Haml::Filters::Base
def render(text)
Redcarpet::Markdown.new(Redcarpet::Render::HTML.new($markdown_config)).render(text)
end
end
end