jekyll-autoembed 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: 16e9538c8bb112d99993c53b34647f9f159743c1
4
- data.tar.gz: 22607032fdc6268c327d108de52488906582c56c
3
+ metadata.gz: 3d03b962f5da0d38710d38e2658e0cf3eb61a0b6
4
+ data.tar.gz: d602bcb1fe7c887efd88fb72c53da6cf7d90a4df
5
5
  SHA512:
6
- metadata.gz: 2b25cbd471599bfc365860914dc5d7966ba1998066c828d1b3341f28f43b3d7db7504117305f53144e6633aa98d89157e354178efeb5e47b990ba7696571b0ca
7
- data.tar.gz: 223a9cbd0e7511859c686f85cf493688223a659bed7a54fe962d7ce3615af62e26dc09eec8fb26d87d898cfad97301c9a76544ddc760f4d21703aa35e6feed67
6
+ metadata.gz: bd20642b5cb2aad14c721fb6a5b7a38ad87d84ff0988b475d3237d6a1f51ed1ca167514a844172abfbf03d83bcd57a49729a203ae829bd143aa6eb9f12c210ff
7
+ data.tar.gz: 2ed74096bab7b9771d63409595ac58d9273579a4ff4d961cc12eb320054683f7225d985386677efd2881d81fd7085181214b1246dface3a5b164d49595776216
@@ -4,15 +4,27 @@ require 'nokogiri'
4
4
  module Jekyll
5
5
  module Autoembed
6
6
  def self.execute(doc)
7
- parsed_doc = Nokogiri::HTML::DocumentFragment.parse(doc.output)
7
+
8
+ if doc.output.include? "<body"
9
+ parsed_doc = Nokogiri::HTML::Document.parse(doc.output)
10
+ body = parsed_doc.at_css('body')
11
+ replace_nodes(body)
12
+ else
13
+ parsed_doc = Nokogiri::HTML::DocumentFragment.parse(doc.output)
14
+ replace_nodes(parsed_doc)
15
+ end
16
+
17
+ doc.output = parsed_doc.to_html
18
+ doc
19
+ end
20
+
21
+ def self.replace_nodes(parsed_doc)
8
22
  parsed_doc.search('.//text()').each do |node|
9
23
  content = node.to_html
10
24
  html = autoembed(content)
11
25
  next if html == content
12
26
  node.replace(html)
13
27
  end
14
- doc.output = parsed_doc.to_html
15
- doc
16
28
  end
17
29
 
18
30
  def self.autoembed(content)
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Autoembed
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-autoembed
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
  - Dotan Nahum
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-29 00:00:00.000000000 Z
11
+ date: 2016-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri