test/devcenter-parser_test.rb in devcenter-parser-1.2.1 vs test/devcenter-parser_test.rb in devcenter-parser-1.3.1
- old
+ new
@@ -22,161 +22,169 @@
end
it 'respects existing ids' do
md = '<strong id="foo">clean</strong>'
assert_maruku_result md, '<strong id="foo">clean</strong>'
+ assert_github_result md, '<p><strong id="foo">clean</strong></p>'
end
it 'removes script tags and their content' do
md = '<strong>clean<script>alert("hack!")</script></strong>'
assert_maruku_result md, '<strong>clean</strong>'
+ assert_github_result md, '<p><strong>clean</strong></p>'
end
- it 'github markdown includes ids in subheaders' do
+ it 'includes ids in subheaders' do
md = <<-MARKDOWN
## Foo Bar Header 123
Foo bar content
MARKDOWN
assert DevcenterParser.to_html(md, :github).include?('<h2 id="foo-bar-header-123">Foo Bar Header 123</h2>')
+ assert DevcenterParser.to_html(md, :maruku).include?('<h2 id="foo-bar-header-123">Foo Bar Header 123</h2>')
end
- it 'maruku markdown includes ids in subheaders' do
- md = <<-MARKDOWN
-## Foo Bar Header 123
+ it 'generates ids replacing inner non-alphanum chars with dashes' do
+ ['Foo Bar', 'Foo-Bar', 'Foo#bar', 'Foo##Bar', 'Foo##Bar', '-$Foo##Bar$-'].each do |title|
+ md = <<-MARKDOWN
+## #{title}
Foo bar content
- MARKDOWN
- assert DevcenterParser.to_html(md, :maruku).include?('<h2 id="foo-bar-header-123">Foo Bar Header 123</h2>')
+MARKDOWN
+ assert DevcenterParser.to_html(md, :github).include?("<h2 id=\"foo-bar\">#{title}</h2>"), "GitHub with title #{title}: " + DevcenterParser.to_html(md, :github)
+ assert DevcenterParser.to_html(md, :maruku).include?("<h2 id=\"foo-bar\">#{title}</h2>"), "Maruku: " + DevcenterParser.to_html(md, :maruku)
+ end
end
- it 'github markdown supports regular block quotes without callout|warning|note' do
- md = <<-MARKDOWN
+ describe 'github markdown' do
+ 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
+ MARKDOWN
- html = <<-HTML
+ html = <<-HTML
<p>Testing</p>
<blockquote>
<p>not a callout
<strong>strong</strong>
normal</p>
</blockquote>
<p>And that's it.</p>
- HTML
+ HTML
- assert_github_result(md, html)
+ assert_github_result(md, html)
- md = <<-MARKDOWN
+ md = <<-MARKDOWN
Testing
> calloutnonono
> **strong**
> normal
And that's it.
- MARKDOWN
+ MARKDOWN
- html = <<-HTML
+ html = <<-HTML
<p>Testing</p>
<blockquote>
<p>calloutnonono
<strong>strong</strong>
normal</p>
</blockquote>
<p>And that's it.</p>
- HTML
+ HTML
- assert_github_result(md, html)
- end
+ assert_github_result(md, html)
+ end
- it 'github markdown supports "> callout" and ">callout" and parses inner markdown' do
- mds = []
- mds << <<-MARKDOWN
+ it 'github markdown supports "> callout" and ">callout" and parses inner markdown' do
+ mds = []
+ mds << <<-MARKDOWN
Testing
> callout
> **strong**
> normal
And that's it.
- MARKDOWN
+ MARKDOWN
- mds << <<-MARKDOWN
+ mds << <<-MARKDOWN
Testing
>callout
>**strong**
>normal
And that's it.
- MARKDOWN
+ MARKDOWN
- html = <<-HTML
+ html = <<-HTML
<p>Testing</p>
<div class="callout">
<p><strong>strong</strong>
normal</p>
</div>
<p>And that's it.</p>
- HTML
+ HTML
- mds.each do |md|
- assert_github_result(md, html)
+ mds.each do |md|
+ assert_github_result(md, html)
+ end
end
- end
- it 'github markdown supports "> callout" and ">callout", parses inner markdown and allows paragraphs' do
- mds = []
- mds << <<-MARKDOWN
+ it 'github markdown supports "> callout" and ">callout", parses inner markdown and allows paragraphs' do
+ mds = []
+ mds << <<-MARKDOWN
Testing
> callout
> **strong**
> normal
And that's it.
- MARKDOWN
+ MARKDOWN
- mds << <<-MARKDOWN
+ mds << <<-MARKDOWN
Testing
>callout
>**strong**
>normal
And that's it.
- MARKDOWN
+ MARKDOWN
- html = <<-HTML
+ html = <<-HTML
<p>Testing</p>
<div class="callout">
<p><strong>strong</strong></p>
<p>normal</p>
</div>
<p>And that's it.</p>
- HTML
+ HTML
- mds.each do |md|
- assert_github_result(md, html)
+ mds.each do |md|
+ assert_github_result(md, html)
+ end
end
end
it "does emdashes both in all flavours" do
md = "foo -- bar"
@@ -198,9 +206,15 @@
md = "[link](#{href})"
html = "<p><a href=\"#{href}\">link</a></p>"
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 = '<a name="heh"></a>'
+ assert_maruku_result md, md
+ assert_github_result md, "<p>#{md}</p>"
end
end
\ No newline at end of file