diff --git a/CHANGELOG.md b/CHANGELOG.md
index 103304e0..b562ed46 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+master
+===
+
+* Support redcarpet's :no_links & :no_images. #951
+
3.1.3
===
diff --git a/middleman-core/features/markdown_redcarpet.feature b/middleman-core/features/markdown_redcarpet.feature
index 4aa97104..54b8dd30 100644
--- a/middleman-core/features/markdown_redcarpet.feature
+++ b/middleman-core/features/markdown_redcarpet.feature
@@ -42,6 +42,32 @@ Feature: Markdown support
When I go to "/hard_wrap.html"
Then I should see "br"
+ Scenario: Redcarpet 2 no_images extension (with overrides)
+ Given a fixture app "markdown-app"
+ And a file named "config.rb" with:
+ """
+ set :markdown_engine, :redcarpet
+ set :markdown, :no_images => true
+
+ """
+ Given the Server is running at "markdown-app"
+ When I go to "/img.html"
+ Then I should see "![dust mite](http://dust.mite/image.png)"
+ And I should not see " true
+
+ """
+ Given the Server is running at "markdown-app"
+ When I go to "/link.html"
+ Then I should see "[This link](http://example.net/) links"
+ And I should not see "
\ No newline at end of file
diff --git a/middleman-core/fixtures/markdown-app/source/link.html.markdown b/middleman-core/fixtures/markdown-app/source/link.html.markdown
new file mode 100644
index 00000000..a02b95ca
--- /dev/null
+++ b/middleman-core/fixtures/markdown-app/source/link.html.markdown
@@ -0,0 +1 @@
+[This link](http://example.net/) links
\ No newline at end of file
diff --git a/middleman-core/lib/middleman-core/renderers/redcarpet.rb b/middleman-core/lib/middleman-core/renderers/redcarpet.rb
index 86bb8398..6c3616f4 100644
--- a/middleman-core/lib/middleman-core/renderers/redcarpet.rb
+++ b/middleman-core/lib/middleman-core/renderers/redcarpet.rb
@@ -21,7 +21,7 @@ module Middleman
end
# Renderer Options
- possible_render_opts = [:filter_html, :no_images, :no_links, :no_styles, :safe_links_only, :with_toc_data, :hard_wrap, :xhtml]
+ possible_render_opts = [:filter_html, :no_images, :no_links, :no_styles, :safe_links_only, :with_toc_data, :hard_wrap, :xhtml, :prettify, :link_attributes]
render_options = possible_render_opts.inject({}) do |sum, opt|
sum[opt] = options.delete(opt) if options.has_key?(opt)
@@ -36,12 +36,30 @@ module Middleman
class MiddlemanRedcarpetHTML < ::Redcarpet::Render::HTML
cattr_accessor :middleman_app
+ def initialize(options={})
+ @local_options = options.dup
+
+ super
+ end
+
def image(link, title, alt_text)
- middleman_app.image_tag(link, :title => title, :alt => alt_text)
+ if !@local_options[:no_images]
+ middleman_app.image_tag(link, :title => title, :alt => alt_text)
+ else
+ link_string = link.dup
+ link_string << %Q{"#{title}"} if title && title.length > 0 && title != alt_text
+ %Q{![#{alt_text}](#{link_string})}
+ end
end
def link(link, title, content)
- middleman_app.link_to(content, link, :title => title)
+ if !@local_options[:no_links]
+ middleman_app.link_to(content, link, :title => title)
+ else
+ link_string = link.dup
+ link_string << %Q{"#{title}"} if title && title.length > 0 && title != alt_text
+ %Q{[#{content}](#{link_string})}
+ end
end
end