middleman-widont 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/middleman-widont.rb +14 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b23f9059dcba0707894f27c1e4c71a4ace42087
|
4
|
+
data.tar.gz: 75db0f228d8d383db0592b987e33769e3519179c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34e5e7b474a2486dd90092c9784184c74e992f5c85fb029ea8f39e58a105f97e8c4b3e72520840356063e6d8a0ef86c1d619a2ba1b6a11d4ef28cbb4a2d52899
|
7
|
+
data.tar.gz: ba6ab14cc29ccc0fe87d6f95ac39a6c11cc92a0bcb3da37ce18ca34d37c3e7e758ee4d4ed2a13c9b05248a0855b1c8b3ea3bafaa9d9291a704a354d889d54556
|
data/lib/middleman-widont.rb
CHANGED
@@ -2,7 +2,7 @@ require "middleman-core"
|
|
2
2
|
require "nokogiri"
|
3
3
|
|
4
4
|
class Widont < ::Middleman::Extension
|
5
|
-
VERSION = "1.0.
|
5
|
+
VERSION = "1.0.4"
|
6
6
|
|
7
7
|
option :nbsp, "\u00A0", "String to use between the last two words"
|
8
8
|
option :tags, %w[p h1 h2 h3 h4 h5 h6], "Tags to apply widont"
|
@@ -23,20 +23,20 @@ class Widont < ::Middleman::Extension
|
|
23
23
|
|
24
24
|
type = headers.fetch("Content-Type", "application/octet-stream").split(";").first
|
25
25
|
path = env["PATH_INFO"]
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
26
|
+
if %w[text/html application/xhtml+xml].include?(type)
|
27
|
+
use_xml = type == "application/xhtml+xml"
|
28
|
+
html = ::Middleman::Util.extract_response_text(response)
|
29
|
+
html_doc = use_xml ? Nokogiri::XML(html) : Nokogiri::HTML(html)
|
30
|
+
|
31
|
+
html_doc.css(@tags.join(", ")).each do |tag|
|
32
|
+
content = tag.inner_html.strip
|
33
|
+
index = content.rindex(/\s/)
|
34
|
+
if index
|
35
|
+
content[index] = @nbsp
|
36
|
+
tag.inner_html = content
|
37
|
+
end
|
38
38
|
end
|
39
|
-
response = html_doc.to_html
|
39
|
+
response = use_xml ? html_doc.to_xml : html_doc.to_html
|
40
40
|
end
|
41
41
|
|
42
42
|
if response.is_a?(String)
|
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.
|
4
|
+
version: 1.0.4
|
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-
|
11
|
+
date: 2015-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: middleman-core
|