jekyll-extract-element 0.0.1

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 +7 -0
  2. data/lib/jekyll-extract-element.rb +20 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a9041dede1ae84a2b4ff9103ef95220bc38d5ab0
4
+ data.tar.gz: db26e567b47e2d0e7e181ad108315e6e8ed29c7f
5
+ SHA512:
6
+ metadata.gz: f5608448a0b5281cfe5393fdda0426ab882e18e0add2d79ba0e2cb591b6171df1c3f9830c693d39fd47b391e16a5c6bd0e182932ba6035ebef49566d3083ce6d
7
+ data.tar.gz: 3db5e48f6e8f1656aca3b9ad2dbdae1a5ac6254a9abbefd47680e05b5b634b197643f941d6077b198660348ebdc3ba103289792c585625864ef52f432de5f4f0
@@ -0,0 +1,20 @@
1
+ require 'nokogiri'
2
+
3
+ module JekyllExtractElement
4
+ def extract_html(html, element)
5
+ entries = []
6
+ @doc = Nokogiri::HTML::DocumentFragment.parse(html)
7
+
8
+ @doc.css(element).each do |node|
9
+ entries << {
10
+ "text" => node.text,
11
+ "node_name" => node.name,
12
+ "id" => node.attr("id")
13
+ }
14
+ end
15
+
16
+ entries
17
+ end
18
+ end
19
+
20
+ Liquid::Template.register_filter(JekyllHTMLElement)
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-extract-element
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mike Neumegen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-02-02 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: ''
14
+ email: mike@cloudcannon.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/jekyll-extract-element.rb
20
+ homepage: http://rubygems.org/gems/jekyll-extract-element
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.4.5.1
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Extracts a particular element from HTML content
44
+ test_files: []