Failing tests (extra new lines) with libxml2 > 2.8 #210

strzibny opened this Issue Mar 14, 2013 · 2 comments

2 participants



apparently redcarpet currently fails both on Ruby 1.9.3 and Ruby 2.0 regarding of adding/handling new lines (\n):

$ git clone git://
$ cd redcarpet/
$ rake test
mkdir -p tmp/x86_64-linux/redcarpet/1.9.3
cd tmp/x86_64-linux/redcarpet/1.9.3
/usr/bin/ruby -I. ../../../../ext/redcarpet/extconf.rb
creating Makefile
cd -
cd tmp/x86_64-linux/redcarpet/1.9.3
gcc -I. -I/usr/include/x86_64-linux -I/usr/include/ruby/backward -I/usr/include -I../../../../ext/redcarpet   -fPIC -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -mtune=generic -fPIC -m64 -o rc_markdown.o -c ../../../../ext/redcarpet/rc_markdown.c
../../../../ext/redcarpet/rc_markdown.c: In function ‘rb_redcarpet_md_render’:
../../../../ext/redcarpet/rc_markdown.c:126:3: warning: pointer targets in passing argument 2 of ‘sd_markdown_render’ differ in signedness [-Wpointer-sign]
In file included from ../../../../ext/redcarpet/redcarpet.h:15:0,
                 from ../../../../ext/redcarpet/rc_markdown.c:16:
../../../../ext/redcarpet/markdown.h:124:1: note: expected ‘const uint8_t *’ but argument is of type ‘char *’
../../../../ext/redcarpet/rc_markdown.c:129:2: warning: pointer targets in passing argument 1 of ‘rb_enc_str_new’ differ in signedness [-Wpointer-sign]
In file included from ../../../../ext/redcarpet/redcarpet.h:9:0,
                 from ../../../../ext/redcarpet/rc_markdown.c:16:

(compilation continues...)

Run options: 

# Running tests:


Finished tests in 0.017176s, 2852.8269 tests/s, 3318.5945 assertions/s.

  1) Failure:
test_simple_overload(CustomRenderTest) [test/redcarpet_test.rb:15]:
<"<p>This is <em class=\"cool\">just</em> a test</p>"> expected but was
<"<p>This is <em class=\"cool\">just</em> a test</p>\n">.

  2) Failure:
test_that_escape_html_works(HTMLRenderTest) [test/redcarpet_test.rb:15]:
<"<p>Through &lt;em&gt;NO&lt;/em&gt; &lt;script&gt;DOUBLE NO&lt;/script&gt;</p>\n\n<p>&lt;script&gt;BAD&lt;/script&gt;</p>\n\n<p>&lt;img src=\"/favicon.ico\" /&gt;\n\n</p>"> expected but was
<"<p>Through &lt;em&gt;NO&lt;/em&gt; &lt;script&gt;DOUBLE NO&lt;/script&gt;</p>\n\n<p>&lt;script&gt;BAD&lt;/script&gt;</p>\n\n<p>&lt;img src=\"/favicon.ico\" /&gt;</p>\n">.

  3) Failure:
test_that_filter_html_works(HTMLRenderTest) [test/redcarpet_test.rb:15]:
<"<p>Through NO DOUBLE NO</p>"> expected but was
<"<p>Through NO DOUBLE NO</p>\n">.

  4) Failure:
test_infinite_loop_in_header(MarkdownTest) [test/redcarpet_test.rb:15]:
<"<h1>Body</h1>\n"> expected but was

  5) Failure:
test_that_headers_are_linkable(MarkdownTest) [test/redcarpet_test.rb:15]:
<"<h3>Hello <a href=\"\">GitHub</a>\n</h3>"> expected but was
<"<h3>Hello <a href=\"\">GitHub</a>\n</h3>\n">.

  6) Failure:
test_that_inline_markdown_goes_to_html(MarkdownTest) [test/redcarpet_test.rb:15]:
<"<p><em>Hello World</em>!</p>"> expected but was
<"<p><em>Hello World</em>!</p>\n">.

  7) Failure:
test_that_inline_markdown_starts_and_ends_correctly(MarkdownTest) [test/redcarpet_test.rb:15]:
<"<p><em>start _ foo_bar bar_baz _ end</em> <em>italic</em> <strong>bold</strong> <a><em>blah</em></a></p>"> expected but was
<"<p><em>start _ foo_bar bar_baz _ end</em> <em>italic</em> <strong>bold</strong> <a><em>blah</em></a></p>\n">.

  8) Failure:
test_that_simple_one_liner_goes_to_html(MarkdownTest) [test/redcarpet_test.rb:15]:
<"<p>Hello World.</p>"> expected but was
<"<p>Hello World.</p>\n">.

  9) Failure:
test_whitespace_after_urls(MarkdownTest) [test/redcarpet_test.rb:15]:
<"<p>Japan: <a href=\"\"></a> (yes, japan)</p>"> expected but was
<"<p>Japan: <a href=\"\"></a> (yes, japan)</p>\n">.

 10) Failure:
test_compat_api_enables_extensions(RedcarpetCompatTest) [test/redcarpet_test.rb:15]:
<"<p>This is_just_a test</p>"> expected but was
<"<p>This is_just_a test</p>\n">.

 11) Failure:
test_compat_api_ignores_gh_blockcode_extension(RedcarpetCompatTest) [test/redcarpet_test.rb:15]:
<"<pre><code class=\"ruby\">x = 'foo'\n</code></pre>"> expected but was
<"<pre><code class=\"ruby\">x = 'foo'\n</code></pre>\n">.

 12) Failure:
test_compat_api_knows_fenced_code_extension(RedcarpetCompatTest) [test/redcarpet_test.rb:15]:
<"<pre><code class=\"ruby\">x = 'foo'\n</code></pre>"> expected but was
<"<pre><code class=\"ruby\">x = 'foo'\n</code></pre>\n">.

 13) Failure:
test_compat_api_knows_no_intraemphasis_extension(RedcarpetCompatTest) [test/redcarpet_test.rb:15]:
<"<p>This is_just_a test</p>"> expected but was
<"<p>This is_just_a test</p>\n">.

 14) Failure:
test_simple_compat_api(RedcarpetCompatTest) [test/redcarpet_test.rb:15]:
<"<p>This is<em>just</em>a test</p>"> expected but was
<"<p>This is<em>just</em>a test</p>\n">.

 15) Failure:
test_translate_outdated_extensions(RedcarpetCompatTest) [test/redcarpet_test.rb:15]:
<"<p>\"TEST\"</p>"> expected but was

49 tests, 57 assertions, 15 failures, 0 errors, 0 skips

This is also true for already released versions 2.1.1 and 2.2.2.

Note: Failure no. 4 is written in the bad order, so it actually doesn't expect new line, but adds one (like with the other tests).


I investigated the issue more deeply and found out that redcarpet behaves the same regardless of Ruby version. The problem actually lies in libxml2 behind Nokogiri. Since version 2.8 it does not strip new lines after a successfully closed tag <p>A</p>\n as it did in 2.7.8. I suggest that these tests should be changed accordingly.


Since #211 has been closed, I think we can close this. Let me know if I should reopen it. Thanks.

@robin850 robin850 closed this Mar 27, 2013
This was referenced Apr 15, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment