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 +4 -4
- data/lib/jekyll/autoembed.rb +15 -3
- data/lib/jekyll/autoembed/version.rb +1 -1
- 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: 3d03b962f5da0d38710d38e2658e0cf3eb61a0b6
|
4
|
+
data.tar.gz: d602bcb1fe7c887efd88fb72c53da6cf7d90a4df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd20642b5cb2aad14c721fb6a5b7a38ad87d84ff0988b475d3237d6a1f51ed1ca167514a844172abfbf03d83bcd57a49729a203ae829bd143aa6eb9f12c210ff
|
7
|
+
data.tar.gz: 2ed74096bab7b9771d63409595ac58d9273579a4ff4d961cc12eb320054683f7225d985386677efd2881d81fd7085181214b1246dface3a5b164d49595776216
|
data/lib/jekyll/autoembed.rb
CHANGED
@@ -4,15 +4,27 @@ require 'nokogiri'
|
|
4
4
|
module Jekyll
|
5
5
|
module Autoembed
|
6
6
|
def self.execute(doc)
|
7
|
-
|
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)
|
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.
|
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
|
+
date: 2016-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|