middleman-widont 1.0.1 → 1.0.2

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +20 -0
  3. data/README.md +40 -0
  4. data/lib/middleman-widont.rb +4 -3
  5. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36eaab45d1b9e58cc24c37a8b46e48f3b71d2858
4
- data.tar.gz: 081b9d69a2f419361a78d3716c5a4c6ed6b5ff02
3
+ metadata.gz: 96370a7900c7593aa1a3d32417be5847e0274ac6
4
+ data.tar.gz: 210f0439c14be285e54a43e1e8a857cb02ee2ce5
5
5
  SHA512:
6
- metadata.gz: 9b6fc4a0a22931c5d13a59bd8741ca045e1c85990125ff0440ef0139e53c27dbd8abfd08d5998637b4b629e1ac5cf8b3798fb9938a1f4f780e0c39e6de36582b
7
- data.tar.gz: 7c23023653210b196647588d568b75bba43e4b0932b4618bdd508ab8907c4d174bec79c855aa2be3772bef5bc140887fe693f77457a35a9cbc210956bf250175
6
+ metadata.gz: 557d7051de9495038b6358963f3f8a176e85d52446ff66351dd0a0f50d1e1feea28226fe1fb434cc4d28079266e4209d49dcb9e6bdb6180a4fa3001159be1ecc
7
+ data.tar.gz: 2aa86d87c5ae2a353fab1655c6bf19578d244b6eb7a71de20699d6651eee8fde862fe2c0d6d830eb450a26e999c930ac014ebb565a2dcbbed5b8137a2c73b23b
data/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 Jeremy Boles
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -0,0 +1,40 @@
1
+ # Middleman-Widont
2
+
3
+ `middleman-widont` is an extension for [Middleman][1] that removes widows, which
4
+ are single words on a line by itself at the end of a block of text, from for
5
+ specified HTML tags. The plugin was inspired by (and owes its named too) [Shaun
6
+ Inman's][2] old Wordpress plugin from yesteryear.
7
+
8
+ ## Installation
9
+
10
+ Add `gem "middleman-widont"` to your `Gemfile` and run `bundle install`
11
+
12
+ ## Configuration
13
+
14
+ ```ruby
15
+ activate :widont
16
+ ```
17
+
18
+ The tags which to apply Widon't to can be specified:
19
+ ```ruby
20
+ activate :widont, tags: %w[p li]
21
+ ```
22
+
23
+ By default, Widon't places the Unicode non-breaking space character
24
+ ([`\u00A0`][3]) between the first and last words of a block of text. You can
25
+ specify which string you'd like use instead:
26
+ ```ruby
27
+ activate :widont, nbsp: " "
28
+ ```
29
+
30
+ These are the default settings:
31
+ ```ruby
32
+ activate :widont do |widont|
33
+ widont.nbsp = "\u00A0"
34
+ widont.tags = %w[p h1 h2 h3 h4 h5 h6]
35
+ end
36
+ ```
37
+
38
+ [1]: http://middlemanapp.com/
39
+ [2]: http://www.shauninman.com/archive/2006/08/22/widont_wordpress_plugin
40
+ [3]: http://www.fileformat.info/info/unicode/char/a0/index.htm
@@ -2,8 +2,9 @@ require "middleman-core"
2
2
  require "nokogiri"
3
3
 
4
4
  class Widont < ::Middleman::Extension
5
- VERSION = "1.0.1"
5
+ VERSION = "1.0.2"
6
6
 
7
+ option :nbsp, "\u00A0", "String to use between the last two words"
7
8
  option :tags, %w[p h1 h2 h3 h4 h5 h6], "Tags to apply widont"
8
9
 
9
10
  def after_configuration
@@ -13,6 +14,7 @@ class Widont < ::Middleman::Extension
13
14
  class Rack
14
15
  def initialize(app, options={})
15
16
  @app = app
17
+ @nbsp = options[:nbsp]
16
18
  @tags = options[:tags]
17
19
  end
18
20
 
@@ -26,11 +28,10 @@ class Widont < ::Middleman::Extension
26
28
  html = ::Middleman::Util.extract_response_text(response)
27
29
  html_doc = Nokogiri::HTML(html)
28
30
 
29
- space = "\u00A0"
30
31
  html_doc.css(@tags.join(", ")).each do |tag|
31
32
  content = tag.inner_html.strip
32
33
  index = content.rindex(/\s/)
33
- content[index] = space
34
+ content[index] = @nbsp
34
35
  tag.inner_html = content
35
36
  end
36
37
  response = html_doc.to_html
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-widont
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Boles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-07 00:00:00.000000000 Z
11
+ date: 2015-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman-core
@@ -47,6 +47,7 @@ extra_rdoc_files: []
47
47
  files:
48
48
  - ".gitignore"
49
49
  - Gemfile
50
+ - LICENSE.md
50
51
  - README.md
51
52
  - lib/middleman-widont.rb
52
53
  - middleman-widont.gemspec