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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/middleman-widont.rb +14 -14
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8581fb267cf0989323f6255b8931888c92972b1c
4
- data.tar.gz: c330bec2a8c1a95ecc6ca368fdeb3febacfc00b1
3
+ metadata.gz: 4b23f9059dcba0707894f27c1e4c71a4ace42087
4
+ data.tar.gz: 75db0f228d8d383db0592b987e33769e3519179c
5
5
  SHA512:
6
- metadata.gz: 255ae567ec4a6f80e1588f637c77632738fa0f2299ce3ead4e03394ccc1187eb4962b65df98877de9fbb9ef81d0be56268c2e3701582c6aec948029a0358ef26
7
- data.tar.gz: 84f8ba31862fe360d39474587fba5a523ac273f67b95fdf9aa1bef694e6631b617de744cc5a7923594334ce17fe41d9af5d195d9f5ae3dc0d4af1f06690606f1
6
+ metadata.gz: 34e5e7b474a2486dd90092c9784184c74e992f5c85fb029ea8f39e58a105f97e8c4b3e72520840356063e6d8a0ef86c1d619a2ba1b6a11d4ef28cbb4a2d52899
7
+ data.tar.gz: ba6ab14cc29ccc0fe87d6f95ac39a6c11cc92a0bcb3da37ce18ca34d37c3e7e758ee4d4ed2a13c9b05248a0855b1c8b3ea3bafaa9d9291a704a354d889d54556
@@ -2,7 +2,7 @@ require "middleman-core"
2
2
  require "nokogiri"
3
3
 
4
4
  class Widont < ::Middleman::Extension
5
- VERSION = "1.0.3"
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
- if type == "text/html"
28
- html = ::Middleman::Util.extract_response_text(response)
29
- html_doc = 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
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.3
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-08-19 00:00:00.000000000 Z
11
+ date: 2015-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman-core