html-pipeline 2.4.1 → 2.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +15 -4
- data/Appraisals +13 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +2 -1
- data/Rakefile +4 -1
- data/html-pipeline.gemspec +2 -3
- data/lib/html/pipeline/emoji_filter.rb +22 -1
- data/lib/html/pipeline/version.rb +1 -1
- metadata +4 -46
- data/script/changelog +0 -47
- data/script/package +0 -7
- data/script/release +0 -16
- data/test/helpers/mocked_instrumentation_service.rb +0 -17
- data/test/html/pipeline/absolute_source_filter_test.rb +0 -55
- data/test/html/pipeline/autolink_filter_test.rb +0 -35
- data/test/html/pipeline/camo_filter_test.rb +0 -77
- data/test/html/pipeline/email_reply_filter_test.rb +0 -66
- data/test/html/pipeline/emoji_filter_test.rb +0 -65
- data/test/html/pipeline/https_filter_test.rb +0 -53
- data/test/html/pipeline/image_filter_test.rb +0 -39
- data/test/html/pipeline/image_max_width_filter_test.rb +0 -50
- data/test/html/pipeline/markdown_filter_test.rb +0 -101
- data/test/html/pipeline/mention_filter_test.rb +0 -212
- data/test/html/pipeline/plain_text_input_filter_test.rb +0 -22
- data/test/html/pipeline/sanitization_filter_test.rb +0 -166
- data/test/html/pipeline/syntax_highlight_filter_test.rb +0 -22
- data/test/html/pipeline/toc_filter_test.rb +0 -134
- data/test/html/pipeline_test.rb +0 -74
- data/test/test_helper.rb +0 -16
@@ -1,77 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class HTML::Pipeline::CamoFilterTest < Minitest::Test
|
4
|
-
CamoFilter = HTML::Pipeline::CamoFilter
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@asset_proxy_url = 'https//assets.example.org'
|
8
|
-
@asset_proxy_secret_key = 'ssssh-secret'
|
9
|
-
@options = {
|
10
|
-
:asset_proxy => @asset_proxy_url,
|
11
|
-
:asset_proxy_secret_key => @asset_proxy_secret_key,
|
12
|
-
:asset_proxy_whitelist => [/(^|\.)github\.com$/]
|
13
|
-
}
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_asset_proxy_disabled
|
17
|
-
orig = %(<p><img src="http://twitter.com/img.png"></p>)
|
18
|
-
assert_equal orig,
|
19
|
-
CamoFilter.call(orig, @options.merge(:disable_asset_proxy => true)).to_s
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_camouflaging_http_image_urls
|
23
|
-
orig = %(<p><img src="http://twitter.com/img.png"></p>)
|
24
|
-
assert_equal %(<p><img src="https//assets.example.org/a5ad43494e343b20d745586282be61ff530e6fa0/687474703a2f2f747769747465722e636f6d2f696d672e706e67" data-canonical-src="http://twitter.com/img.png"></p>),
|
25
|
-
CamoFilter.call(orig, @options).to_s
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_doesnt_rewrite_dotcom_image_urls
|
29
|
-
orig = %(<p><img src="https://github.com/img.png"></p>)
|
30
|
-
assert_equal orig, CamoFilter.call(orig, @options).to_s
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_doesnt_rewrite_dotcom_subdomain_image_urls
|
34
|
-
orig = %(<p><img src="https://raw.github.com/img.png"></p>)
|
35
|
-
assert_equal orig, CamoFilter.call(orig, @options).to_s
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_doesnt_rewrite_dotcom_subsubdomain_image_urls
|
39
|
-
orig = %(<p><img src="https://f.assets.github.com/img.png"></p>)
|
40
|
-
assert_equal orig, CamoFilter.call(orig, @options).to_s
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_camouflaging_github_prefixed_image_urls
|
44
|
-
orig = %(<p><img src="https://notgithub.com/img.png"></p>)
|
45
|
-
assert_equal %(<p><img src="https//assets.example.org/5d4a96c69713f850520538e04cb9661035cfb534/68747470733a2f2f6e6f746769746875622e636f6d2f696d672e706e67" data-canonical-src="https://notgithub.com/img.png"></p>),
|
46
|
-
CamoFilter.call(orig, @options).to_s
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_doesnt_rewrite_absolute_image_urls
|
50
|
-
orig = %(<p><img src="/img.png"></p>)
|
51
|
-
assert_equal orig, CamoFilter.call(orig, @options).to_s
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_doesnt_rewrite_relative_image_urls
|
55
|
-
orig = %(<p><img src="img.png"></p>)
|
56
|
-
assert_equal orig, CamoFilter.call(orig, @options).to_s
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_camouflaging_https_image_urls
|
60
|
-
orig = %(<p><img src="https://foo.com/img.png"></p>)
|
61
|
-
assert_equal %(<p><img src="https//assets.example.org/3c5c6dc74fd6592d2596209dfcb8b7e5461383c8/68747470733a2f2f666f6f2e636f6d2f696d672e706e67" data-canonical-src="https://foo.com/img.png"></p>),
|
62
|
-
CamoFilter.call(orig, @options).to_s
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_handling_images_with_no_src_attribute
|
66
|
-
orig = %(<p><img></p>)
|
67
|
-
assert_equal orig, CamoFilter.call(orig, @options).to_s
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_required_context_validation
|
71
|
-
exception = assert_raises(ArgumentError) {
|
72
|
-
CamoFilter.call("", {})
|
73
|
-
}
|
74
|
-
assert_match /:asset_proxy[^_]/, exception.message
|
75
|
-
assert_match /:asset_proxy_secret_key/, exception.message
|
76
|
-
end
|
77
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
EmailReplyFilter = HTML::Pipeline::EmailReplyFilter
|
4
|
-
|
5
|
-
class HTML::Pipeline::EmailReplyFilterTest < Minitest::Test
|
6
|
-
def setup
|
7
|
-
@body = <<-EMAIL
|
8
|
-
Hey, don't send email addresses in comments. They aren't filtered.
|
9
|
-
|
10
|
-
> On Mar 5, 2016, at 08:05, Boaty McBoatface <boatymcboatface@example.com> wrote:
|
11
|
-
>
|
12
|
-
> Sup. alreadyleaked@example.com
|
13
|
-
>
|
14
|
-
> —
|
15
|
-
> Reply to this email directly or view it on GitHub.
|
16
|
-
EMAIL
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_doesnt_hide_by_default
|
20
|
-
filter = EmailReplyFilter.new(@body)
|
21
|
-
doc = filter.call.to_s
|
22
|
-
assert_match %r(alreadyleaked@example.com), doc
|
23
|
-
assert_match %r(boatymcboatface@example.com), doc
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_hides_email_addresses_when_configured
|
27
|
-
filter = EmailReplyFilter.new(@body, :hide_quoted_email_addresses => true)
|
28
|
-
doc = filter.call.to_s
|
29
|
-
refute_match %r(boatymcboatface@example.com), doc
|
30
|
-
refute_match %r(alreadyleaked@example.com), doc
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_preserves_non_email_content_while_filtering
|
34
|
-
str = <<-EMAIL
|
35
|
-
> Thank you! I have some thoughts on this pull request.
|
36
|
-
>
|
37
|
-
> * acme provides cmake and a wrapper for it. Please use '$(TARGET)-cmake' instead of cmake -DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)' -DCMAKE_BUILD_TYPE=Release.
|
38
|
-
|
39
|
-
Okay -- I'm afraid I just blindly copied the eigen3.mk file, since that's a library I'm familiar with :-)
|
40
|
-
|
41
|
-
> * Do you need -DCMAKE_SYSTEM_PROCESSOR=x86?
|
42
|
-
|
43
|
-
Yes, this is a bit dumb, but vc checks for that (or amd) to determine that it's not being built on ARM.
|
44
|
-
|
45
|
-
--
|
46
|
-
Boaty McBoatface | http://example.org
|
47
|
-
EMAIL
|
48
|
-
|
49
|
-
filter = EmailReplyFilter.new(str, :hide_quoted_email_addresses => true)
|
50
|
-
doc = filter.call.to_s
|
51
|
-
|
52
|
-
expected = <<-EXPECTED
|
53
|
-
<div class="email-quoted-reply"> Thank you! I have some thoughts on this pull request.
|
54
|
-
|
55
|
-
* acme provides cmake and a wrapper for it. Please use '$(TARGET)-cmake' instead of cmake -DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)' -DCMAKE_BUILD_TYPE=Release.</div>
|
56
|
-
<div class="email-fragment">Okay -- I'm afraid I just blindly copied the eigen3.mk file, since that's a library I'm familiar with :-)</div>
|
57
|
-
<div class="email-quoted-reply"> * Do you need -DCMAKE_SYSTEM_PROCESSOR=x86?</div>
|
58
|
-
<div class="email-fragment">Yes, this is a bit dumb, but vc checks for that (or amd) to determine that it's not being built on ARM.</div>
|
59
|
-
<span class="email-hidden-toggle"><a href="#">…</a></span><div class="email-hidden-reply" style="display:none"><div class="email-signature-reply">--
|
60
|
-
Boaty McBoatface | http://example.org</div>
|
61
|
-
</div>
|
62
|
-
EXPECTED
|
63
|
-
|
64
|
-
assert_equal(expected.chomp, doc)
|
65
|
-
end
|
66
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class HTML::Pipeline::EmojiFilterTest < Minitest::Test
|
4
|
-
EmojiFilter = HTML::Pipeline::EmojiFilter
|
5
|
-
|
6
|
-
def test_emojify
|
7
|
-
filter = EmojiFilter.new("<p>:shipit:</p>", {:asset_root => 'https://foo.com'})
|
8
|
-
doc = filter.call
|
9
|
-
assert_match "https://foo.com/emoji/shipit.png", doc.search('img').attr('src').value
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_uri_encoding
|
13
|
-
filter = EmojiFilter.new("<p>:+1:</p>", {:asset_root => 'https://foo.com'})
|
14
|
-
doc = filter.call
|
15
|
-
assert_match "https://foo.com/emoji/unicode/1f44d.png", doc.search('img').attr('src').value
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_required_context_validation
|
19
|
-
exception = assert_raises(ArgumentError) {
|
20
|
-
EmojiFilter.call("", {})
|
21
|
-
}
|
22
|
-
assert_match /:asset_root/, exception.message
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_custom_asset_path
|
26
|
-
filter = EmojiFilter.new("<p>:+1:</p>", {:asset_path => ':file_name', :asset_root => 'https://foo.com'})
|
27
|
-
doc = filter.call
|
28
|
-
assert_match "https://foo.com/unicode/1f44d.png", doc.search('img').attr('src').value
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_not_emojify_in_code_tags
|
32
|
-
body = "<code>:shipit:</code>"
|
33
|
-
filter = EmojiFilter.new(body, {:asset_root => 'https://foo.com'})
|
34
|
-
doc = filter.call
|
35
|
-
assert_equal body, doc.to_html
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_not_emojify_in_tt_tags
|
39
|
-
body = "<tt>:shipit:</tt>"
|
40
|
-
filter = EmojiFilter.new(body, {:asset_root => 'https://foo.com'})
|
41
|
-
doc = filter.call
|
42
|
-
assert_equal body, doc.to_html
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_not_emojify_in_pre_tags
|
46
|
-
body = "<pre>:shipit:</pre>"
|
47
|
-
filter = EmojiFilter.new(body, {:asset_root => 'https://foo.com'})
|
48
|
-
doc = filter.call
|
49
|
-
assert_equal body, doc.to_html
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_not_emojify_in_custom_single_tag_foo
|
53
|
-
body = "<foo>:shipit:</foo>"
|
54
|
-
filter = EmojiFilter.new(body, {:asset_root => 'https://foo.com', ignored_ancestor_tags: %w(foo)})
|
55
|
-
doc = filter.call
|
56
|
-
assert_equal body, doc.to_html
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_not_emojify_in_custom_multiple_tags_foo_and_bar
|
60
|
-
body = "<bar>:shipit:</bar>"
|
61
|
-
filter = EmojiFilter.new(body, {:asset_root => 'https://foo.com', ignored_ancestor_tags: %w(foo bar)})
|
62
|
-
doc = filter.call
|
63
|
-
assert_equal body, doc.to_html
|
64
|
-
end
|
65
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
HttpsFilter = HTML::Pipeline::HttpsFilter
|
4
|
-
|
5
|
-
class HTML::Pipeline::AutolinkFilterTest < Minitest::Test
|
6
|
-
def filter(html)
|
7
|
-
HttpsFilter.to_html(html, @options)
|
8
|
-
end
|
9
|
-
|
10
|
-
def setup
|
11
|
-
@options = {:base_url => "http://github.com"}
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_http
|
15
|
-
assert_equal %(<a href="https://github.com">github.com</a>),
|
16
|
-
filter(%(<a href="http://github.com">github.com</a>))
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_https
|
20
|
-
assert_equal %(<a href="https://github.com">github.com</a>),
|
21
|
-
filter(%(<a href="https://github.com">github.com</a>))
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_subdomain
|
25
|
-
assert_equal %(<a href="http://help.github.com">github.com</a>),
|
26
|
-
filter(%(<a href="http://help.github.com">github.com</a>))
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_other
|
30
|
-
assert_equal %(<a href="http://github.io">github.io</a>),
|
31
|
-
filter(%(<a href="http://github.io">github.io</a>))
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_uses_http_url_over_base_url
|
35
|
-
@options = {:http_url => "http://github.com", :base_url => "https://github.com"}
|
36
|
-
|
37
|
-
assert_equal %(<a href="https://github.com">github.com</a>),
|
38
|
-
filter(%(<a href="http://github.com">github.com</a>))
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_only_http_url
|
42
|
-
@options = {:http_url => "http://github.com"}
|
43
|
-
|
44
|
-
assert_equal %(<a href="https://github.com">github.com</a>),
|
45
|
-
filter(%(<a href="http://github.com">github.com</a>))
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_validates_http_url
|
49
|
-
@options.clear
|
50
|
-
exception = assert_raises(ArgumentError) { filter("") }
|
51
|
-
assert_match "HTML::Pipeline::HttpsFilter: :http_url", exception.message
|
52
|
-
end
|
53
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
ImageFilter = HTML::Pipeline::ImageFilter
|
4
|
-
|
5
|
-
class HTML::Pipeline::ImageFilterTest < Minitest::Test
|
6
|
-
def filter(html)
|
7
|
-
ImageFilter.to_html(html)
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_jpg
|
11
|
-
assert_equal %(<img src="http://example.com/test.jpg" alt=""/>),
|
12
|
-
filter(%(http://example.com/test.jpg))
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_jpeg
|
16
|
-
assert_equal %(<img src="http://example.com/test.jpeg" alt=""/>),
|
17
|
-
filter(%(http://example.com/test.jpeg))
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_bmp
|
21
|
-
assert_equal %(<img src="http://example.com/test.bmp" alt=""/>),
|
22
|
-
filter(%(http://example.com/test.bmp))
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_gif
|
26
|
-
assert_equal %(<img src="http://example.com/test.gif" alt=""/>),
|
27
|
-
filter(%(http://example.com/test.gif))
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_png
|
31
|
-
assert_equal %(<img src="http://example.com/test.png" alt=""/>),
|
32
|
-
filter(%(http://example.com/test.png))
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_https_url
|
36
|
-
assert_equal %(<img src="https://example.com/test.png" alt=""/>),
|
37
|
-
filter(%(https://example.com/test.png))
|
38
|
-
end
|
39
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class HTML::Pipeline::ImageMaxWidthFilterTest < Minitest::Test
|
4
|
-
def filter(html)
|
5
|
-
HTML::Pipeline::ImageMaxWidthFilter.call(html)
|
6
|
-
end
|
7
|
-
|
8
|
-
def test_rewrites_image_style_tags
|
9
|
-
body = "<p>Screenshot: <img src='screenshot.png'></p>"
|
10
|
-
doc = Nokogiri::HTML::DocumentFragment.parse(body)
|
11
|
-
|
12
|
-
res = filter(doc)
|
13
|
-
assert_equal_html %q(<p>Screenshot: <a target="_blank" href="screenshot.png"><img src="screenshot.png" style="max-width:100%;"></a></p>),
|
14
|
-
res.to_html
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_leaves_existing_image_style_tags_alone
|
18
|
-
body = "<p><img src='screenshot.png' style='width:100px;'></p>"
|
19
|
-
doc = Nokogiri::HTML::DocumentFragment.parse(body)
|
20
|
-
|
21
|
-
res = filter(doc)
|
22
|
-
assert_equal_html '<p><img src="screenshot.png" style="width:100px;"></p>',
|
23
|
-
res.to_html
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_links_to_image
|
27
|
-
body = "<p>Screenshot: <img src='screenshot.png'></p>"
|
28
|
-
doc = Nokogiri::HTML::DocumentFragment.parse(body)
|
29
|
-
|
30
|
-
res = filter(doc)
|
31
|
-
assert_equal_html '<p>Screenshot: <a target="_blank" href="screenshot.png"><img src="screenshot.png" style="max-width:100%;"></a></p>',
|
32
|
-
res.to_html
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_doesnt_link_to_image_when_already_linked
|
36
|
-
body = "<p>Screenshot: <a href='blah.png'><img src='screenshot.png'></a></p>"
|
37
|
-
doc = Nokogiri::HTML::DocumentFragment.parse(body)
|
38
|
-
|
39
|
-
res = filter(doc)
|
40
|
-
assert_equal_html %q(<p>Screenshot: <a href="blah.png"><img src="screenshot.png" style="max-width:100%;"></a></p>),
|
41
|
-
res.to_html
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_doesnt_screw_up_inlined_images
|
45
|
-
body = "<p>Screenshot <img src='screenshot.png'>, yes, this is a <b>screenshot</b> indeed.</p>"
|
46
|
-
doc = Nokogiri::HTML::DocumentFragment.parse(body)
|
47
|
-
|
48
|
-
assert_equal_html %q(<p>Screenshot <a target="_blank" href="screenshot.png"><img src="screenshot.png" style="max-width:100%;"></a>, yes, this is a <b>screenshot</b> indeed.</p>), filter(doc).to_html
|
49
|
-
end
|
50
|
-
end
|
@@ -1,101 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
MarkdownFilter = HTML::Pipeline::MarkdownFilter
|
4
|
-
|
5
|
-
class HTML::Pipeline::MarkdownFilterTest < Minitest::Test
|
6
|
-
def setup
|
7
|
-
@haiku =
|
8
|
-
"Pointing at the moon\n" +
|
9
|
-
"Reminded of simple things\n" +
|
10
|
-
"Moments matter most"
|
11
|
-
@links =
|
12
|
-
"See http://example.org/ for more info"
|
13
|
-
@code =
|
14
|
-
"```\n" +
|
15
|
-
"def hello()" +
|
16
|
-
" 'world'" +
|
17
|
-
"end" +
|
18
|
-
"```"
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_fails_when_given_a_documentfragment
|
22
|
-
body = "<p>heyo</p>"
|
23
|
-
doc = HTML::Pipeline.parse(body)
|
24
|
-
assert_raises(TypeError) { MarkdownFilter.call(doc, {}) }
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_gfm_enabled_by_default
|
28
|
-
doc = MarkdownFilter.to_document(@haiku, {})
|
29
|
-
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
30
|
-
assert_equal 2, doc.search('br').size
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_disabling_gfm
|
34
|
-
doc = MarkdownFilter.to_document(@haiku, :gfm => false)
|
35
|
-
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
36
|
-
assert_equal 0, doc.search('br').size
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_fenced_code_blocks
|
40
|
-
doc = MarkdownFilter.to_document(@code)
|
41
|
-
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
42
|
-
assert_equal 1, doc.search('pre').size
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_fenced_code_blocks_with_language
|
46
|
-
doc = MarkdownFilter.to_document(@code.sub("```", "``` ruby"))
|
47
|
-
assert doc.kind_of?(HTML::Pipeline::DocumentFragment)
|
48
|
-
assert_equal 1, doc.search('pre').size
|
49
|
-
assert_equal 'ruby', doc.search('pre').first['lang']
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
class GFMTest < Minitest::Test
|
54
|
-
def gfm(text)
|
55
|
-
MarkdownFilter.call(text, :gfm => true)
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_not_touch_single_underscores_inside_words
|
59
|
-
assert_equal "<p>foo_bar</p>",
|
60
|
-
gfm("foo_bar")
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_not_touch_underscores_in_code_blocks
|
64
|
-
assert_equal "<pre><code>foo_bar_baz\n</code></pre>",
|
65
|
-
gfm(" foo_bar_baz")
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_not_touch_underscores_in_pre_blocks
|
69
|
-
assert_equal "<pre>\nfoo_bar_baz\n</pre>",
|
70
|
-
gfm("<pre>\nfoo_bar_baz\n</pre>")
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_not_touch_two_or_more_underscores_inside_words
|
74
|
-
assert_equal "<p>foo_bar_baz</p>",
|
75
|
-
gfm("foo_bar_baz")
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_turn_newlines_into_br_tags_in_simple_cases
|
79
|
-
assert_equal "<p>foo<br>\nbar</p>",
|
80
|
-
gfm("foo\nbar")
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_convert_newlines_in_all_groups
|
84
|
-
assert_equal "<p>apple<br>\npear<br>\norange</p>\n\n" +
|
85
|
-
"<p>ruby<br>\npython<br>\nerlang</p>",
|
86
|
-
gfm("apple\npear\norange\n\nruby\npython\nerlang")
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_convert_newlines_in_even_long_groups
|
90
|
-
assert_equal "<p>apple<br>\npear<br>\norange<br>\nbanana</p>\n\n" +
|
91
|
-
"<p>ruby<br>\npython<br>\nerlang</p>",
|
92
|
-
gfm("apple\npear\norange\nbanana\n\nruby\npython\nerlang")
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_not_convert_newlines_in_lists
|
96
|
-
assert_equal "<h1>foo</h1>\n\n<h1>bar</h1>",
|
97
|
-
gfm("# foo\n# bar")
|
98
|
-
assert_equal "<ul>\n<li>foo</li>\n<li>bar</li>\n</ul>",
|
99
|
-
gfm("* foo\n* bar")
|
100
|
-
end
|
101
|
-
end
|