html-pipeline-abbr 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cd2f77d1c2671b8049eb2fc22eb37a23ee733c18
4
- data.tar.gz: a87f98ce3d7f43032eb84d11c753fecdf06196f1
3
+ metadata.gz: 3cf810f9e3ab99171f6f6d725eea91a08e49b476
4
+ data.tar.gz: aa106ec15f8ad8b533e2ee89a0e588e9bb8fe8b6
5
5
  SHA512:
6
- metadata.gz: b913c06f4f63af85f8fea0e6a2ef83ec5abfcb1e2e86b312ee6e1abf9864e0963507533019db112877847cf014e0cb26841f043a7a64301bbcec66fcf20242b9
7
- data.tar.gz: 01232a4db85b04a369fa55c2d80f3a1c15198aa0928207c910c8288a2aae2bfd2ce35819e1a272f7fb45d559cfe98c5d40b3e9c1eecee9d7ee983c109df9b5dd
6
+ metadata.gz: c064fc9dbf16f8979894cf5a5c07592369d41f46968a073783f5713445856e0f32c6f00db8a9f80d3be612533e1dad095c2e88442c4fdb0a94017fda57e989b5
7
+ data.tar.gz: 64d2467612f80e2faebe70ed8d58bb5bbf2a2a269a89f88c7f7d55ea7bf316dade24baa2ed7bdf87f646137d6bb15b4ce012b5ab490bab55a26f6f6d3ad03287
@@ -0,0 +1,24 @@
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file.
3
+ This project adheres to [Semantic Versioning](http://semver.org/).
4
+
5
+ ## [Unreleased]
6
+
7
+ ## [0.2.0] - 2015-05-25
8
+ ### Added
9
+ - `abbr_emoji_filter` is an `emoji_filter` without the `alt` and `title` attributes. It works better with the `abbr` tag.
10
+ - project references
11
+
12
+ ### Changed
13
+ - renamed `shorten_filter` to `auto_abbr_filter` to match other internet plugins. (nice to know others want this too)
14
+ - lessen bundler dependency to work with more ruby versions
15
+ - more strict substitution boundaries
16
+
17
+ ## [0.1.0] - 2015-05-23
18
+ ### Added
19
+ - `abbr_filter` and `shorten_filter`
20
+ - initial push
21
+
22
+ [unreleased]: https://github.com/kbrock/html-pipeline-abbr/compare/v0.1.0...HEAD
23
+ [0.2.0]: https://github.com/kbrock/html-pipeline-abbr/compare/v0.1.0...v0.2.0
24
+ [0.1.0]: https://github.com/kbrock/html-pipeline-abbr/commits/v0.1.0
data/README.md CHANGED
@@ -28,7 +28,6 @@ Or install it yourself as:
28
28
  pipeline = HTML::Pipeline.new [
29
29
  HTML::Pipeline::MarkdownFilter,
30
30
  HTML::Pipeline::AbbrFilter,
31
- HTML::Pipeline::SyntaxHighlightFilter,
32
31
  ]
33
32
  result = pipeline.call <<-CODE
34
33
  Lets generate some *great* HTML.
@@ -43,13 +42,12 @@ Prints:
43
42
  <p>Lets generate some <strong>great</strong> <abbr title="Hypertxt">HTML</abbr>.</p>
44
43
  ```
45
44
 
46
- On the flip side, there is also the `ShortenFilter` which will find words that can be abbreviated and shorten them.
45
+ On the flip side, there is also the `AutoAbbrFilter` which will find words that can be abbreviated and shorten them.
47
46
 
48
47
  ```ruby
49
48
  pipeline = HTML::Pipeline.new [
50
49
  HTML::Pipeline::MarkdownFilter,
51
- HTML::Pipeline::ShortenFilter,
52
- HTML::Pipeline::SyntaxHighlightFilter,
50
+ HTML::Pipeline::AutoAbbrFilter,
53
51
  ]
54
52
  result = pipeline.call <<-CODE
55
53
  Lets generate some *great* Hypertext.
@@ -15,19 +15,21 @@ Gem::Specification.new do |spec|
15
15
  In the mean time this adds abbr tags}
16
16
  spec.homepage = "http://github.com/kbrock/html-pipeline-abbr/"
17
17
 
18
- # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
19
- # delete this section to allow pushing this gem to any host.
20
18
  if spec.respond_to?(:metadata)
21
- # spec.metadata['allowed_push_host'] = ""
19
+ spec.metadata = {
20
+ "source_code_uri" => "http://github.com/kbrock/html-pipeline-abbr",
21
+ "bug_tracker_uri" => "http://github.com/kbrock/html-pipeline-abbr/issues",
22
+ }
22
23
  end
23
24
 
24
25
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
26
  spec.require_paths = ["lib"]
26
27
 
27
28
  spec.add_dependency "html-pipeline", ">= 1.0"
28
- spec.add_dependency "nokogiri", [">= 1.4", "<= 1.6.5"]
29
+ spec.add_dependency "nokogiri"
30
+ spec.add_dependency "gemoji"
29
31
 
30
- spec.add_development_dependency "bundler", "~> 1.9"
32
+ spec.add_development_dependency "bundler"
31
33
  spec.add_development_dependency "rake", "~> 10.0"
32
34
  spec.add_development_dependency "minitest", "~> 5.3"
33
35
  spec.add_development_dependency "yard", "~> 0.8"
@@ -1,4 +1,5 @@
1
1
  require "html/pipeline"
2
2
  require "html/pipeline/abbr/version"
3
3
  require "html/pipeline/abbr_filter.rb"
4
- require "html/pipeline/shorten_filter.rb"
4
+ require "html/pipeline/auto_abbr_filter.rb"
5
+ require "html/pipeline/abbr_emoji_filter.rb"
@@ -1,7 +1,7 @@
1
1
  module Html
2
2
  module Pipeline
3
3
  module Abbr
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,18 @@
1
+ require 'html/pipeline/emoji_filter'
2
+
3
+ module HTML
4
+ class Pipeline
5
+ # This class is very similar EmojiFilter. It removes the inline
6
+ # width/height attributes so that reveal-ck supplied CSS takes effect.
7
+ class AbbrEmojiFilter < EmojiFilter
8
+ def emoji_image_filter(text)
9
+ return text unless text.include?(':')
10
+
11
+ text.gsub(emoji_pattern) do
12
+ name = Regexp.last_match[1]
13
+ result = "<img class='emoji' src='#{emoji_url(name)}' />"
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -58,7 +58,7 @@ module HTML
58
58
  # @return [String] html with all abbreviations replaced
59
59
  def abbrs_filter(content, abbrs)
60
60
  abbrs.each do |abbr, full|
61
- content = abbr_filter(content, abbr, full) if content.include?(abbr)
61
+ content = abbr_filter(content, abbr, full)
62
62
  end
63
63
  content
64
64
  end
@@ -68,7 +68,7 @@ module HTML
68
68
  # @return [String] html with abbreviation tags
69
69
  def abbr_filter(content, abbr, full)
70
70
  target_html = abbr_tag(abbr, full)
71
- content.gsub(abbr) { |_| target_html }
71
+ content.gsub(/\b#{abbr}\b/) { |_| target_html } || content
72
72
  end
73
73
 
74
74
  # Return html string to use as an abbr tag
@@ -0,0 +1,12 @@
1
+ module HTML
2
+ class Pipeline
3
+ # Similar to abbreviate
4
+ # but it starts with the long format and shortens it
5
+ class AutoAbbrFilter < AbbrFilter
6
+ def abbr_filter(content, abbr, full)
7
+ target_html = abbr_tag(abbr, full)
8
+ content.gsub(/\b#{full}\b/) { |_| target_html } || content
9
+ end
10
+ end
11
+ end
12
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html-pipeline-abbr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keenan Brock
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-24 00:00:00.000000000 Z
11
+ date: 2015-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: html-pipeline
@@ -30,34 +30,42 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.4'
34
- - - "<="
35
- - !ruby/object:Gem::Version
36
- version: 1.6.5
33
+ version: '0'
37
34
  type: :runtime
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
38
  - - ">="
42
39
  - !ruby/object:Gem::Version
43
- version: '1.4'
44
- - - "<="
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: gemoji
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
45
46
  - !ruby/object:Gem::Version
46
- version: 1.6.5
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
47
55
  - !ruby/object:Gem::Dependency
48
56
  name: bundler
49
57
  requirement: !ruby/object:Gem::Requirement
50
58
  requirements:
51
- - - "~>"
59
+ - - ">="
52
60
  - !ruby/object:Gem::Version
53
- version: '1.9'
61
+ version: '0'
54
62
  type: :development
55
63
  prerelease: false
56
64
  version_requirements: !ruby/object:Gem::Requirement
57
65
  requirements:
58
- - - "~>"
66
+ - - ">="
59
67
  - !ruby/object:Gem::Version
60
- version: '1.9'
68
+ version: '0'
61
69
  - !ruby/object:Gem::Dependency
62
70
  name: rake
63
71
  requirement: !ruby/object:Gem::Requirement
@@ -112,6 +120,7 @@ extra_rdoc_files: []
112
120
  files:
113
121
  - ".gitignore"
114
122
  - ".travis.yml"
123
+ - CHANGELOG.md
115
124
  - Gemfile
116
125
  - README.md
117
126
  - Rakefile
@@ -119,11 +128,14 @@ files:
119
128
  - html-pipeline-abbr.gemspec
120
129
  - lib/html/pipeline/abbr.rb
121
130
  - lib/html/pipeline/abbr/version.rb
131
+ - lib/html/pipeline/abbr_emoji_filter.rb
122
132
  - lib/html/pipeline/abbr_filter.rb
123
- - lib/html/pipeline/shorten_filter.rb
133
+ - lib/html/pipeline/auto_abbr_filter.rb
124
134
  homepage: http://github.com/kbrock/html-pipeline-abbr/
125
135
  licenses: []
126
- metadata: {}
136
+ metadata:
137
+ source_code_uri: http://github.com/kbrock/html-pipeline-abbr
138
+ bug_tracker_uri: http://github.com/kbrock/html-pipeline-abbr/issues
127
139
  post_install_message:
128
140
  rdoc_options: []
129
141
  require_paths:
@@ -1,23 +0,0 @@
1
- module HTML
2
- class Pipeline
3
- # Similar to abbreviate
4
- # but it starts with the long format and shortens it
5
- class ShortenFilter < AbbrFilter
6
-
7
- # Return html with abbreviations replaced
8
- #
9
- # @return [String] html with all abbreviations replaced
10
- def abbrs_filter(content, abbrs)
11
- abbrs.each do |abbr, full|
12
- content = abbr_filter(content, abbr, full) if content.include?(full)
13
- end
14
- content
15
- end
16
-
17
- def abbr_filter(content, abbr, full)
18
- target_html = abbr_tag(abbr, full)
19
- content.gsub(full) { |_| target_html }
20
- end
21
- end
22
- end
23
- end