html-pipeline 0.3.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 398dde5c696c319791f1591c1df00abde348028b
4
+ data.tar.gz: 55dc9f47d97a18ab166a5fb6016fb4de28611c13
5
+ SHA512:
6
+ metadata.gz: c3f317bb8ca4615276a9ea0caf6f5d48e5bb9fd4d92b1dc5073cf65d7601e155d3e8bc55b12339dc4eb30eb8d82defb1fbc6219408987bf2e7ecb2bf55a2e057
7
+ data.tar.gz: 8b40cc7d0b8d3bae252d565e7ac929b4b194659ad2d284657db7ee09a98bda81c14b300484f81a65395dca1847ebc7c138e9fc2a9d67dbab81350c7badfc3f6f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.0.0
4
+
5
+ To upgrade to this release, you will need to include separate gems for each of
6
+ the filters. See [this section of the README](/README.md#dependencies) for
7
+ details.
8
+
9
+ * filter dependencies are no longer included #80 from simeonwillbanks/simple-dependency-management
10
+ * Add link_attr option to Autolink filter #89 from excid3/master
11
+ * Add ActiveSupport back in as dependency for xml-mini #85 from mojavelinux/xml-mini
12
+
3
13
  ## 0.3.1
4
14
 
5
15
  * Guard against nil node replacement in SyntaxHighlightFilter #84 jbarnette
data/Gemfile CHANGED
@@ -1,9 +1,24 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in html-pipeline.gemspec
4
4
  gemspec
5
5
 
6
6
  group :development do
7
- gem 'bundler'
8
- gem 'rake'
7
+ gem "bundler"
8
+ gem "rake"
9
+ end
10
+
11
+ group :test do
12
+ gem "rinku", "~> 1.7", :require => false
13
+ gem "gemoji", "~> 1.0", :require => false
14
+ gem "RedCloth", "~> 4.2.9", :require => false
15
+ gem "escape_utils", "~> 0.3", :require => false
16
+ gem "github-linguist", "~> 2.6.2", :require => false
17
+ gem "github-markdown", "~> 0.5", :require => false
18
+
19
+ if RUBY_VERSION < "1.9.2"
20
+ gem "sanitize", ">= 2", "< 2.0.4", :require => false
21
+ else
22
+ gem "sanitize", "~> 2.0", :require => false
23
+ end
9
24
  end
data/README.md CHANGED
@@ -98,18 +98,38 @@ filter.call
98
98
  * `TextileFilter` - convert textile to html
99
99
  * `TableOfContentsFilter` - anchor headings with name attributes and generate Table of Contents html unordered list linking headings
100
100
 
101
- ## Syntax highlighting
101
+ ## Dependencies
102
102
 
103
+ Filter gem dependencies are not bundled; you must bundle the filter's gem
104
+ dependencies. The below list details filters with dependencies. For example,
103
105
  `SyntaxHighlightFilter` uses [github-linguist](https://github.com/github/linguist)
104
- to detect and highlight languages. It isn't included as a dependency by default
105
- because it's a large dependency and
106
- [a hassle to build on heroku](https://github.com/jch/html-pipeline/issues/33).
107
- To use the filter, add the following to your Gemfile:
106
+ to detect and highlight languages. For example, to use the `SyntaxHighlightFilter`,
107
+ add the following to your Gemfile:
108
108
 
109
109
  ```ruby
110
110
  gem 'github-linguist'
111
111
  ```
112
112
 
113
+ * `AutolinkFilter` - `rinku`
114
+ * `EmailReplyFilter` - `escape_utils`
115
+ * `EmojiFilter` - `gemoji`
116
+ * `MarkdownFilter` - `github-markdown`
117
+ * `PlainTextInputFilter` - `escape_utils`
118
+ * `SanitizationFilter` - `sanitize`
119
+ * `SyntaxHighlightFilter` - `github-linguist`
120
+ * `TextileFilter` - `RedCloth`
121
+
122
+ _Note:_ See [Gemfile](/Gemfile) `:test` block for version requirements.
123
+
124
+ ## 3rd Party Extensions
125
+
126
+ If you have an idea for a filter, propose it as
127
+ [an issue](https://github.com/jch/html-pipeline/issues) first. This allows us discuss
128
+ whether the filter is a common enough use case to belong in this gem, or should be
129
+ built as an external gem.
130
+
131
+ * [html-pipeline-asciidoc_filter](https://github.com/asciidoctor/html-pipeline-asciidoc_filter) - asciidoc support
132
+
113
133
  ## Examples
114
134
 
115
135
  We define different pipelines for different parts of our app. Here are a few
data/bin/html-pipeline CHANGED
@@ -54,8 +54,6 @@ else
54
54
  case name
55
55
  when "Text"
56
56
  raise NameError # Text filter doesn't work, no call method
57
- when "Textile"
58
- require "RedCloth" # Textile filter doesn't require RedCloth
59
57
  end
60
58
 
61
59
  HTML::Pipeline.const_get("#{name}Filter")
@@ -77,4 +75,4 @@ context = {
77
75
  :gfm => true
78
76
  }
79
77
 
80
- puts HTML::Pipeline.new(filters, context).call(ARGF.read)[:output]
78
+ puts HTML::Pipeline.new(filters, context).call(ARGF.read)[:output]
@@ -15,13 +15,15 @@ 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 "gemoji", "~> 1.0"
19
- gem.add_dependency "nokogiri", RUBY_VERSION < "1.9.2" ? [">= 1.4", "< 1.6"] : "~> 1.4"
20
- gem.add_dependency "github-markdown", "~> 0.5"
21
- gem.add_dependency "sanitize", RUBY_VERSION < "1.9.2" ? [">= 2", "< 2.0.4"] : "~> 2.0"
22
- gem.add_dependency "rinku", "~> 1.7"
23
- gem.add_dependency "escape_utils", "~> 0.3"
18
+ gem.add_dependency "nokogiri", RUBY_VERSION < "1.9.2" ? [">= 1.4", "< 1.6"] : "~> 1.4"
19
+ gem.add_dependency "activesupport", RUBY_VERSION < "1.9.3" ? [">= 2", "< 4"] : ">= 2"
24
20
 
25
- gem.add_development_dependency "activesupport", RUBY_VERSION < "1.9.3" ? [">= 2", "< 4"] : ">= 2"
26
- gem.add_development_dependency "github-linguist", "~> 2.6.2"
21
+ gem.post_install_message = <<msg
22
+ -------------------------------------------------
23
+ Thank you for installing html-pipeline!
24
+ You must bundle Filter gem dependencies.
25
+ See html-pipeline README.md for more details.
26
+ https://github.com/jch/html-pipeline#dependencies
27
+ -------------------------------------------------
28
+ msg
27
29
  end
data/lib/html/pipeline.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require "nokogiri"
2
2
  require "active_support/xml_mini/nokogiri" # convert Documents to hashes
3
- require "escape_utils"
4
3
 
5
4
  module HTML
6
5
  # GitHub HTML processing filters and utilities. This module includes a small
@@ -1,4 +1,8 @@
1
- require 'rinku'
1
+ begin
2
+ require "rinku"
3
+ rescue LoadError => _
4
+ abort "Missing dependency 'rinku' for AutolinkFilter. See README.md for details."
5
+ end
2
6
 
3
7
  module HTML
4
8
  class Pipeline
@@ -6,6 +10,7 @@ module HTML
6
10
  #
7
11
  # Context options:
8
12
  # :autolink - boolean whether to autolink urls
13
+ # :link_attr - HTML attributes for the link that will be generated
9
14
  # :skip_tags - HTML tags inside which autolinking will be skipped.
10
15
  # See Rinku.skip_tags
11
16
  # :flags - additional Rinku flags. See https://github.com/vmg/rinku
@@ -19,7 +24,7 @@ module HTML
19
24
  flags = 0
20
25
  flags |= context[:flags] if context[:flags]
21
26
 
22
- Rinku.auto_link(html, :urls, nil, skip_tags, flags)
27
+ Rinku.auto_link(html, :urls, context[:link_attr], skip_tags, flags)
23
28
  end
24
29
  end
25
30
  end
@@ -1,3 +1,9 @@
1
+ begin
2
+ require "escape_utils"
3
+ rescue LoadError => _
4
+ abort "Missing dependency 'escape_utils' for EmailReplyFilter. See README.md for details."
5
+ end
6
+
1
7
  module HTML
2
8
  class Pipeline
3
9
  # HTML Filter that converts email reply text into an HTML DocumentFragment.
@@ -53,4 +59,4 @@ module HTML
53
59
  end
54
60
  end
55
61
  end
56
- end
62
+ end
@@ -1,4 +1,8 @@
1
- require 'emoji'
1
+ begin
2
+ require "gemoji"
3
+ rescue LoadError => _
4
+ abort "Missing dependency 'gemoji' for EmojiFilter. See README.md for details."
5
+ end
2
6
 
3
7
  module HTML
4
8
  class Pipeline
@@ -51,4 +55,4 @@ module HTML
51
55
  end
52
56
  end
53
57
  end
54
- end
58
+ end
@@ -1,4 +1,8 @@
1
- require 'github/markdown'
1
+ begin
2
+ require "github/markdown"
3
+ rescue LoadError => _
4
+ abort "Missing dependency 'github-markdown' for MarkdownFilter. See README.md for details."
5
+ end
2
6
 
3
7
  module HTML
4
8
  class Pipeline
@@ -26,4 +30,4 @@ module HTML
26
30
  end
27
31
  end
28
32
  end
29
- end
33
+ end
@@ -1,3 +1,9 @@
1
+ begin
2
+ require "escape_utils"
3
+ rescue LoadError => _
4
+ abort "Missing dependency 'escape_utils' for PlainTextInputFilter. See README.md for details."
5
+ end
6
+
1
7
  module HTML
2
8
  class Pipeline
3
9
  # Simple filter for plain text input. HTML escapes the text input and wraps it
@@ -8,4 +14,4 @@ module HTML
8
14
  end
9
15
  end
10
16
  end
11
- end
17
+ end
@@ -1,4 +1,8 @@
1
- require 'sanitize'
1
+ begin
2
+ require "sanitize"
3
+ rescue LoadError => _
4
+ abort "Missing dependency 'sanitize' for SanitizationFilter. See README.md for details."
5
+ end
2
6
 
3
7
  module HTML
4
8
  class Pipeline
@@ -1,7 +1,7 @@
1
1
  begin
2
- require 'linguist'
3
- rescue LoadError
4
- raise LoadError, "You need to install 'github-linguist' before using the SyntaxHighlightFilter. See README.md for details"
2
+ require "linguist"
3
+ rescue LoadError => _
4
+ abort "Missing dependency 'github-linguist' for SyntaxHighlightFilter. See README.md for details."
5
5
  end
6
6
 
7
7
  module HTML
@@ -1,3 +1,9 @@
1
+ begin
2
+ require "redcloth"
3
+ rescue LoadError => _
4
+ abort "Missing dependency 'RedCloth' for TextileFilter. See README.md for details."
5
+ end
6
+
1
7
  module HTML
2
8
  class Pipeline
3
9
  # HTML Filter that converts Textile text into HTML and converts into a
@@ -18,4 +24,4 @@ module HTML
18
24
  end
19
25
  end
20
26
  end
21
- end
27
+ end
@@ -1,5 +1,5 @@
1
1
  module HTML
2
2
  class Pipeline
3
- VERSION = "0.3.1"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
@@ -15,6 +15,11 @@ class HTML::Pipeline::AutolinkFilterTest < Test::Unit::TestCase
15
15
  AutolinkFilter.to_html('<p>"http://www.github.com"</p>', :autolink => false)
16
16
  end
17
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
+
18
23
  def test_autolink_flags
19
24
  assert_equal '<p>"<a href="http://github">http://github</a>"</p>',
20
25
  AutolinkFilter.to_html('<p>"http://github"</p>', :flags => Rinku::AUTOLINK_SHORT_DOMAINS)
data/test/test_helper.rb CHANGED
@@ -2,6 +2,7 @@ require 'bundler/setup'
2
2
  require 'html/pipeline'
3
3
  require 'test/unit'
4
4
 
5
+ require 'active_support/core_ext/string'
5
6
  require 'active_support/core_ext/object/try'
6
7
 
7
8
  module TestHelpers
@@ -35,4 +36,4 @@ module TestHelpers
35
36
  end
36
37
  end
37
38
 
38
- Test::Unit::TestCase.send(:include, TestHelpers)
39
+ Test::Unit::TestCase.send(:include, TestHelpers)
metadata CHANGED
@@ -1,175 +1,52 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: html-pipeline
3
- version: !ruby/object:Gem::Version
4
- hash: 17
5
- prerelease:
6
- segments:
7
- - 0
8
- - 3
9
- - 1
10
- version: 0.3.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Ryan Tomayko
14
8
  - Jerry Cheung
15
9
  autorequire:
16
10
  bindir: bin
17
11
  cert_chain: []
18
-
19
- date: 2013-09-16 00:00:00 -07:00
20
- default_executable:
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
26
- - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 15
29
- segments:
30
- - 1
31
- - 0
32
- version: "1.0"
33
- type: :runtime
34
- name: gemoji
35
- version_requirements: *id001
36
- prerelease: false
37
- - !ruby/object:Gem::Dependency
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 7
44
- segments:
45
- - 1
46
- - 4
47
- version: "1.4"
48
- - - <
49
- - !ruby/object:Gem::Version
50
- hash: 3
51
- segments:
52
- - 1
53
- - 6
54
- version: "1.6"
55
- type: :runtime
12
+ date: 2013-10-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
56
15
  name: nokogiri
57
- version_requirements: *id002
58
- prerelease: false
59
- - !ruby/object:Gem::Dependency
60
- requirement: &id003 !ruby/object:Gem::Requirement
61
- none: false
62
- requirements:
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
63
18
  - - ~>
64
- - !ruby/object:Gem::Version
65
- hash: 1
66
- segments:
67
- - 0
68
- - 5
69
- version: "0.5"
70
- type: :runtime
71
- name: github-markdown
72
- version_requirements: *id003
73
- prerelease: false
74
- - !ruby/object:Gem::Dependency
75
- requirement: &id004 !ruby/object:Gem::Requirement
76
- none: false
77
- requirements:
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- hash: 7
81
- segments:
82
- - 2
83
- version: "2"
84
- - - <
85
- - !ruby/object:Gem::Version
86
- hash: 7
87
- segments:
88
- - 2
89
- - 0
90
- - 4
91
- version: 2.0.4
19
+ - !ruby/object:Gem::Version
20
+ version: '1.4'
92
21
  type: :runtime
93
- name: sanitize
94
- version_requirements: *id004
95
22
  prerelease: false
96
- - !ruby/object:Gem::Dependency
97
- requirement: &id005 !ruby/object:Gem::Requirement
98
- none: false
99
- requirements:
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
100
25
  - - ~>
101
- - !ruby/object:Gem::Version
102
- hash: 1
103
- segments:
104
- - 1
105
- - 7
106
- version: "1.7"
107
- type: :runtime
108
- name: rinku
109
- version_requirements: *id005
110
- prerelease: false
111
- - !ruby/object:Gem::Dependency
112
- requirement: &id006 !ruby/object:Gem::Requirement
113
- none: false
114
- requirements:
115
- - - ~>
116
- - !ruby/object:Gem::Version
117
- hash: 13
118
- segments:
119
- - 0
120
- - 3
121
- version: "0.3"
122
- type: :runtime
123
- name: escape_utils
124
- version_requirements: *id006
125
- prerelease: false
126
- - !ruby/object:Gem::Dependency
127
- requirement: &id007 !ruby/object:Gem::Requirement
128
- none: false
129
- requirements:
130
- - - ">="
131
- - !ruby/object:Gem::Version
132
- hash: 7
133
- segments:
134
- - 2
135
- version: "2"
136
- - - <
137
- - !ruby/object:Gem::Version
138
- hash: 11
139
- segments:
140
- - 4
141
- version: "4"
142
- type: :development
26
+ - !ruby/object:Gem::Version
27
+ version: '1.4'
28
+ - !ruby/object:Gem::Dependency
143
29
  name: activesupport
144
- version_requirements: *id007
145
- prerelease: false
146
- - !ruby/object:Gem::Dependency
147
- requirement: &id008 !ruby/object:Gem::Requirement
148
- none: false
149
- requirements:
150
- - - ~>
151
- - !ruby/object:Gem::Version
152
- hash: 19
153
- segments:
154
- - 2
155
- - 6
156
- - 2
157
- version: 2.6.2
158
- type: :development
159
- name: github-linguist
160
- version_requirements: *id008
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '2'
35
+ type: :runtime
161
36
  prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '2'
162
42
  description: GitHub HTML processing filters and utilities
163
- email:
43
+ email:
164
44
  - ryan@github.com
165
45
  - jerry@github.com
166
46
  executables: []
167
-
168
47
  extensions: []
169
-
170
48
  extra_rdoc_files: []
171
-
172
- files:
49
+ files:
173
50
  - .gitignore
174
51
  - .travis.yml
175
52
  - CHANGELOG.md
@@ -212,41 +89,37 @@ files:
212
89
  - test/html/pipeline/toc_filter_test.rb
213
90
  - test/html/pipeline_test.rb
214
91
  - test/test_helper.rb
215
- has_rdoc: true
216
92
  homepage: https://github.com/jch/html-pipeline
217
- licenses:
93
+ licenses:
218
94
  - MIT
219
- post_install_message:
95
+ metadata: {}
96
+ post_install_message: |
97
+ -------------------------------------------------
98
+ Thank you for installing html-pipeline!
99
+ You must bundle Filter gem dependencies.
100
+ See html-pipeline README.md for more details.
101
+ https://github.com/jch/html-pipeline#dependencies
102
+ -------------------------------------------------
220
103
  rdoc_options: []
221
-
222
- require_paths:
104
+ require_paths:
223
105
  - lib
224
- required_ruby_version: !ruby/object:Gem::Requirement
225
- none: false
226
- requirements:
227
- - - ">="
228
- - !ruby/object:Gem::Version
229
- hash: 3
230
- segments:
231
- - 0
232
- version: "0"
233
- required_rubygems_version: !ruby/object:Gem::Requirement
234
- none: false
235
- requirements:
236
- - - ">="
237
- - !ruby/object:Gem::Version
238
- hash: 3
239
- segments:
240
- - 0
241
- version: "0"
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
242
116
  requirements: []
243
-
244
117
  rubyforge_project:
245
- rubygems_version: 1.6.2
118
+ rubygems_version: 2.0.3
246
119
  signing_key:
247
- specification_version: 3
120
+ specification_version: 4
248
121
  summary: Helpers for processing content through a chain of filters
249
- test_files:
122
+ test_files:
250
123
  - test/helpers/mocked_instrumentation_service.rb
251
124
  - test/html/pipeline/absolute_source_filter_test.rb
252
125
  - test/html/pipeline/autolink_filter_test.rb