Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #119 from gregleaver/issue71

Handle a renderer returning nil from preprocess.
  • Loading branch information...
commit 2a1a189ee3869950733c119a435fafae595eee59 2 parents 4a697cc + 075b2ad
@vmg authored
Showing with 14 additions and 0 deletions.
  1. +2 −0  ext/redcarpet/rc_markdown.c
  2. +12 −0 test/redcarpet_test.rb
View
2  ext/redcarpet/rc_markdown.c
@@ -104,6 +104,8 @@ static VALUE rb_redcarpet_md_render(VALUE self, VALUE text)
if (rb_respond_to(rb_rndr, rb_intern("preprocess")))
text = rb_funcall(rb_rndr, rb_intern("preprocess"), 1, text);
+ if (NIL_P(text))
+ return Qnil;
#ifdef HAVE_RUBY_ENCODING_H
{
View
12 test/redcarpet_test.rb
@@ -328,6 +328,18 @@ def test_simple_overload
html_equal "<p>This is <em class=\"cool\">just</em> a test</p>",
md.render("This is *just* a test")
end
+
+ class NilPreprocessRenderer < Redcarpet::Render::HTML
+ def preprocess(fulldoc)
+ nil
+ end
+ end
+
+ def test_preprocess_returning_nil
+ md = Redcarpet::Markdown.new(NilPreprocessRenderer)
+ assert_equal(nil,md.render("Anything"))
+ end
+
end
class RedcarpetCompatTest < Test::Unit::TestCase
Please sign in to comment.
Something went wrong with that request. Please try again.