diff --git a/CHANGELOG.md b/CHANGELOG.md
index b99d42db..5e1b9b5f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
master
===
+* Allow frontmatter "renderer_options" key to overwrite renderer options on a per-file basis. #859
* Added a "t" helper that delegates to I18n.t, just like Rails. #853.
* I18n will fall back to the default locale if a translation in the current locale is not found. You can disable this behavior by passing `:no_fallbacks => true` when activating `:i18n`. More settings documented at https://github.com/svenfuchs/i18n/wiki/Fallbacks . #853
* Switched default Markdown engine to Kramdown. #852
diff --git a/middleman-core/lib/middleman-core/core_extensions/rendering.rb b/middleman-core/lib/middleman-core/core_extensions/rendering.rb
index 93f83de6..24d436a2 100644
--- a/middleman-core/lib/middleman-core/core_extensions/rendering.rb
+++ b/middleman-core/lib/middleman-core/core_extensions/rendering.rb
@@ -250,6 +250,9 @@ module Middleman
options = opts.merge(options_for_ext(extension))
options[:outvar] ||= '@_out_buf'
+ # Overwrite with frontmatter options
+ options = options.deep_merge(options[:renderer_options]) if options[:renderer_options]
+
template_class = Tilt[path]
# Allow hooks to manipulate the template before render
self.class.callbacks_for_hook(:before_render).each do |callback|
diff --git a/middleman-core/lib/middleman-core/sitemap/resource.rb b/middleman-core/lib/middleman-core/sitemap/resource.rb
index 2a6c9ed6..63e29396 100644
--- a/middleman-core/lib/middleman-core/sitemap/resource.rb
+++ b/middleman-core/lib/middleman-core/sitemap/resource.rb
@@ -117,6 +117,15 @@ module Middleman
instrument "render.resource", :path => relative_source do
md = metadata.dup
opts = md[:options].deep_merge(opts)
+
+ # Pass "renderer_options" hash from frontmatter along to renderer
+ if md[:page]["renderer_options"]
+ opts[:renderer_options] = {}
+ md[:page]["renderer_options"].each do |k, v|
+ opts[:renderer_options][k.to_sym] = v
+ end
+ end
+
locs = md[:locals].deep_merge(locs)
# Forward remaining data to helpers
diff --git a/middleman-more/features/markdown_redcarpet.feature b/middleman-more/features/markdown_redcarpet.feature
index c9ea816a..4aa97104 100644
--- a/middleman-more/features/markdown_redcarpet.feature
+++ b/middleman-more/features/markdown_redcarpet.feature
@@ -42,6 +42,27 @@ Feature: Markdown support
When I go to "/hard_wrap.html"
Then I should see "br"
+ Scenario: Redcarpet per-page frontmatter options
+ Given a fixture app "markdown-frontmatter-options-app"
+ And a file named "config.rb" with:
+ """
+ set :markdown_engine, :redcarpet
+ set :markdown, :smartypants => true
+ """
+ Given the Server is running at "markdown-frontmatter-options-app"
+ When I go to "/smarty_pants-default.html"
+ Then I should see "“"
+ When I go to "/smarty_pants-on.html"
+ Then I should see "“"
+ When I go to "/smarty_pants-off.html"
+ Then I should not see "“"
+ When I go to "/tables-default.html"
+ Then I should not see "
"
+ When I go to "/tables-on.html"
+ Then I should see ""
+ When I go to "/tables-off.html"
+ Then I should not see ""
+
Scenario: Redcarpet uses our link_to and image_tag helpers
Given a fixture app "markdown-app"
And a file named "config.rb" with:
diff --git a/middleman-more/fixtures/markdown-frontmatter-options-app/config.rb b/middleman-more/fixtures/markdown-frontmatter-options-app/config.rb
new file mode 100644
index 00000000..55b36b24
--- /dev/null
+++ b/middleman-more/fixtures/markdown-frontmatter-options-app/config.rb
@@ -0,0 +1 @@
+set :markdown, :smartypants => true
diff --git a/middleman-more/fixtures/markdown-frontmatter-options-app/source/smarty_pants-default.html.markdown b/middleman-more/fixtures/markdown-frontmatter-options-app/source/smarty_pants-default.html.markdown
new file mode 100755
index 00000000..2dadeba1
--- /dev/null
+++ b/middleman-more/fixtures/markdown-frontmatter-options-app/source/smarty_pants-default.html.markdown
@@ -0,0 +1,5 @@
+---
+layout: false
+---
+
+"Hello"
\ No newline at end of file
diff --git a/middleman-more/fixtures/markdown-frontmatter-options-app/source/smarty_pants-off.html.markdown b/middleman-more/fixtures/markdown-frontmatter-options-app/source/smarty_pants-off.html.markdown
new file mode 100755
index 00000000..6bc260f7
--- /dev/null
+++ b/middleman-more/fixtures/markdown-frontmatter-options-app/source/smarty_pants-off.html.markdown
@@ -0,0 +1,7 @@
+---
+layout: false
+renderer_options:
+ smartypants: false
+---
+
+"Hello"
\ No newline at end of file
diff --git a/middleman-more/fixtures/markdown-frontmatter-options-app/source/smarty_pants-on.html.markdown b/middleman-more/fixtures/markdown-frontmatter-options-app/source/smarty_pants-on.html.markdown
new file mode 100755
index 00000000..f54e2d67
--- /dev/null
+++ b/middleman-more/fixtures/markdown-frontmatter-options-app/source/smarty_pants-on.html.markdown
@@ -0,0 +1,7 @@
+---
+layout: false
+renderer_options:
+ smartypants: true
+---
+
+"Hello"
\ No newline at end of file
diff --git a/middleman-more/fixtures/markdown-frontmatter-options-app/source/tables-default.html.markdown b/middleman-more/fixtures/markdown-frontmatter-options-app/source/tables-default.html.markdown
new file mode 100755
index 00000000..033fba90
--- /dev/null
+++ b/middleman-more/fixtures/markdown-frontmatter-options-app/source/tables-default.html.markdown
@@ -0,0 +1,8 @@
+---
+layout: false
+---
+
+First Header | Second Header
+------------- | -------------
+Content Cell | Content Cell
+Content Cell | Content Cell
\ No newline at end of file
diff --git a/middleman-more/fixtures/markdown-frontmatter-options-app/source/tables-off.html.markdown b/middleman-more/fixtures/markdown-frontmatter-options-app/source/tables-off.html.markdown
new file mode 100755
index 00000000..9ba04d43
--- /dev/null
+++ b/middleman-more/fixtures/markdown-frontmatter-options-app/source/tables-off.html.markdown
@@ -0,0 +1,10 @@
+---
+layout: false
+renderer_options:
+ tables: false
+---
+
+First Header | Second Header
+------------- | -------------
+Content Cell | Content Cell
+Content Cell | Content Cell
\ No newline at end of file
diff --git a/middleman-more/fixtures/markdown-frontmatter-options-app/source/tables-on.html.markdown b/middleman-more/fixtures/markdown-frontmatter-options-app/source/tables-on.html.markdown
new file mode 100755
index 00000000..9083397b
--- /dev/null
+++ b/middleman-more/fixtures/markdown-frontmatter-options-app/source/tables-on.html.markdown
@@ -0,0 +1,10 @@
+---
+layout: false
+renderer_options:
+ tables: true
+---
+
+First Header | Second Header
+------------- | -------------
+Content Cell | Content Cell
+Content Cell | Content Cell
\ No newline at end of file