foo_bar_baz
' assert_maruku_result md, html assert_github_result md, html end it 'raises InvalidMarkdownError when parsing invalid markdown' do md = '[foo](bar' assert_raises DevcenterParser::InvalidMarkdownError do DevcenterParser.to_html(md, :maruku) end end it 'removes script tags and their content' do md = 'clean' html = 'clean
' assert_maruku_result md, html assert_github_result md, html end it 'allows embedding vimeo videos' do src = <<-SRC SRC assert_github_result src, src end describe 'github markdown' do it 'generates apostrophes from single quotes in plain text' do md = "That's it" html = "That’s it
" assert_github_result(md, html) end it 'generates apostrophes from single quotes in callout|warning|note blocks' do md = <<-MARKDOWN > warning > That's it MARKDOWN html = <<-HTMLThat’s it
Paragraph
$ command
indented
< tag1
> tag2
Another paragraph
HTML assert_maruku_result md, html md = <<-MARKDOWN Paragraph ```term $ command indented < tag1 > tag2 ``` Another paragraph MARKDOWN html = <<-HTMLParagraph
$ command
indented
< tag1
> tag2
Another paragraph
HTML assert_github_result md, html end it 'github markdown supports regular block quotes without callout|warning|note' do md = <<-MARKDOWN Testing > not a callout > **strong** > normal And that's it. MARKDOWN html = <<-HTMLTesting
not a callout strong normal
And that’s it.
HTML assert_github_result(md, html) md = <<-MARKDOWN Testing > calloutnonono > **strong** > normal And that's it. MARKDOWN html = <<-HTMLTesting
calloutnonono strong normal
And that’s it.
HTML assert_github_result(md, html) end it 'github markdown supports "> callout" and ">callout" and parses inner markdown' do mds = [] mds << <<-MARKDOWN Testing > callout > **strong** > normal And that's it. MARKDOWN mds << <<-MARKDOWN Testing >callout >**strong** >normal And that's it. MARKDOWN html = <<-HTMLTesting
strong normal
And that’s it.
HTML mds.each do |md| assert_github_result(md, html) end end it 'github markdown supports "> callout" and ">callout", parses inner markdown and allows paragraphs' do mds = [] mds << <<-MARKDOWN Testing > callout > **strong** > more callout > normal And that's it. MARKDOWN mds << <<-MARKDOWN Testing >callout >**strong** >more callout >normal And that's it. MARKDOWN html = <<-HTMLTesting
strong more callout
normal
And that’s it.
HTML mds.each do |md| assert_github_result(md, html) end end end it 'github markdown generates separate special blocks from blockquotes separated by empty lines' do md = <<-MARKDOWN > warning > foo > note > bar MARKDOWN html = <<-HTMLfoo
bar
A | B |
---|---|
1 | 2 |
3 | 4 |
foo – bar
' assert_all_flavours_result(md, html) end it 'converts relative links with missing initial slashes to article links' do ['foo', 'foo/bar', 'foo#bar', '123'].each do |href| md = "[link](#{href})" html = "" assert_maruku_result md, html assert_github_result md, html end end it 'converts "articles/foo relative links with missing initial slashes to article links' do md = '[link](articles/foo)' html = '' assert_maruku_result md, html assert_github_result md, html md = '[link](articles/foo#bar)' html = '' assert_maruku_result md, html assert_github_result md, html end it 'does not alter relative links with initial slashes nor absolute links nor anchor links to the same doc' do ['http://foo.com', 'https://foo.com', '/foo', '/foo/bar', '/foo#bar', '#foo', '/123', 'mailto:foo@foobar.com'].each do |href| md = "[link](#{href})" html = "" assert_maruku_result md, html assert_github_result md, html end end it 'does not add href attribute to links where it does not exist' do md = '' html = '' assert_maruku_result md, html assert_github_result md, html end it 'generates separate blockquotes from blockquotes separated by empty lines' do md = <<-MARKDOWN > foo > bar MARKDOWN html_maruku = <<-HTMLfoo
HTML assert_maruku_result md, html_maruku html_github = <<-HTMLbar
foo
HTML assert_github_result md, html_github end end # helpers def assert_all_flavours_result(md, expected) [:github, :maruku].each { |flavour| assert_parsing_result(md, flavour, expected) } end def assert_maruku_result(md, expected) assert_parsing_result md, :maruku, expected end def assert_github_result(md, expected) assert_parsing_result md, :github, expected end def assert_parsing_result(md, flavour, expected) result = DevcenterParser.to_html(md, flavour) assert_equal expected.strip, result.strip, "Failed when parsing\n#{md}\nwith the #{flavour} flavour.\n\nExpected:\n#{expected}\n\nActual result:\n#{result}\n\n" end def assert_parsing_unsanitized_result(md, flavour, expected) result = DevcenterParser.to_unsanitized_html(md, flavour) assert_equal expected.strip, result.strip, "Failed when parsing on unsanitized mode\n#{md}\nwith the #{flavour} flavour.\n\nExpected:\n#{expected}\n\nActual result:\n#{result}\n\n" end def assert_header_id(md, header, id) assert DevcenterParser.to_html(md, :github).include?("<#{header} id=\"#{id}\">"), "GitHub does not generate a #{header} with id #{id}" assert DevcenterParser.to_html(md, :maruku).include?("<#{header} id=\"#{id}\">"), "Maruku does not generate a #{header} with id #{id}" end endbar