html-pipeline 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +5 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +6 -0
- data/html-pipeline.gemspec +2 -2
- data/lib/html/pipeline/emoji_filter.rb +32 -6
- data/lib/html/pipeline/https_filter.rb +12 -3
- data/lib/html/pipeline/version.rb +1 -1
- data/test/html/pipeline/absolute_source_filter_test.rb +7 -7
- data/test/html/pipeline/autolink_filter_test.rb +1 -1
- data/test/html/pipeline/camo_filter_test.rb +3 -5
- data/test/html/pipeline/emoji_filter_test.rb +2 -2
- data/test/html/pipeline/https_filter_test.rb +34 -0
- data/test/html/pipeline/image_max_width_filter_test.rb +1 -1
- data/test/html/pipeline/markdown_filter_test.rb +3 -3
- data/test/html/pipeline/mention_filter_test.rb +1 -1
- data/test/html/pipeline/plain_text_input_filter_test.rb +2 -2
- data/test/html/pipeline/sanitization_filter_test.rb +7 -7
- data/test/html/pipeline/syntax_highlight_filter_test.rb +1 -1
- data/test/html/pipeline/toc_filter_test.rb +15 -15
- data/test/html/pipeline_test.rb +1 -1
- data/test/test_helper.rb +2 -24
- metadata +13 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d66ab39f5d7421758fc4599939bdbb364a50b3da
|
4
|
+
data.tar.gz: 7f0ff92ba9e248534ce6bf8579d86e1b965f2901
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f26ca78fe3a9549c5023601919593f0f3265bab16865efac85cfe187ec2588f217f1c4e5d92e10fcef4d8417fa64eb20dc256945a7ed7cf1d1931706f790bc1
|
7
|
+
data.tar.gz: fbd6e5c3ce3174f467515e8ce8bdb685ef2c56878920d2c600ed7b5bf38a3b6bcfbec2cb62cc07a1e8c6ece21b223f20addccfce65100089d59b8a972d609b06
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 1.9.0
|
4
|
+
|
5
|
+
* Generalize https filter with :base_url #124 #131 rymohr
|
6
|
+
* Clean up gemspec dependencies #130 mislav
|
7
|
+
* EmojiFilter compatibility with gemoji v2 #129 mislav
|
8
|
+
* Now using Minitest #126 simeonwillbanks
|
9
|
+
|
3
10
|
## 1.8.0
|
4
11
|
|
5
12
|
* Add custom path support for EmojiFilter #122 bradly
|
data/Gemfile
CHANGED
@@ -9,6 +9,7 @@ group :development do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
group :test do
|
12
|
+
gem "minitest", "~> 5.3"
|
12
13
|
gem "rinku", "~> 1.7", :require => false
|
13
14
|
gem "gemoji", "~> 1.0", :require => false
|
14
15
|
gem "RedCloth", "~> 4.2.9", :require => false
|
@@ -25,7 +26,12 @@ group :test do
|
|
25
26
|
|
26
27
|
if RUBY_VERSION < "1.9.2"
|
27
28
|
gem "sanitize", ">= 2", "< 2.0.4", :require => false
|
29
|
+
gem "nokogiri", ">= 1.4", "< 1.6"
|
28
30
|
else
|
29
31
|
gem "sanitize", "~> 2.0", :require => false
|
30
32
|
end
|
33
|
+
|
34
|
+
if RUBY_VERSION < "1.9.3"
|
35
|
+
gem "activesupport", ">= 2", "< 4"
|
36
|
+
end
|
31
37
|
end
|
data/html-pipeline.gemspec
CHANGED
@@ -15,8 +15,8 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.test_files = gem.files.grep(%r{^test})
|
16
16
|
gem.require_paths = ["lib"]
|
17
17
|
|
18
|
-
gem.add_dependency "nokogiri",
|
19
|
-
gem.add_dependency "activesupport",
|
18
|
+
gem.add_dependency "nokogiri", "~> 1.4"
|
19
|
+
gem.add_dependency "activesupport", ">= 2"
|
20
20
|
|
21
21
|
gem.post_install_message = <<msg
|
22
22
|
-------------------------------------------------
|
@@ -14,9 +14,6 @@ module HTML
|
|
14
14
|
# :asset_root (required) - base url to link to emoji sprite
|
15
15
|
# :asset_path (optional) - url path to link to emoji sprite. :file_name can be used as a placeholder for the sprite file name. If no asset_path is set "emoji/:file_name" is used.
|
16
16
|
class EmojiFilter < Filter
|
17
|
-
# Build a regexp that matches all valid :emoji: names.
|
18
|
-
EmojiPattern = /:(#{Emoji.names.map { |name| Regexp.escape(name) }.join('|')}):/
|
19
|
-
|
20
17
|
def call
|
21
18
|
doc.search('text()').each do |node|
|
22
19
|
content = node.to_html
|
@@ -43,7 +40,7 @@ module HTML
|
|
43
40
|
def emoji_image_filter(text)
|
44
41
|
return text unless text.include?(':')
|
45
42
|
|
46
|
-
text.gsub
|
43
|
+
text.gsub(emoji_pattern) do |match|
|
47
44
|
name = $1
|
48
45
|
"<img class='emoji' title=':#{name}:' alt=':#{name}:' src='#{emoji_url(name)}' height='20' width='20' align='absmiddle' />"
|
49
46
|
end
|
@@ -63,9 +60,9 @@ module HTML
|
|
63
60
|
# Returns the context's asset_path or the default path if no context asset_path is given.
|
64
61
|
def asset_path(name)
|
65
62
|
if context[:asset_path]
|
66
|
-
context[:asset_path].gsub(":file_name",
|
63
|
+
context[:asset_path].gsub(":file_name", emoji_filename(name))
|
67
64
|
else
|
68
|
-
File.join("emoji",
|
65
|
+
File.join("emoji", emoji_filename(name))
|
69
66
|
end
|
70
67
|
end
|
71
68
|
|
@@ -74,6 +71,35 @@ module HTML
|
|
74
71
|
def emoji_url(name)
|
75
72
|
File.join(asset_root, asset_path(name))
|
76
73
|
end
|
74
|
+
|
75
|
+
# Build a regexp that matches all valid :emoji: names.
|
76
|
+
def self.emoji_pattern
|
77
|
+
@emoji_pattern ||= /:(#{emoji_names.map { |name| Regexp.escape(name) }.join('|')}):/
|
78
|
+
end
|
79
|
+
|
80
|
+
def emoji_pattern
|
81
|
+
self.class.emoji_pattern
|
82
|
+
end
|
83
|
+
|
84
|
+
# Detect gemoji v2 which has a new API
|
85
|
+
# https://github.com/jch/html-pipeline/pull/129
|
86
|
+
if Emoji.respond_to?(:all)
|
87
|
+
def self.emoji_names
|
88
|
+
Emoji.all.map(&:aliases).flatten.sort
|
89
|
+
end
|
90
|
+
|
91
|
+
def emoji_filename(name)
|
92
|
+
Emoji.find_by_alias(name).image_filename
|
93
|
+
end
|
94
|
+
else
|
95
|
+
def self.emoji_names
|
96
|
+
Emoji.names
|
97
|
+
end
|
98
|
+
|
99
|
+
def emoji_filename(name)
|
100
|
+
"#{::CGI.escape(name)}.png"
|
101
|
+
end
|
102
|
+
end
|
77
103
|
end
|
78
104
|
end
|
79
105
|
end
|
@@ -1,13 +1,22 @@
|
|
1
1
|
module HTML
|
2
2
|
class Pipeline
|
3
|
-
# HTML Filter for replacing http
|
3
|
+
# HTML Filter for replacing http references to :base_url with https versions.
|
4
|
+
# Subdomain references are not rewritten.
|
5
|
+
#
|
6
|
+
# Context options:
|
7
|
+
# :base_url - The url to force https
|
4
8
|
class HttpsFilter < Filter
|
5
9
|
def call
|
6
|
-
doc.css(
|
10
|
+
doc.css(%Q(a[href^="#{context[:base_url]}"])).each do |element|
|
7
11
|
element['href'] = element['href'].sub(/^http:/,'https:')
|
8
12
|
end
|
9
13
|
doc
|
10
14
|
end
|
15
|
+
|
16
|
+
# Raise error if :base_url undefined
|
17
|
+
def validate
|
18
|
+
needs :base_url
|
19
|
+
end
|
11
20
|
end
|
12
21
|
end
|
13
|
-
end
|
22
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
|
-
class HTML::Pipeline::AbsoluteSourceFilterTest < Test
|
3
|
+
class HTML::Pipeline::AbsoluteSourceFilterTest < Minitest::Test
|
4
4
|
AbsoluteSourceFilter = HTML::Pipeline::AbsoluteSourceFilter
|
5
5
|
|
6
6
|
def setup
|
@@ -27,26 +27,26 @@ class HTML::Pipeline::AbsoluteSourceFilterTest < Test::Unit::TestCase
|
|
27
27
|
def test_does_not_rewrite_absolute_urls
|
28
28
|
orig = %(<p><img src="http://other.example.com/img.png"></p>)
|
29
29
|
result = AbsoluteSourceFilter.call(orig, @options).to_s
|
30
|
-
|
31
|
-
|
30
|
+
refute_match /@image_base_url/, result
|
31
|
+
refute_match /@image_subpage_url/, result
|
32
32
|
end
|
33
33
|
|
34
34
|
def test_fails_when_context_is_missing
|
35
|
-
|
35
|
+
assert_raises RuntimeError do
|
36
36
|
AbsoluteSourceFilter.call("<img src=\"img.png\">", {})
|
37
37
|
end
|
38
|
-
|
38
|
+
assert_raises RuntimeError do
|
39
39
|
AbsoluteSourceFilter.call("<img src=\"/img.png\">", {})
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_tells_you_where_context_is_required
|
44
|
-
exception =
|
44
|
+
exception = assert_raises(RuntimeError) {
|
45
45
|
AbsoluteSourceFilter.call("<img src=\"img.png\">", {})
|
46
46
|
}
|
47
47
|
assert_match 'HTML::Pipeline::AbsoluteSourceFilter', exception.message
|
48
48
|
|
49
|
-
exception =
|
49
|
+
exception = assert_raises(RuntimeError) {
|
50
50
|
AbsoluteSourceFilter.call("<img src=\"/img.png\">", {})
|
51
51
|
}
|
52
52
|
assert_match 'HTML::Pipeline::AbsoluteSourceFilter', exception.message
|
@@ -2,7 +2,7 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
AutolinkFilter = HTML::Pipeline::AutolinkFilter
|
4
4
|
|
5
|
-
class HTML::Pipeline::AutolinkFilterTest < Test
|
5
|
+
class HTML::Pipeline::AutolinkFilterTest < Minitest::Test
|
6
6
|
def test_uses_rinku_for_autolinking
|
7
7
|
# just try to parse a complicated piece of HTML
|
8
8
|
# that Rails auto_link cannot handle
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
|
-
class HTML::Pipeline::CamoFilterTest < Test
|
3
|
+
class HTML::Pipeline::CamoFilterTest < Minitest::Test
|
4
4
|
CamoFilter = HTML::Pipeline::CamoFilter
|
5
5
|
|
6
6
|
def setup
|
@@ -64,13 +64,11 @@ class HTML::Pipeline::CamoFilterTest < Test::Unit::TestCase
|
|
64
64
|
|
65
65
|
def test_handling_images_with_no_src_attribute
|
66
66
|
orig = %(<p><img></p>)
|
67
|
-
|
68
|
-
CamoFilter.call(orig, @options).to_s
|
69
|
-
end
|
67
|
+
assert_equal orig, CamoFilter.call(orig, @options).to_s
|
70
68
|
end
|
71
69
|
|
72
70
|
def test_required_context_validation
|
73
|
-
exception =
|
71
|
+
exception = assert_raises(ArgumentError) {
|
74
72
|
CamoFilter.call("", {})
|
75
73
|
}
|
76
74
|
assert_match /:asset_proxy[^_]/, exception.message
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class HTML::Pipeline::EmojiFilterTest < Test
|
3
|
+
class HTML::Pipeline::EmojiFilterTest < Minitest::Test
|
4
4
|
EmojiFilter = HTML::Pipeline::EmojiFilter
|
5
5
|
|
6
6
|
def test_emojify
|
@@ -16,7 +16,7 @@ class HTML::Pipeline::EmojiFilterTest < Test::Unit::TestCase
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_required_context_validation
|
19
|
-
exception =
|
19
|
+
exception = assert_raises(ArgumentError) {
|
20
20
|
EmojiFilter.call("", {})
|
21
21
|
}
|
22
22
|
assert_match /:asset_root/, exception.message
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
HttpsFilter = HTML::Pipeline::HttpsFilter
|
4
|
+
|
5
|
+
class HTML::Pipeline::AutolinkFilterTest < Minitest::Test
|
6
|
+
def filter(html, base_url="http://github.com")
|
7
|
+
HttpsFilter.to_html(html, :base_url => base_url)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_http
|
11
|
+
assert_equal %(<a href="https://github.com">github.com</a>),
|
12
|
+
filter(%(<a href="http://github.com">github.com</a>))
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_https
|
16
|
+
assert_equal %(<a href="https://github.com">github.com</a>),
|
17
|
+
filter(%(<a href="https://github.com">github.com</a>))
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_subdomain
|
21
|
+
assert_equal %(<a href="http://help.github.com">github.com</a>),
|
22
|
+
filter(%(<a href="http://help.github.com">github.com</a>))
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_other
|
26
|
+
assert_equal %(<a href="http://github.io">github.io</a>),
|
27
|
+
filter(%(<a href="http://github.io">github.io</a>))
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_validation
|
31
|
+
exception = assert_raises(ArgumentError) { HttpsFilter.call(nil, {}) }
|
32
|
+
assert_match "HTML::Pipeline::HttpsFilter: :base_url", exception.message
|
33
|
+
end
|
34
|
+
end
|
@@ -2,7 +2,7 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
MarkdownFilter = HTML::Pipeline::MarkdownFilter
|
4
4
|
|
5
|
-
class HTML::Pipeline::MarkdownFilterTest < Test
|
5
|
+
class HTML::Pipeline::MarkdownFilterTest < Minitest::Test
|
6
6
|
def setup
|
7
7
|
@haiku =
|
8
8
|
"Pointing at the moon\n" +
|
@@ -21,7 +21,7 @@ class HTML::Pipeline::MarkdownFilterTest < Test::Unit::TestCase
|
|
21
21
|
def test_fails_when_given_a_documentfragment
|
22
22
|
body = "<p>heyo</p>"
|
23
23
|
doc = HTML::Pipeline.parse(body)
|
24
|
-
|
24
|
+
assert_raises(TypeError) { MarkdownFilter.call(doc, {}) }
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_gfm_enabled_by_default
|
@@ -50,7 +50,7 @@ class HTML::Pipeline::MarkdownFilterTest < Test::Unit::TestCase
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
class GFMTest < Test
|
53
|
+
class GFMTest < Minitest::Test
|
54
54
|
def gfm(text)
|
55
55
|
MarkdownFilter.call(text, :gfm => true)
|
56
56
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
|
-
class HTML::Pipeline::MentionFilterTest < Test
|
3
|
+
class HTML::Pipeline::MentionFilterTest < Minitest::Test
|
4
4
|
def filter(html, base_url='/', info_url=nil)
|
5
5
|
HTML::Pipeline::MentionFilter.call(html, :base_url => base_url, :info_url => info_url)
|
6
6
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
|
-
class HTML::Pipeline::PlainTextInputFilterTest < Test
|
3
|
+
class HTML::Pipeline::PlainTextInputFilterTest < Minitest::Test
|
4
4
|
PlainTextInputFilter = HTML::Pipeline::PlainTextInputFilter
|
5
5
|
|
6
6
|
def test_fails_when_given_a_documentfragment
|
7
7
|
body = "<p>heyo</p>"
|
8
8
|
doc = Nokogiri::HTML::DocumentFragment.parse(body)
|
9
|
-
|
9
|
+
assert_raises(TypeError) { PlainTextInputFilter.call(doc, {}) }
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_wraps_input_in_a_div_element
|
@@ -1,32 +1,32 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
|
-
class HTML::Pipeline::SanitizationFilterTest < Test
|
3
|
+
class HTML::Pipeline::SanitizationFilterTest < Minitest::Test
|
4
4
|
SanitizationFilter = HTML::Pipeline::SanitizationFilter
|
5
5
|
|
6
6
|
def test_removing_script_tags
|
7
7
|
orig = %(<p><img src="http://github.com/img.png" /><script></script></p>)
|
8
8
|
html = SanitizationFilter.call(orig).to_s
|
9
|
-
|
9
|
+
refute_match /script/, html
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_removing_style_tags
|
13
13
|
orig = %(<p><style>hey now</style></p>)
|
14
14
|
html = SanitizationFilter.call(orig).to_s
|
15
|
-
|
15
|
+
refute_match /style/, html
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_removing_style_attributes
|
19
19
|
orig = %(<p style='font-size:1000%'>YO DAWG</p>)
|
20
20
|
html = SanitizationFilter.call(orig).to_s
|
21
|
-
|
22
|
-
|
21
|
+
refute_match /font-size/, html
|
22
|
+
refute_match /style/, html
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_removing_script_event_handler_attributes
|
26
26
|
orig = %(<a onclick='javascript:alert(0)'>YO DAWG</a>)
|
27
27
|
html = SanitizationFilter.call(orig).to_s
|
28
|
-
|
29
|
-
|
28
|
+
refute_match /javscript/, html
|
29
|
+
refute_match /onclick/, html
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_sanitizes_li_elements_not_contained_in_ul_or_ol
|
@@ -2,7 +2,7 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
SyntaxHighlightFilter = HTML::Pipeline::SyntaxHighlightFilter
|
4
4
|
|
5
|
-
class HTML::Pipeline::SyntaxHighlightFilterTest < Test
|
5
|
+
class HTML::Pipeline::SyntaxHighlightFilterTest < Minitest::Test
|
6
6
|
def test_highlight_default
|
7
7
|
filter = SyntaxHighlightFilter.new \
|
8
8
|
"<pre>hello</pre>", :highlight => "coffeescript"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "test_helper"
|
3
3
|
|
4
|
-
class HTML::Pipeline::TableOfContentsFilterTest < Test
|
4
|
+
class HTML::Pipeline::TableOfContentsFilterTest < Minitest::Test
|
5
5
|
TocFilter = HTML::Pipeline::TableOfContentsFilter
|
6
6
|
|
7
7
|
TocPipeline =
|
@@ -17,30 +17,30 @@ class HTML::Pipeline::TableOfContentsFilterTest < Test::Unit::TestCase
|
|
17
17
|
|
18
18
|
def test_anchors_are_added_properly
|
19
19
|
orig = %(<h1>Ice cube</h1><p>Will swarm on any motherfucker in a blue uniform</p>)
|
20
|
-
assert_includes
|
20
|
+
assert_includes TocFilter.call(orig).to_s, '<a name='
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_toc_list_added_properly
|
24
24
|
@orig = %(<h1>Ice cube</h1><p>Will swarm on any motherfucker in a blue uniform</p>)
|
25
|
-
assert_includes %Q{<ul class="section-nav">\n<li><a href="}
|
25
|
+
assert_includes toc, %Q{<ul class="section-nav">\n<li><a href="}
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_anchors_have_sane_names
|
29
29
|
orig = %(<h1>Dr Dre</h1><h1>Ice Cube</h1><h1>Eazy-E</h1><h1>MC Ren</h1>)
|
30
30
|
result = TocFilter.call(orig).to_s
|
31
31
|
|
32
|
-
assert_includes '"dr-dre"'
|
33
|
-
assert_includes '"ice-cube"'
|
34
|
-
assert_includes '"eazy-e"'
|
35
|
-
assert_includes '"mc-ren"'
|
32
|
+
assert_includes result, '"dr-dre"'
|
33
|
+
assert_includes result, '"ice-cube"'
|
34
|
+
assert_includes result, '"eazy-e"'
|
35
|
+
assert_includes result, '"mc-ren"'
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_toc_hrefs_have_sane_values
|
39
39
|
@orig = %(<h1>Dr Dre</h1><h1>Ice Cube</h1><h1>Eazy-E</h1><h1>MC Ren</h1>)
|
40
|
-
assert_includes '"#dr-dre"'
|
41
|
-
assert_includes '"#ice-cube"'
|
42
|
-
assert_includes '"#eazy-e"'
|
43
|
-
assert_includes '"#mc-ren"'
|
40
|
+
assert_includes toc, '"#dr-dre"'
|
41
|
+
assert_includes toc, '"#ice-cube"'
|
42
|
+
assert_includes toc, '"#eazy-e"'
|
43
|
+
assert_includes toc, '"#mc-ren"'
|
44
44
|
end
|
45
45
|
|
46
46
|
def test_dupe_headers_have_unique_trailing_identifiers
|
@@ -51,8 +51,8 @@ class HTML::Pipeline::TableOfContentsFilterTest < Test::Unit::TestCase
|
|
51
51
|
|
52
52
|
result = TocFilter.call(orig).to_s
|
53
53
|
|
54
|
-
assert_includes '"dopeman"'
|
55
|
-
assert_includes '"dopeman-1"'
|
54
|
+
assert_includes result, '"dopeman"'
|
55
|
+
assert_includes result, '"dopeman-1"'
|
56
56
|
end
|
57
57
|
|
58
58
|
def test_dupe_headers_have_unique_toc_anchors
|
@@ -61,8 +61,8 @@ class HTML::Pipeline::TableOfContentsFilterTest < Test::Unit::TestCase
|
|
61
61
|
<h3>Express Yourself</h3>
|
62
62
|
<h1>Dopeman</h1>)
|
63
63
|
|
64
|
-
assert_includes '"#dopeman"'
|
65
|
-
assert_includes '"#dopeman-1"'
|
64
|
+
assert_includes toc, '"#dopeman"'
|
65
|
+
assert_includes toc, '"#dopeman-1"'
|
66
66
|
end
|
67
67
|
|
68
68
|
def test_all_header_tags_are_found_when_adding_anchors
|
data/test/html/pipeline_test.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -1,33 +1,11 @@
|
|
1
1
|
require 'bundler/setup'
|
2
2
|
require 'html/pipeline'
|
3
|
-
require '
|
3
|
+
require 'minitest/autorun'
|
4
4
|
|
5
5
|
require 'active_support/core_ext/string'
|
6
6
|
require 'active_support/core_ext/object/try'
|
7
7
|
|
8
8
|
module TestHelpers
|
9
|
-
# Asserts that `needle` is not a member of `haystack`, where
|
10
|
-
# `haystack` is any object that responds to `include?`.
|
11
|
-
def assert_doesnt_include(needle, haystack, message = nil)
|
12
|
-
error = '<?> included in <?>'
|
13
|
-
message = build_message(message, error, needle.to_s, Array(haystack).map(&:to_s))
|
14
|
-
|
15
|
-
assert_block message do
|
16
|
-
!haystack.include?(needle)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
# Asserts that `needle` is a member of `haystack`, where
|
21
|
-
# `haystack` is any object that responds to `include?`.
|
22
|
-
def assert_includes(needle, haystack, message = nil)
|
23
|
-
error = '<?> not included in <?>'
|
24
|
-
message = build_message(message, error, needle.to_s, Array(haystack).map(&:to_s))
|
25
|
-
|
26
|
-
assert_block message do
|
27
|
-
haystack.include?(needle)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
9
|
# Asserts that two html fragments are equivalent. Attribute order
|
32
10
|
# will be ignored.
|
33
11
|
def assert_equal_html(expected, actual)
|
@@ -36,4 +14,4 @@ module TestHelpers
|
|
36
14
|
end
|
37
15
|
end
|
38
16
|
|
39
|
-
Test
|
17
|
+
Minitest::Test.send(:include, TestHelpers)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html-pipeline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Tomayko
|
@@ -9,34 +9,34 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-07-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ~>
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '1.4'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ~>
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '1.4'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: activesupport
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - '>='
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '2'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - '>='
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '2'
|
42
42
|
description: GitHub HTML processing filters and utilities
|
@@ -47,8 +47,8 @@ executables: []
|
|
47
47
|
extensions: []
|
48
48
|
extra_rdoc_files: []
|
49
49
|
files:
|
50
|
-
-
|
51
|
-
-
|
50
|
+
- .gitignore
|
51
|
+
- .travis.yml
|
52
52
|
- CHANGELOG.md
|
53
53
|
- CONTRIBUTING.md
|
54
54
|
- Gemfile
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- test/html/pipeline/autolink_filter_test.rb
|
84
84
|
- test/html/pipeline/camo_filter_test.rb
|
85
85
|
- test/html/pipeline/emoji_filter_test.rb
|
86
|
+
- test/html/pipeline/https_filter_test.rb
|
86
87
|
- test/html/pipeline/image_max_width_filter_test.rb
|
87
88
|
- test/html/pipeline/markdown_filter_test.rb
|
88
89
|
- test/html/pipeline/mention_filter_test.rb
|
@@ -108,17 +109,17 @@ require_paths:
|
|
108
109
|
- lib
|
109
110
|
required_ruby_version: !ruby/object:Gem::Requirement
|
110
111
|
requirements:
|
111
|
-
- -
|
112
|
+
- - '>='
|
112
113
|
- !ruby/object:Gem::Version
|
113
114
|
version: '0'
|
114
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
116
|
requirements:
|
116
|
-
- -
|
117
|
+
- - '>='
|
117
118
|
- !ruby/object:Gem::Version
|
118
119
|
version: '0'
|
119
120
|
requirements: []
|
120
121
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.
|
122
|
+
rubygems_version: 2.0.14
|
122
123
|
signing_key:
|
123
124
|
specification_version: 4
|
124
125
|
summary: Helpers for processing content through a chain of filters
|
@@ -128,6 +129,7 @@ test_files:
|
|
128
129
|
- test/html/pipeline/autolink_filter_test.rb
|
129
130
|
- test/html/pipeline/camo_filter_test.rb
|
130
131
|
- test/html/pipeline/emoji_filter_test.rb
|
132
|
+
- test/html/pipeline/https_filter_test.rb
|
131
133
|
- test/html/pipeline/image_max_width_filter_test.rb
|
132
134
|
- test/html/pipeline/markdown_filter_test.rb
|
133
135
|
- test/html/pipeline/mention_filter_test.rb
|