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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c0ef5f710331e4cbd96e8052870c185b069ec6c
|
4
|
+
data.tar.gz: 268a8be42428bf687f3f7a7a5ee12311f91be04b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82fc8239a1783aea4c6f6e270a19efb56ffc6ed7cf4fae61924b9de1391dc9822b4134c00bb41fa2bf7f6052b568b40410b6fc2dbbb68d38be93ed2856e5a33b
|
7
|
+
data.tar.gz: e857252f6362ac78b3213cb4ca98ed614c647ec911b210205b33d01fd644378885beffae2b44071545164ad7e1e0c7b419019f7e7b8ff80067b7a034d9c2403f
|
data/.travis.yml
CHANGED
@@ -1,21 +1,32 @@
|
|
1
1
|
language: ruby
|
2
2
|
sudo: false
|
3
|
+
cache: bundler
|
3
4
|
|
4
5
|
addons:
|
5
6
|
apt:
|
6
7
|
sources:
|
7
8
|
- libicu-dev
|
8
9
|
|
9
|
-
script:
|
10
|
+
script: bundle exec rake
|
11
|
+
|
12
|
+
gemfile:
|
13
|
+
- gemfiles/rails_5.gemfile
|
14
|
+
- gemfiles/rails_4.gemfile
|
15
|
+
- gemfiles/rails_3.gemfile
|
10
16
|
|
11
17
|
rvm:
|
12
|
-
- 2.
|
18
|
+
- 2.3.1
|
19
|
+
- 2.2.5
|
13
20
|
- 2.1
|
14
|
-
- 2.
|
15
|
-
- 2.3.0
|
21
|
+
- 2.0
|
16
22
|
- ruby-head
|
17
23
|
|
18
24
|
matrix:
|
19
25
|
fast_finish: true
|
20
26
|
allow_failures:
|
21
27
|
- rvm: ruby-head
|
28
|
+
exclude:
|
29
|
+
- gemfile: gemfiles/rails_5.gemfile
|
30
|
+
rvm: 2.1
|
31
|
+
- gemfile: gemfiles/rails_5.gemfile
|
32
|
+
rvm: 2.0
|
data/Appraisals
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 2.4.2
|
4
|
+
|
5
|
+
* Make EmojiFilter generated img tag HTML attributes configurable [#258](https://github.com/jch/html-pipeline/pull/258)
|
6
|
+
|
3
7
|
## 2.4.1
|
4
8
|
|
5
9
|
* Regression in EmailReplyPipeline: unfiltered content is being ommitted [#253](https://github.com/jch/html-pipeline/pull/253)
|
data/Gemfile
CHANGED
@@ -6,10 +6,11 @@ gemspec
|
|
6
6
|
group :development do
|
7
7
|
gem "bundler"
|
8
8
|
gem "rake"
|
9
|
+
gem "appraisal"
|
9
10
|
end
|
10
11
|
|
11
12
|
group :test do
|
12
|
-
gem "minitest"
|
13
|
+
gem "minitest"
|
13
14
|
gem "rinku", "~> 1.7", :require => false
|
14
15
|
gem "gemoji", "~> 2.0", :require => false
|
15
16
|
gem "RedCloth", "~> 4.2.9", :require => false
|
data/Rakefile
CHANGED
data/html-pipeline.gemspec
CHANGED
@@ -11,12 +11,11 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.summary = %q{Helpers for processing content through a chain of filters}
|
12
12
|
gem.homepage = "https://github.com/jch/html-pipeline"
|
13
13
|
|
14
|
-
gem.files = `git ls-files`.split
|
15
|
-
gem.test_files = gem.files.grep(%r{^test})
|
14
|
+
gem.files = `git ls-files -z`.split("\x0").reject { |f| f =~ %r(^(test|gemfiles|script)/) }
|
16
15
|
gem.require_paths = ["lib"]
|
17
16
|
|
18
17
|
gem.add_dependency "nokogiri", ">= 1.4"
|
19
|
-
gem.add_dependency "activesupport",
|
18
|
+
gem.add_dependency "activesupport", ">= 2"
|
20
19
|
|
21
20
|
gem.post_install_message = <<msg
|
22
21
|
-------------------------------------------------
|
@@ -14,6 +14,7 @@ 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
|
# :ignored_ancestor_tags (optional) - Tags to stop the emojification. Node has matched ancestor HTML tags will not be emojified. Default to pre, code, and tt tags. Extra tags please pass in the form of array, e.g., %w(blockquote summary).
|
17
|
+
# :img_attrs (optional) - Attributes for generated img tag. E.g. Pass { "draggble" => true, "height" => nil } to set draggable attribute to "true" and clear height attribute of generated img tag.
|
17
18
|
class EmojiFilter < Filter
|
18
19
|
|
19
20
|
DEFAULT_IGNORED_ANCESTOR_TAGS = %w(pre code tt).freeze
|
@@ -71,7 +72,27 @@ module HTML
|
|
71
72
|
|
72
73
|
# Build an emoji image tag
|
73
74
|
def emoji_image_tag(name)
|
74
|
-
|
75
|
+
require "active_support/core_ext/hash/indifferent_access"
|
76
|
+
html_attrs =
|
77
|
+
default_img_attrs(name).
|
78
|
+
merge!((context[:img_attrs] || {}).with_indifferent_access).
|
79
|
+
map { |attr, value| !value.nil? && %(#{attr}="#{value.respond_to?(:call) && value.call(name) || value}") }.
|
80
|
+
reject(&:blank?).join(" ".freeze)
|
81
|
+
|
82
|
+
"<img #{html_attrs}>"
|
83
|
+
end
|
84
|
+
|
85
|
+
# Default attributes for img tag
|
86
|
+
def default_img_attrs(name)
|
87
|
+
{
|
88
|
+
"class" => "emoji".freeze,
|
89
|
+
"title" => ":#{name}:",
|
90
|
+
"alt" => ":#{name}:",
|
91
|
+
"src" => "#{emoji_url(name)}",
|
92
|
+
"height" => "20".freeze,
|
93
|
+
"width" => "20".freeze,
|
94
|
+
"align" => "absmiddle".freeze,
|
95
|
+
}
|
75
96
|
end
|
76
97
|
|
77
98
|
def emoji_url(name)
|
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: 2.4.
|
4
|
+
version: 2.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Tomayko
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-07-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -32,9 +32,6 @@ dependencies:
|
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '2'
|
35
|
-
- - "<"
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '5'
|
38
35
|
type: :runtime
|
39
36
|
prerelease: false
|
40
37
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,9 +39,6 @@ dependencies:
|
|
42
39
|
- - ">="
|
43
40
|
- !ruby/object:Gem::Version
|
44
41
|
version: '2'
|
45
|
-
- - "<"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '5'
|
48
42
|
description: GitHub HTML processing filters and utilities
|
49
43
|
email:
|
50
44
|
- ryan@github.com
|
@@ -55,6 +49,7 @@ extra_rdoc_files: []
|
|
55
49
|
files:
|
56
50
|
- ".gitignore"
|
57
51
|
- ".travis.yml"
|
52
|
+
- Appraisals
|
58
53
|
- CHANGELOG.md
|
59
54
|
- CONTRIBUTING.md
|
60
55
|
- Gemfile
|
@@ -83,26 +78,6 @@ files:
|
|
83
78
|
- lib/html/pipeline/textile_filter.rb
|
84
79
|
- lib/html/pipeline/toc_filter.rb
|
85
80
|
- lib/html/pipeline/version.rb
|
86
|
-
- script/changelog
|
87
|
-
- script/package
|
88
|
-
- script/release
|
89
|
-
- test/helpers/mocked_instrumentation_service.rb
|
90
|
-
- test/html/pipeline/absolute_source_filter_test.rb
|
91
|
-
- test/html/pipeline/autolink_filter_test.rb
|
92
|
-
- test/html/pipeline/camo_filter_test.rb
|
93
|
-
- test/html/pipeline/email_reply_filter_test.rb
|
94
|
-
- test/html/pipeline/emoji_filter_test.rb
|
95
|
-
- test/html/pipeline/https_filter_test.rb
|
96
|
-
- test/html/pipeline/image_filter_test.rb
|
97
|
-
- test/html/pipeline/image_max_width_filter_test.rb
|
98
|
-
- test/html/pipeline/markdown_filter_test.rb
|
99
|
-
- test/html/pipeline/mention_filter_test.rb
|
100
|
-
- test/html/pipeline/plain_text_input_filter_test.rb
|
101
|
-
- test/html/pipeline/sanitization_filter_test.rb
|
102
|
-
- test/html/pipeline/syntax_highlight_filter_test.rb
|
103
|
-
- test/html/pipeline/toc_filter_test.rb
|
104
|
-
- test/html/pipeline_test.rb
|
105
|
-
- test/test_helper.rb
|
106
81
|
homepage: https://github.com/jch/html-pipeline
|
107
82
|
licenses:
|
108
83
|
- MIT
|
@@ -133,21 +108,4 @@ rubygems_version: 2.5.1
|
|
133
108
|
signing_key:
|
134
109
|
specification_version: 4
|
135
110
|
summary: Helpers for processing content through a chain of filters
|
136
|
-
test_files:
|
137
|
-
- test/helpers/mocked_instrumentation_service.rb
|
138
|
-
- test/html/pipeline/absolute_source_filter_test.rb
|
139
|
-
- test/html/pipeline/autolink_filter_test.rb
|
140
|
-
- test/html/pipeline/camo_filter_test.rb
|
141
|
-
- test/html/pipeline/email_reply_filter_test.rb
|
142
|
-
- test/html/pipeline/emoji_filter_test.rb
|
143
|
-
- test/html/pipeline/https_filter_test.rb
|
144
|
-
- test/html/pipeline/image_filter_test.rb
|
145
|
-
- test/html/pipeline/image_max_width_filter_test.rb
|
146
|
-
- test/html/pipeline/markdown_filter_test.rb
|
147
|
-
- test/html/pipeline/mention_filter_test.rb
|
148
|
-
- test/html/pipeline/plain_text_input_filter_test.rb
|
149
|
-
- test/html/pipeline/sanitization_filter_test.rb
|
150
|
-
- test/html/pipeline/syntax_highlight_filter_test.rb
|
151
|
-
- test/html/pipeline/toc_filter_test.rb
|
152
|
-
- test/html/pipeline_test.rb
|
153
|
-
- test/test_helper.rb
|
111
|
+
test_files: []
|
data/script/changelog
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
# Usage: script/changelog [-r <repo>] [-b <base>] [-h <head>]
|
3
|
-
#
|
4
|
-
# repo: base string of GitHub repository url. e.g. "user_or_org/repository". Defaults to git remote url.
|
5
|
-
# base: git ref to compare from. e.g. "v1.3.1". Defaults to latest git tag.
|
6
|
-
# head: git ref to compare to. Defaults to "HEAD".
|
7
|
-
#
|
8
|
-
# Generate a changelog preview from pull requests merged between `base` and
|
9
|
-
# `head`.
|
10
|
-
#
|
11
|
-
# https://github.com/jch/release-scripts/blob/master/changelog
|
12
|
-
set -e
|
13
|
-
|
14
|
-
[ $# -eq 0 ] && set -- --help
|
15
|
-
while [[ $# > 1 ]]
|
16
|
-
do
|
17
|
-
key="$1"
|
18
|
-
case $key in
|
19
|
-
-r|--repo)
|
20
|
-
repo="$2"
|
21
|
-
shift
|
22
|
-
;;
|
23
|
-
-b|--base)
|
24
|
-
base="$2"
|
25
|
-
shift
|
26
|
-
;;
|
27
|
-
-h|--head)
|
28
|
-
head="$2"
|
29
|
-
shift
|
30
|
-
;;
|
31
|
-
*)
|
32
|
-
;;
|
33
|
-
esac
|
34
|
-
shift
|
35
|
-
done
|
36
|
-
|
37
|
-
repo="${repo:-$(git remote -v | grep push | awk '{print $2}' | cut -d'/' -f4- | sed 's/\.git//')}"
|
38
|
-
base="${base:-$(git tag -l | sort -t. -k 1,1n -k 2,2n -k 3,3n | tail -n 1)}"
|
39
|
-
head="${head:-HEAD}"
|
40
|
-
api_url="https://api.github.com"
|
41
|
-
|
42
|
-
# get merged PR's. Better way is to query the API for these, but this is easier
|
43
|
-
for pr in $(git log --oneline $base..$head | grep "Merge pull request" | awk '{gsub("#",""); print $5}')
|
44
|
-
do
|
45
|
-
# frustrated with trying to pull out the right values, fell back to ruby
|
46
|
-
curl -s "$api_url/repos/$repo/pulls/$pr" | ruby -rjson -e 'pr=JSON.parse(STDIN.read); puts "* #{pr[%q(title)]} [##{pr[%q(number)]}](#{pr[%q(html_url)]})"'
|
47
|
-
done
|
data/script/package
DELETED
data/script/release
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
# Usage: script/release
|
3
|
-
# Build the package, tag a commit, push it to origin, and then release the
|
4
|
-
# package publicly.
|
5
|
-
|
6
|
-
set -e
|
7
|
-
|
8
|
-
version="$(script/package | grep Version: | awk '{print $2}')"
|
9
|
-
[ -n "$version" ] || exit 1
|
10
|
-
|
11
|
-
echo $version
|
12
|
-
git commit --allow-empty -a -m "Release $version"
|
13
|
-
git tag "v$version"
|
14
|
-
git push origin
|
15
|
-
git push origin "v$version"
|
16
|
-
gem push pkg/*-${version}.gem
|
@@ -1,17 +0,0 @@
|
|
1
|
-
class MockedInstrumentationService
|
2
|
-
attr_reader :events
|
3
|
-
def initialize(event = nil, events = [])
|
4
|
-
@events = events
|
5
|
-
subscribe event
|
6
|
-
end
|
7
|
-
def instrument(event, payload = nil)
|
8
|
-
payload ||= {}
|
9
|
-
res = yield payload
|
10
|
-
events << [event, payload, res] if @subscribe == event
|
11
|
-
res
|
12
|
-
end
|
13
|
-
def subscribe(event)
|
14
|
-
@subscribe = event
|
15
|
-
@events
|
16
|
-
end
|
17
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class HTML::Pipeline::AbsoluteSourceFilterTest < Minitest::Test
|
4
|
-
AbsoluteSourceFilter = HTML::Pipeline::AbsoluteSourceFilter
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@image_base_url = 'http://assets.example.com'
|
8
|
-
@image_subpage_url = 'http://blog.example.com/a/post'
|
9
|
-
@options = {
|
10
|
-
:image_base_url => @image_base_url,
|
11
|
-
:image_subpage_url => @image_subpage_url
|
12
|
-
}
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_rewrites_root_urls
|
16
|
-
orig = %(<p><img src="/img.png"></p>)
|
17
|
-
assert_equal "<p><img src=\"#{@image_base_url}/img.png\"></p>",
|
18
|
-
AbsoluteSourceFilter.call(orig, @options).to_s
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_rewrites_relative_urls
|
22
|
-
orig = %(<p><img src="post/img.png"></p>)
|
23
|
-
assert_equal "<p><img src=\"#{@image_subpage_url}/img.png\"></p>",
|
24
|
-
AbsoluteSourceFilter.call(orig, @options).to_s
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_does_not_rewrite_absolute_urls
|
28
|
-
orig = %(<p><img src="http://other.example.com/img.png"></p>)
|
29
|
-
result = AbsoluteSourceFilter.call(orig, @options).to_s
|
30
|
-
refute_match /@image_base_url/, result
|
31
|
-
refute_match /@image_subpage_url/, result
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_fails_when_context_is_missing
|
35
|
-
assert_raises RuntimeError do
|
36
|
-
AbsoluteSourceFilter.call("<img src=\"img.png\">", {})
|
37
|
-
end
|
38
|
-
assert_raises RuntimeError do
|
39
|
-
AbsoluteSourceFilter.call("<img src=\"/img.png\">", {})
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_tells_you_where_context_is_required
|
44
|
-
exception = assert_raises(RuntimeError) {
|
45
|
-
AbsoluteSourceFilter.call("<img src=\"img.png\">", {})
|
46
|
-
}
|
47
|
-
assert_match 'HTML::Pipeline::AbsoluteSourceFilter', exception.message
|
48
|
-
|
49
|
-
exception = assert_raises(RuntimeError) {
|
50
|
-
AbsoluteSourceFilter.call("<img src=\"/img.png\">", {})
|
51
|
-
}
|
52
|
-
assert_match 'HTML::Pipeline::AbsoluteSourceFilter', exception.message
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
AutolinkFilter = HTML::Pipeline::AutolinkFilter
|
4
|
-
|
5
|
-
class HTML::Pipeline::AutolinkFilterTest < Minitest::Test
|
6
|
-
def test_uses_rinku_for_autolinking
|
7
|
-
# just try to parse a complicated piece of HTML
|
8
|
-
# that Rails auto_link cannot handle
|
9
|
-
assert_equal '<p>"<a href="http://www.github.com">http://www.github.com</a>"</p>',
|
10
|
-
AutolinkFilter.to_html('<p>"http://www.github.com"</p>')
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_autolink_option
|
14
|
-
assert_equal '<p>"http://www.github.com"</p>',
|
15
|
-
AutolinkFilter.to_html('<p>"http://www.github.com"</p>', :autolink => false)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_autolink_link_attr
|
19
|
-
assert_equal '<p>"<a href="http://www.github.com" target="_blank">http://www.github.com</a>"</p>',
|
20
|
-
AutolinkFilter.to_html('<p>"http://www.github.com"</p>', :link_attr => 'target="_blank"')
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_autolink_flags
|
24
|
-
assert_equal '<p>"<a href="http://github">http://github</a>"</p>',
|
25
|
-
AutolinkFilter.to_html('<p>"http://github"</p>', :flags => Rinku::AUTOLINK_SHORT_DOMAINS)
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_autolink_skip_tags
|
29
|
-
assert_equal '<code>"http://github.com"</code>',
|
30
|
-
AutolinkFilter.to_html('<code>"http://github.com"</code>')
|
31
|
-
|
32
|
-
assert_equal '<code>"<a href="http://github.com">http://github.com</a>"</code>',
|
33
|
-
AutolinkFilter.to_html('<code>"http://github.com"</code>', :skip_tags => %w(kbd script))
|
34
|
-
end
|
35
|
-
end
|