# encoding: utf-8 rootdir = File.dirname(File.dirname(__FILE__)) $LOAD_PATH.unshift "#{rootdir}/lib" require 'test/unit' require 'redcarpet' class RedcarpetTest < Test::Unit::TestCase def test_that_discount_does_not_blow_up_with_weird_formatting_case text = (<<-TEXT).gsub(/^ {4}/, '').rstrip 1. some text 1. TEXT Redcarpet.new(text).to_html end def test_that_smart_converts_double_quotes_to_curly_quotes rd = Redcarpet.new(%("Quoted text"), :smart) assert_equal %(
“Quoted text”
\n), rd.to_html end def test_that_smart_converts_double_quotes_to_curly_quotes_before_a_heading rd = Redcarpet.new(%("Quoted text"\n\n# Heading), :smart) assert_equal %(“Quoted text”
\n\n“Quoted text”
\n), rd.to_html end def test_that_smart_gives_ve_suffix_a_rsquo rd = Redcarpet.new("I've been meaning to tell you ..", :smart) assert_equal "I’ve been meaning to tell you ..
\n", rd.to_html end def test_that_smart_gives_m_suffix_a_rsquo rd = Redcarpet.new("I'm not kidding", :smart) assert_equal "I’m not kidding
\n", rd.to_html end def test_that_smart_gives_d_suffix_a_rsquo rd = Redcarpet.new("what'd you say?", :smart) assert_equal "what’d you say?
\n", rd.to_html end if "".respond_to?(:encoding) def test_should_return_string_in_same_encoding_as_input input = "Yogācāra" output = Redcarpet.new(input).to_html assert_equal input.encoding.name, output.encoding.name end end def test_that_no_image_flag_works rd = Redcarpet.new(%(![dust mite](http://dust.mite/image.png) ), :no_image) assert rd.to_html !~ /links), :no_links) assert rd.to_html !~ /foobarbaz\n", rd.to_html end def test_that_autolink_flag_works rd = Redcarpet.new("http://github.com/rtomayko/rdiscount", :autolink) assert_equal "http://github.com/rtomayko/rdiscount
\n", rd.to_html end def test_that_safelink_flag_works rd = Redcarpet.new("[IRC](irc://chat.freenode.org/#freenode)", :safelink) assert_equal "[IRC](irc://chat.freenode.org/#freenode)
\n", rd.to_html end def test_that_tags_can_have_dashes_and_underscores rd = Redcarpet.new("foofoo
This is a code block\nThis is a link [[1]] inside\n
\n",
markdown.to_html
end
def test_that_generate_toc_sets_toc_ids
rd = Redcarpet.new("# Level 1\n\n## Level 2", :generate_toc)
assert rd.generate_toc
assert_equal %(