redcarpet-3.3.4/ 0000755 0001750 0001750 00000000000 12641446067 013340 5 ustar uwabami uwabami redcarpet-3.3.4/test/ 0000755 0001750 0001750 00000000000 12641446067 014317 5 ustar uwabami uwabami redcarpet-3.3.4/test/redcarpet_compat_test.rb 0000644 0001750 0001750 00000002543 12641446067 021223 0 ustar uwabami uwabami # coding: UTF-8 require 'test_helper' class RedcarpetCompatTest < Redcarpet::TestCase def test_simple_compat_api html = RedcarpetCompat.new("This is_just_a test").to_html assert_equal "
This isjusta test
\n", html end def test_compat_api_enables_extensions html = RedcarpetCompat.new("This is_just_a test", :no_intra_emphasis).to_html assert_equal "This is_just_a test
\n", html end def test_compat_api_knows_fenced_code_extension text = "```ruby\nx = 'foo'\n```" html = RedcarpetCompat.new(text, :fenced_code).to_html assert_equal "x = 'foo'\n
\n", html
end
def test_compat_api_ignores_gh_blockcode_extension
text = "```ruby\nx = 'foo'\n```"
html = RedcarpetCompat.new(text, :fenced_code, :gh_blockcode).to_html
assert_equal "x = 'foo'\n
\n", html
end
def test_compat_api_knows_no_intraemphasis_extension
html = RedcarpetCompat.new("This is_just_a test", :no_intraemphasis).to_html
assert_equal "This is_just_a test
\n", html end def test_translate_outdated_extensions # these extensions are no longer used exts = [:gh_blockcode, :no_tables, :smart, :strict] html = RedcarpetCompat.new('"TEST"', *exts).to_html assert_equal ""TEST"
\n", html end end redcarpet-3.3.4/test/smarty_html_test.rb 0000644 0001750 0001750 00000002612 12641446067 020247 0 ustar uwabami uwabami # coding: UTF-8 require 'test_helper' class SmartyHTMLTest < Redcarpet::TestCase def setup @renderer = Redcarpet::Render::SmartyHTML end def test_that_smartyhtml_converts_single_quotes markdown = render("They're not for sale.") assert_equal "They’re not for sale.
\n", markdown end def test_that_smartyhtml_converts_double_quotes rd = render(%("Quoted text")) assert_equal %(“Quoted text”
\n), rd end def test_that_smartyhtml_converts_double_hyphen rd = render("double hyphen -- ndash") assert_equal "double hyphen – ndash
\n", rd end def test_that_smartyhtml_converts_triple_hyphen rd = render("triple hyphen --- mdash") assert_equal "triple hyphen — mdash
\n", rd end def test_that_smartyhtml_ignores_double_hyphen_in_code rd = render("double hyphen in `--option`") assert_equal "double hyphen in --option
Hello world!
" output = render(markdown) assert_match %r{<}, output end def test_html_escaping_in_code_blocks markdown = "~~~\nHello!
\n~~~" output = render(markdown) assert_match %r{<p>}, output end def test_lang_class_is_removed markdown = "~~~ruby\nclass Foo; end\n~~~" output = render(markdown, with: [:fenced_code_blocks]) assert_not_match %r{ruby}, output end end redcarpet-3.3.4/test/redcarpet_bin_test.rb 0000644 0001750 0001750 00000003234 12641446067 020506 0 ustar uwabami uwabami require 'test_helper' require 'tempfile' class RedcarpetBinTest < Redcarpet::TestCase def setup @fixture_file = Tempfile.new('bin') @fixture_path = @fixture_file.path @fixture_file.write "A ==simple== fixture file -- with " \ "a [link](https://github.com)." @fixture_file.rewind end def teardown @fixture_file.unlink end def test_vanilla_bin run_bin(@fixture_path) expected = "A ==simple== fixture file -- with " \ "a link.
\n" assert_equal expected, @output end def test_enabling_a_parse_option run_bin("--parse", "highlight", @fixture_path) assert_output "" refute_output "==" end def test_enabling_a_render_option run_bin("--render", "no-links", @fixture_path) assert_output "[link]" refute_output "" end def test_enabling_smarty_pants run_bin("--smarty", @fixture_path) assert_output "&ndash" refute_output "--" end def test_version_option run_bin("--version") assert_output "Redcarpet #{Redcarpet::VERSION}" end def test_legacy_option_parsing run_bin("--parse-highlight", "--render-no-links", @fixture_path) assert_output "" refute_output "==" assert_output "[link]" refute_output "" end private def run_bin(*args) bin_path = File.expand_path('../../bin/redcarpet', __FILE__) IO.popen("#{bin_path} #{args.join(" ")}") do |stream| @output = stream.read end end def assert_output(pattern) assert_match pattern, @output end def refute_output(pattern) refute_match Regexp.new(pattern), @output end end redcarpet-3.3.4/test/test_helper.rb 0000644 0001750 0001750 00000001413 12641446067 017161 0 ustar uwabami uwabami # coding: UTF-8 $:.unshift(File.expand_path('../../lib', __FILE__)) Encoding.default_internal = 'UTF-8' require 'test/unit' require 'redcarpet' require 'redcarpet/render_strip' require 'redcarpet/render_man' class Redcarpet::TestCase < Test::Unit::TestCase def assert_renders(html, markdown) assert_equal html, render(markdown) end def render(markdown, options = {}) options = options.fetch(:with, {}) if options.kind_of?(Array) options = Hash[options.map {|o| [o, true]}] end render = begin renderer.new(options) rescue ArgumentError renderer.new end parser = Redcarpet::Markdown.new(render, options) parser.render(markdown) end private def renderer @renderer ||= Redcarpet::Render::HTML end end redcarpet-3.3.4/test/fixtures/ 0000755 0001750 0001750 00000000000 12641446067 016170 5 ustar uwabami uwabami redcarpet-3.3.4/test/fixtures/benchmark.md 0000644 0001750 0001750 00000020053 12641446067 020444 0 ustar uwabami uwabami Download -------- [Markdown 1.0.1][dl] (18 KB) -- 17 Dec 2004 [dl]: http://daringfireball.net/projects/downloads/Markdown_1.0.1.zip Introduction ------------ Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML). Thus, "Markdown" is two things: (1) a plain text formatting syntax; and (2) a software tool, written in Perl, that converts the plain text formatting to HTML. See the [Syntax][] page for details pertaining to Markdown's formatting syntax. You can try it out, right now, using the online [Dingus][]. [syntax]: /projects/markdown/syntax [dingus]: /projects/markdown/dingus The overriding design goal for Markdown's formatting syntax is to make it as readable as possible. The idea is that a Markdown-formatted document should be publishable as-is, as plain text, without looking like it's been marked up with tags or formatting instructions. While Markdown's syntax has been influenced by several existing text-to-HTML filters, the single biggest source of inspiration for Markdown's syntax is the format of plain text email. The best way to get a feel for Markdown's formatting syntax is simply to look at a Markdown-formatted document. For example, you can view the Markdown source for the article text on this page here:Hello World.
\n", @markdown.render("Hello World.") end def test_that_inline_markdown_goes_to_html markdown = @markdown.render('_Hello World_!') assert_equal "Hello World!
\n", markdown end def test_that_inline_markdown_starts_and_ends_correctly markdown = render_with({:no_intra_emphasis => true}, '_start _ foo_bar bar_baz _ end_ *italic* **bold** _blah_') assert_equal "start _ foo_bar bar_baz _ end italic bold blah
\n", markdown markdown = @markdown.render("Run 'rake radiant:extensions:rbac_base:migrate'") assert_equal "Run 'rake radiant:extensions:rbac_base:migrate'
\n", markdown end def test_that_urls_are_not_doubly_escaped markdown = @markdown.render('[Page 2](/search?query=Markdown+Test&page=2)') assert_equal "\n", markdown end def test_simple_inline_html #markdown = Markdown.new("before\n\nbefore
\n\nafter
\n", markdown end def test_that_html_blocks_do_not_require_their_own_end_tag_line markdown = @markdown.render("Para 1\n\nHTML block\n
Para 1
\n\nHTML block\n
Para 2 Link
\n", markdown end # This isn't in the spec but is Markdown.pl behavior. def test_block_quotes_preceded_by_spaces markdown = @markdown.render( "A wise man once said:\n\n" + " > Isn't it wonderful just to be alive.\n" ) assert_equal "A wise man once said:
\n\n" + "\n\n", markdown end def test_para_before_block_html_should_not_wrap_in_p_tag markdown = render_with({:lax_spacing => true}, "Things to watch out for\n" + "Isn't it wonderful just to be alive.
\n
Things to watch out for
\n\n" + "This paragraph is not part of the list.
HTML assert_equal expected, @markdown.render(text) end # http://github.com/rtomayko/rdiscount/issues/#issue/13 def test_headings_with_trailing_space text = "The Ant-Sugar Tales \n" + "=================== \n\n" + "By Candice Yellowflower \n" assert_equal "By Candice Yellowflower
\n", @markdown.render(text) end def test_that_intra_emphasis_works rd = render_with({}, "foo_bar_baz") assert_equal "foobarbaz
\n", rd rd = render_with({:no_intra_emphasis => true},"foo_bar_baz") assert_equal "foo_bar_baz
\n", rd end def test_that_autolink_flag_works rd = render_with({:autolink => true}, "http://github.com/rtomayko/rdiscount") assert_equal "http://github.com/rtomayko/rdiscount
\n", rd end def test_that_tags_can_have_dashes_and_underscores rd = @markdown.render("foofoo
This is a code block\nThis is a link [[1]] inside\n
\n",
markdown
end
def test_whitespace_after_urls
rd = render_with({:autolink => true}, "Japan: http://www.abc.net.au/news/events/japan-quake-2011/beforeafter.htm (yes, japan)")
exp = %{Japan: http://www.abc.net.au/news/events/japan-quake-2011/beforeafter.htm (yes, japan)
\n} assert_equal exp, rd end def test_memory_leak_when_parsing_char_links @markdown.render(<<-leaks) 2. Identify the wild-type cluster and determine all clusters containing or contained by it: wildtype <- wildtype.cluster(h) wildtype.mask <- logical(nclust) wildtype.mask[c(contains(h, wildtype), wildtype, contained.by(h, wildtype))] <- TRUE This could be more elegant. leaks end def test_infinite_loop_in_header assert_equal "-
\n", @markdown.render("-") assert_equal "=
\n", @markdown.render("=") end def test_that_tables_flag_works text = <