redcarpet-3.3.4/0000755000175000017500000000000012641446067013340 5ustar uwabamiuwabamiredcarpet-3.3.4/test/0000755000175000017500000000000012641446067014317 5ustar uwabamiuwabamiredcarpet-3.3.4/test/redcarpet_compat_test.rb0000644000175000017500000000254312641446067021223 0ustar uwabamiuwabami# 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.rb0000644000175000017500000000261212641446067020247 0ustar uwabamiuwabami# 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

\n", rd end def test_that_smartyhtml_ignores_pre rd = render(" It's a test of \"pre\"\n") expected = "It's a test of "pre"" assert rd.include?(expected), "\"#{rd}\" should contain \"#{expected}\"" end def test_that_smartyhtml_ignores_code rd = render("`It's a test of \"code\"`\n") expected = "It's a test of "code"" assert rd.include?(expected), "\"#{rd}\" should contain \"#{expected}\"" end end redcarpet-3.3.4/test/safe_render_test.rb0000644000175000017500000000144712641446067020166 0ustar uwabamiuwabamirequire 'test_helper' class SafeRenderTest < Redcarpet::TestCase def setup @renderer = Redcarpet::Render::Safe end def test_safe_links_only_is_enabled_by_default markdown = "[foo](javascript:alert('foo'))" output = render(markdown) assert_not_match %r{a href}, output end def test_escape_html_is_enabled_by_default markdown = "

Hello world!

" output = render(markdown) assert_match %r{<}, output end def test_html_escaping_in_code_blocks markdown = "~~~\n

Hello!

\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.rb0000644000175000017500000000323412641446067020506 0ustar uwabamiuwabamirequire '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.rb0000644000175000017500000000141312641446067017161 0ustar uwabamiuwabami# 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/0000755000175000017500000000000012641446067016170 5ustar uwabamiuwabamiredcarpet-3.3.4/test/fixtures/benchmark.md0000644000175000017500000002005312641446067020444 0ustar uwabamiuwabamiDownload -------- [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: (You can use this '.text' suffix trick to view the Markdown source for the content of each of the pages in this section, e.g. the [Syntax][s_src] and [License][l_src] pages.) [s_src]: /projects/markdown/syntax.text [l_src]: /projects/markdown/license.text Markdown is free software, available under a BSD-style open source license. See the [License] [pl] page for more information. [pl]: /projects/markdown/license Discussion List --------------- I've set up a public [mailing list for discussion about Markdown] [ml]. Any topic related to Markdown -- both its formatting syntax and its software -- is fair game for discussion. Anyone who is interested is welcome to join. It's my hope that the mailing list will lead to good ideas for future improvements to Markdown. [ml]: http://six.pairlist.net/mailman/listinfo/markdown-discuss Installation and Requirements ----------------------------- Markdown requires Perl 5.6.0 or later. Welcome to the 21st Century. Markdown also requires the standard Perl library module [Digest::MD5] [md5], which is probably already installed on your server. [md5]: http://search.cpan.org/dist/Digest-MD5/MD5.pm ### Movable Type ### Markdown works with Movable Type version 2.6 or later (including Movable Type 3.0). 1. Copy the "Markdown.pl" file into your Movable Type "plugins" directory. The "plugins" directory should be in the same directory as "mt.cgi"; if the "plugins" directory doesn't already exist, use your FTP program to create it. Your installation should look like this: (mt home)/plugins/Markdown.pl 2. Once installed, Markdown will appear as an option in Movable Type's Text Formatting pop-up menu. This is selectable on a per-post basis: ![Screenshot of Movable Type 'Text Formatting' Menu][tfmenu] Markdown translates your posts to HTML when you publish; the posts themselves are stored in your MT database in Markdown format. 3. If you also install SmartyPants 1.5 (or later), Markdown will offer a second text formatting option: "Markdown With SmartyPants". This option is the same as the regular "Markdown" formatter, except that it automatically uses SmartyPants to create typographically correct curly quotes, em-dashes, and ellipses. See the [SmartyPants web page][sp] for more information. 4. To make Markdown (or "Markdown With SmartyPants") your default text formatting option for new posts, go to Weblog Config: Preferences. Note that by default, Markdown produces XHTML output. To configure Markdown to produce HTML 4 output, see "Configuration", below. [sp]: http://daringfireball.net/projects/smartypants/ ### Blosxom ### Markdown works with Blosxom version 2.0 or later. 1. Rename the "Markdown.pl" plug-in to "Markdown" (case is important). Movable Type requires plug-ins to have a ".pl" extension; Blosxom forbids it. 2. Copy the "Markdown" plug-in file to your Blosxom plug-ins folder. If you're not sure where your Blosxom plug-ins folder is, see the Blosxom documentation for information. 3. That's it. The entries in your weblog will now automatically be processed by Markdown. 4. If you'd like to apply Markdown formatting only to certain posts, rather than all of them, Markdown can optionally be used in conjunction with Blosxom's [Meta][] plug-in. First, install the Meta plug-in. Next, open the Markdown plug-in file in a text editor, and set the configuration variable `$g_blosxom_use_meta` to 1. Then, simply include a "`meta-markup: Markdown`" header line at the top of each post you compose using Markdown. [meta]: http://www.blosxom.com/plugins/meta/meta.htm ### BBEdit ### Markdown works with BBEdit 6.1 or later on Mac OS X. It also works with BBEdit 5.1 or later and MacPerl 5.6.1 on Mac OS 8.6 or later. If you're running Mac OS X 10.2 (Jaguar), you may need to install the Perl module [Digest::MD5] [md5] from CPAN; Digest::MD5 comes pre-installed on Mac OS X 10.3 (Panther). 1. Copy the "Markdown.pl" file to appropriate filters folder in your "BBEdit Support" folder. On Mac OS X, this should be: BBEdit Support/Unix Support/Unix Filters/ See the BBEdit documentation for more details on the location of these folders. You can rename "Markdown.pl" to whatever you wish. 2. That's it. To use Markdown, select some text in a BBEdit document, then choose Markdown from the Filters sub-menu in the "#!" menu, or the Filters floating palette Configuration ------------- By default, Markdown produces XHTML output for tags with empty elements. E.g.:
Markdown can be configured to produce HTML-style tags; e.g.:
### Movable Type ### You need to use a special `MTMarkdownOptions` container tag in each Movable Type template where you want HTML 4-style output: ... put your entry content here ... The easiest way to use MTMarkdownOptions is probably to put the opening tag right after your `` tag, and the closing tag right before ``. To suppress Markdown processing in a particular template, i.e. to publish the raw Markdown-formatted text without translation into (X)HTML, set the `output` attribute to 'raw': ... put your entry content here ... ### Command-Line ### Use the `--html4tags` command-line switch to produce HTML output from a Unix-style command line. E.g.: % perl Markdown.pl --html4tags foo.text Type `perldoc Markdown.pl`, or read the POD documentation within the Markdown.pl source code for more information. Acknowledgements ---------------- [Aaron Swartz][] deserves a tremendous amount of credit for his feedback on the design of Markdown's formatting syntax. Markdown is *much* better thanks to Aaron's ideas, feedback, and testing. Also, Aaron's [html2text][] is a very handy (and free) utility for turning HTML into Markdown-formatted plain text. [Nathaniel Irons][], [Dan Benjamin][], [Daniel Bogan][], and [Jason Perkins][] also deserve thanks for their feedback. [Michel Fortin][] has ported Markdown to PHP; it's a splendid port, and highly recommended for anyone looking for a PHP implementation of Markdown. [Aaron Swartz]: http://www.aaronsw.com/ [Nathaniel Irons]: http://bumppo.net/ [Dan Benjamin]: http://hivelogic.com/ [Daniel Bogan]: http://waferbaby.com/ [Jason Perkins]: http://pressedpants.com/ [Michel Fortin]: http://www.michelf.com/projects/php-markdown/ [html2text]: http://www.aaronsw.com/2002/html2text/ [tfmenu]: /graphics/markdown/mt_textformat_menu.png redcarpet-3.3.4/test/markdown_test.rb0000644000175000017500000002777112641446067017543 0ustar uwabamiuwabami# coding: UTF-8 require 'test_helper' class MarkdownTest < Redcarpet::TestCase def setup @markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML) end def render_with(flags, text) Redcarpet::Markdown.new(Redcarpet::Render::HTML, flags).render(text) end def test_that_simple_one_liner_goes_to_html assert_respond_to @markdown, :render assert_equal "

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 "

Page 2

\n", markdown end def test_simple_inline_html #markdown = Markdown.new("before\n\n
\n foo\n
\nafter") markdown = @markdown.render("before\n\n
\n foo\n
\n\nafter") assert_equal "

before

\n\n
\n foo\n
\n\n

after

\n", markdown end def test_that_html_blocks_do_not_require_their_own_end_tag_line markdown = @markdown.render("Para 1\n\n
HTML block\n
\n\nPara 2 [Link](#anchor)") assert_equal "

Para 1

\n\n
HTML block\n
\n\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

Isn't it wonderful just to be alive.

\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" + "
    \n
  • Blah
  • \n
\n") assert_equal "

Things to watch out for

\n\n" + "
    \n
  • Blah
  • \n
\n", markdown end # https://github.com/vmg/redcarpet/issues/111 def test_p_with_less_than_4space_indent_should_not_be_part_of_last_list_item text = <
  • a
  • b
  • c
  • 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 "

    The Ant-Sugar Tales

    \n\n

    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("foo bar and baz") assert_equal "

    foo bar and baz

    \n", rd end def test_link_syntax_is_not_processed_within_code_blocks markdown = @markdown.render(" This is a code block\n This is a link [[1]] inside\n") assert_equal "
    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 "

    Body

    \n", @markdown.render(<<-header) ###### #Body# ###### header end def test_a_hyphen_and_a_equal_should_not_be_converted_to_heading assert_equal "

    -

    \n", @markdown.render("-") assert_equal "

    =

    \n", @markdown.render("=") end def test_that_tables_flag_works text = < true}, text) =~ / true}, text) =~ /
    true}, text) =~ /underlined' output = render_with({:underline => true}, text) assert output.include? 'underlined' assert output.include? 'some' end def test_highlight_flag_works text = "this is ==highlighted==" refute render_with({}, text).include? 'highlighted' output = render_with({:highlight => true}, text) assert output.include? 'highlighted' end def test_quote_flag_works text = 'this is "quote"' refute render_with({}, text).include? 'quote' output = render_with({:quote => true}, text) assert output.include? 'quote' end def test_that_fenced_flag_works text = < true}, text) =~ / true, :lax_spacing => true).render(text) assert out.include?("
    ")
    
        out = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :fenced_code_blocks => true).render(text)
        assert !out.include?("
    ")
      end
    
      def test_that_indented_code_preserves_references
        text = < true).render(text)
        assert out.include?("[1]: http://google.com")
      end
    
      def test_that_fenced_flag_preserves_references
        text = < true).render(text)
        assert out.include?("[1]: http://google.com")
      end
    
      def test_that_fenced_code_copies_language_verbatim_with_braces
        text = "```{rust,no_run}\nx = 'foo'\n```"
        html = render_with({:fenced_code_blocks => true}, text)
        assert_equal "
    x = 'foo'\n
    \n", html end def test_that_fenced_code_copies_language_verbatim text = "```rust,no_run\nx = 'foo'\n```" html = render_with({:fenced_code_blocks => true}, text) assert_equal "
    x = 'foo'\n
    \n", html end def test_that_indented_flag_works text = < true}, text) !~ /Hello GitHub\n", markdown end def test_autolinking_with_ent_chars markdown = render_with({:autolink => true}, <This a stupid link: https://github.com/rtomayko/tilt/issues?milestone=1&state=open

    \n", markdown end def test_spaced_headers rd = render_with({:space_after_headers => true}, "#123 a header yes\n") assert rd !~ /

    / end def test_proper_intra_emphasis assert render_with({:no_intra_emphasis => true}, "http://en.wikipedia.org/wiki/Dave_Allen_(comedian)") !~ // assert render_with({:no_intra_emphasis => true}, "this fails: hello_world_") !~ // assert render_with({:no_intra_emphasis => true}, "this also fails: hello_world_#bye") !~ // assert render_with({:no_intra_emphasis => true}, "this works: hello_my_world") !~ // assert render_with({:no_intra_emphasis => true}, "句中**粗體**測試") =~ // markdown = "This is (**bold**) and this_is_not_italic!" html = "

    This is (bold) and this_is_not_italic!

    \n" assert_equal html, render_with({:no_intra_emphasis => true}, markdown) markdown = "This is \"**bold**\"" html = "

    This is "bold"

    \n" assert_equal html, render_with({:no_intra_emphasis => true}, markdown) end def test_emphasis_escaping markdown = @markdown.render("**foo\\*** _dd\\_dd_") assert_equal "

    foo* dd_dd

    \n", markdown end def test_char_escaping_when_highlighting markdown = "==attribute\\===" output = render_with({highlight: true}, markdown) assert_equal "

    attribute=

    \n", output end def test_ordered_lists_with_lax_spacing markdown = "Foo:\n1. Foo\n2. Bar" output = render_with({lax_spacing: true}, markdown) assert_match /
      /, output assert_match /
    1. Foo<\/li>/, output end def test_references_with_tabs_after_colon markdown = @markdown.render("[Link][id]\n[id]:\t\t\thttp://google.es") assert_equal "

      Link

      \n", markdown end def test_superscript markdown = render_with({:superscript => true}, "this is the 2^nd time") assert_equal "

      this is the 2nd time

      \n", markdown end def test_superscript_enclosed_in_parenthesis markdown = render_with({:superscript => true}, "this is the 2^(nd) time") assert_equal "

      this is the 2nd time

      \n", markdown end def test_no_rewind_into_previous_inline result = "

      !dl1@danlec.com

      \n" output = render("_!dl_1@danlec.com", with: [:autolink]) assert_equal result, output result = "

      abc123www.foo.com@foo.com

      \n" output = render("abc123_www.foo.com_@foo.com", with: [:autolink]) assert_equal result, output end end redcarpet-3.3.4/test/html_render_test.rb0000644000175000017500000001541712641446067020216 0ustar uwabamiuwabami# coding: UTF-8 require 'test_helper' class HTMLRenderTest < Redcarpet::TestCase def setup @renderer = Redcarpet::Render::HTML end # Hint: overrides filter_html, no_images and no_links def test_that_escape_html_works source = <NO
      EOS expected = <Through <em>NO</em> <script>DOUBLE NO</script>

      <script>BAD</script>

      <img src="/favicon.ico" />

      EOE assert_equal expected, render(source, with: [:escape_html]) end def test_that_filter_html_works markdown = 'Through NO ' output = render(markdown, with: [:filter_html]) assert_equal "

      Through NO DOUBLE NO

      \n", output end def test_filter_html_doesnt_break_two_space_hard_break markdown = "Lorem, \nipsum\n" output = render(markdown, with: [:filter_html]) assert_equal "

      Lorem,
      \nipsum

      \n", output end def test_that_no_image_flag_works markdown = %(![dust mite](http://dust.mite/image.png) ) output = render(markdown, with: [:no_images]) assert_no_match %r{links) output = render(markdown, with: [:no_links]) assert_no_match %r{[IRC](irc://chat.freenode.org/#freenode)

      \n", output end def test_that_hard_wrap_works markdown = <}, output end def test_that_link_attributes_work rndr = Redcarpet::Render::HTML.new(:link_attributes => {:rel => 'blank'}) md = Redcarpet::Markdown.new(rndr) assert md.render('This is a [simple](http://test.com) test.').include?('rel="blank"') end def test_that_link_works_with_quotes markdown = %([This'link"is](http://example.net/)) expected = %(

      This'link"is

      \n) assert_equal expected, render(markdown) assert_equal expected, render(markdown, with: [:escape_html]) end def test_that_code_emphasis_work markdown = <<-MD This should be **`a bold codespan`** However, this should be *`an emphasised codespan`* * **`ABC`** or **`DEF`** * Foo bar MD html = <This should be a bold codespan However, this should be an emphasised codespan

      • ABC or DEF
      • Foo bar
      HTML assert_equal html, render(markdown) end def test_that_parenthesis_are_handled_into_links markdown = %(The [bash man page](man:bash(1))!) expected = %(

      The bash man page!

      \n) assert_equal expected, render(markdown) end def test_autolinking_works_as_expected markdown = "Uri ftp://user:pass@example.com/. Email foo@bar.com and link http://bar.com" output = render(markdown, with: [:autolink]) assert output.include? 'ftp://user:pass@example.com/' assert output.include? 'mailto:foo@bar.com' assert output.include? '' end def test_that_footnotes_work markdown = <<-MD This is a footnote.[^1] [^1]: It provides additional information. MD html = <This is a footnote.1


      1. It provides additional information. 

      HTML output = render(markdown, with: [:footnotes]) assert_equal html, output end def test_footnotes_enabled_but_missing_marker markdown = <Some text without a marker

      [^1] And a trailing definition

      HTML output = render(markdown, with: [:footnotes]) assert_equal html, output end def test_footnotes_enabled_but_missing_definition markdown = "Some text with a marker[^1] but no definition." expected = "

      Some text with a marker[^1] but no definition.

      \n" output = render(markdown, with: [:footnotes]) assert_equal expected, output end def test_autolink_short_domains markdown = "Example of uri ftp://auto/short/domains. Email auto@l.n and link http://a/u/t/o/s/h/o/r/t" output = render(markdown, with: [:autolink]) assert output.include? 'ftp://auto/short/domains' assert output.include? 'mailto:auto@l.n' assert output.include? 'http://a/u/t/o/s/h/o/r/t' end def test_that_prettify_works markdown = "\tclass Foo\nend" output = render(markdown, with: [:prettify]) assert output.include?("
      ")
      
          markdown = "`class`"
          output   = render(markdown, with: [:prettify])
      
          assert output.include?("")
        end
      
        def test_prettify_with_fenced_code_blocks
          markdown = "~~~ruby\ncode\n~~~"
          output   = render(markdown, with: [:fenced_code_blocks, :prettify])
      
          assert output.include?("")
        end
      
        def test_safe_links_only_with_anchors
          markdown = "An [anchor link](#anchor) on a page."
          output   = render(markdown, with: [:safe_links_only])
      
          assert_match %r{anchor link}, output
        end
      
        def test_autolink_with_link_attributes
          options = { autolink: true, link_attributes: {rel: "nofollow"} }
          output  = render("https://github.com/", with: options)
      
          assert_match %r{rel="nofollow"}, output
        end
      
        def test_image_unsafe_src_with_safe_links_only
          markdown = "![foo](javascript:while(1);)"
          output   = render(markdown, with: [:safe_links_only])
      
          assert_not_match %r{img src}, output
        end
      
        def test_no_styles_option_inside_a_paragraph
          markdown = "Hello  !"
          output   = render(markdown, with: [:no_styles])
      
          assert_no_match %r{"
          output   = render(markdown, with: [:no_styles])
      
          assert_no_match %r{