content-pipeline 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/lib/content/pipeline.rb +0 -18
- data/lib/content/pipeline/core_extensions/object_ext.rb +0 -2
- data/lib/content/pipeline/filters.rb +0 -12
- data/lib/content/pipeline/filters/code_highlight.rb +0 -16
- data/lib/content/pipeline/filters/gemoji.rb +0 -14
- data/lib/content/pipeline/filters/markdown.rb +24 -4
- data/lib/content/pipeline/jekyll/converter.rb +2 -10
- data/lib/content/pipeline/version.rb +1 -1
- metadata +47 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99982146710eb42b199f6f0d9af72351654c2477
|
4
|
+
data.tar.gz: 93180e18ff0229a46cd1d21cc78ddf42b4d4e780
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24cef63ca9907370b1f6809eef8464806e75a97df2370100681d33aac94245d31108623f9db673ed7353f6849468de1c8bbd98351df59c71a249c29b85877210
|
7
|
+
data.tar.gz: bf3541baf1aa6e64118515e75a3e17b2ec18acc2d5c5cdf3c35bdd1f3b00161c20b60bf32d3e498de548bee18632ccc9540e0949832bf35258760c0d3d459542
|
data/Gemfile
CHANGED
data/lib/content/pipeline.rb
CHANGED
@@ -6,11 +6,6 @@ module Content
|
|
6
6
|
require_relative "pipeline/filters"
|
7
7
|
attr_reader :filters, :opts
|
8
8
|
|
9
|
-
# -------------------------------------------------------------------------
|
10
|
-
# @arg Array: The filters you would like to use or next:
|
11
|
-
# @arg Hash : Your "default options" that should be "global."
|
12
|
-
# -------------------------------------------------------------------------
|
13
|
-
|
14
9
|
def initialize(filters = nil, opts = nil)
|
15
10
|
if filters.is_a?(Hash) && opts.nil?
|
16
11
|
opts = filters
|
@@ -23,11 +18,6 @@ module Content
|
|
23
18
|
@opts, @filters = opts.freeze, [ filters ].flatten.freeze
|
24
19
|
end
|
25
20
|
|
26
|
-
# -------------------------------------------------------------------------
|
27
|
-
# @arg String: The incomming string that will be modified.
|
28
|
-
# @arg Hash : The secondary opts to override the "defaults".
|
29
|
-
# -------------------------------------------------------------------------
|
30
|
-
|
31
21
|
def filter(out, opts = {})
|
32
22
|
return out if out.nil? || out.empty? || @filters.empty?
|
33
23
|
|
@@ -42,10 +32,6 @@ module Content
|
|
42
32
|
out
|
43
33
|
end
|
44
34
|
|
45
|
-
# -------------------------------------------------------------------------
|
46
|
-
# @arg Object: An object (preferably a class or module.)
|
47
|
-
# -------------------------------------------------------------------------
|
48
|
-
|
49
35
|
private
|
50
36
|
def to_opt(cls)
|
51
37
|
cls = cls.name.split(/::/).last
|
@@ -55,10 +41,6 @@ module Content
|
|
55
41
|
underscore_cls(cls) ].uniq.map(&:to_sym)
|
56
42
|
end
|
57
43
|
|
58
|
-
# -------------------------------------------------------------------------
|
59
|
-
# @arg String: The name of the class you wish to adjust.
|
60
|
-
# -------------------------------------------------------------------------
|
61
|
-
|
62
44
|
private
|
63
45
|
def underscore_cls(cls)
|
64
46
|
(cls[0].downcase + cls[1..-1]).gsub(/([A-Z])/) do
|
@@ -6,8 +6,6 @@ module CoreExtensions
|
|
6
6
|
RbConfig::CONFIG["ruby_install_name"] == "jruby"
|
7
7
|
end
|
8
8
|
|
9
|
-
# -------------------------------------------------------------------------
|
10
|
-
|
11
9
|
def to_nokogiri_fragment
|
12
10
|
return self if self.is_a?(Nokogiri::HTML::DocumentFragment)
|
13
11
|
Nokogiri::HTML.fragment(self.to_s)
|
@@ -10,16 +10,10 @@ class Content::Pipeline
|
|
10
10
|
def_delegator "self.class.filters", :[]
|
11
11
|
def_delegator "self.class", :filters
|
12
12
|
|
13
|
-
# -------------------------------------------------------------------------
|
14
|
-
|
15
13
|
def initialize(str, opts = nil)
|
16
14
|
@opts, @str = (opts || {}), str
|
17
15
|
end
|
18
16
|
|
19
|
-
# -------------------------------------------------------------------------
|
20
|
-
# @arg Array: The next filter in the chain, to check the types.
|
21
|
-
# -------------------------------------------------------------------------
|
22
|
-
|
23
17
|
def run(next_filter = nil)
|
24
18
|
return @str unless size > 0
|
25
19
|
|
@@ -44,10 +38,6 @@ class Content::Pipeline
|
|
44
38
|
class << self
|
45
39
|
attr_reader :filters
|
46
40
|
|
47
|
-
# -----------------------------------------------------------------------
|
48
|
-
# @arg Hash: The filters and the type of input they prefer.
|
49
|
-
# -----------------------------------------------------------------------
|
50
|
-
|
51
41
|
def add_filter(*filters)
|
52
42
|
@filters ||= []
|
53
43
|
|
@@ -69,8 +59,6 @@ class Content::Pipeline
|
|
69
59
|
end
|
70
60
|
end
|
71
61
|
|
72
|
-
# ---------------------------------------------------------------------------
|
73
|
-
|
74
62
|
module Filters
|
75
63
|
require_relative "filters/markdown"
|
76
64
|
DEFAULT_FILTERS = [ Markdown ].freeze
|
@@ -5,8 +5,6 @@ class Content::Pipeline::Filters::CodeHighlight < Content::Pipeline::Filter
|
|
5
5
|
:highlight => :nokogiri
|
6
6
|
})
|
7
7
|
|
8
|
-
# ---------------------------------------------------------------------------
|
9
|
-
|
10
8
|
Matcher = /<pre>(.+)<\/pre>/m
|
11
9
|
Templates = {
|
12
10
|
:numb => %Q{<span class="line-number">%s</span>\n},
|
@@ -35,15 +33,11 @@ class Content::Pipeline::Filters::CodeHighlight < Content::Pipeline::Filter
|
|
35
33
|
HTML
|
36
34
|
}
|
37
35
|
|
38
|
-
# ---------------------------------------------------------------------------
|
39
|
-
|
40
36
|
def initialize(*args)
|
41
37
|
super(*args)
|
42
38
|
@opts[:gutter] = true if @opts[:gutter].nil?
|
43
39
|
end
|
44
40
|
|
45
|
-
# ---------------------------------------------------------------------------
|
46
|
-
|
47
41
|
private
|
48
42
|
def highlight
|
49
43
|
@str = @str.to_nokogiri_fragment
|
@@ -53,11 +47,6 @@ class Content::Pipeline::Filters::CodeHighlight < Content::Pipeline::Filter
|
|
53
47
|
end
|
54
48
|
end
|
55
49
|
|
56
|
-
# ---------------------------------------------------------------------------
|
57
|
-
# @arg String: The "multi-line" string you wish to parse.
|
58
|
-
# @arg String: The "programming language" you wish to highlight as.
|
59
|
-
# ---------------------------------------------------------------------------
|
60
|
-
|
61
50
|
private
|
62
51
|
def wrap(str, lang)
|
63
52
|
lines, numbs = "", ""
|
@@ -81,11 +70,6 @@ class Content::Pipeline::Filters::CodeHighlight < Content::Pipeline::Filter
|
|
81
70
|
end
|
82
71
|
end
|
83
72
|
|
84
|
-
# ---------------------------------------------------------------------------
|
85
|
-
# @arg String: The "multi-line" string you wish to highlight.
|
86
|
-
# @arg String: The lang you wish to use when highlighting the string.
|
87
|
-
# ---------------------------------------------------------------------------
|
88
|
-
|
89
73
|
private
|
90
74
|
def pygments(str, lang)
|
91
75
|
return str if jruby? || ! Pygments::Lexer[lang]
|
@@ -10,22 +10,12 @@ class Content::Pipeline::Filters::Gemoji < Content::Pipeline::Filter
|
|
10
10
|
:gemoji => :nokogiri
|
11
11
|
})
|
12
12
|
|
13
|
-
# ---------------------------------------------------------------------------
|
14
|
-
# This is a simple wrapper method around the default initialize.
|
15
|
-
# ---------------------------------------------------------------------------
|
16
|
-
|
17
13
|
def initialize(*args)
|
18
14
|
super(*args)
|
19
15
|
# I should make this an addon.
|
20
16
|
@opts[:asset_path] ||= "/assets"
|
21
17
|
end
|
22
18
|
|
23
|
-
# ---------------------------------------------------------------------------
|
24
|
-
# Because of the way that Nokogiri behaves we need to go out of our
|
25
|
-
# way and ensure that we capture both text nodes in the root and
|
26
|
-
# text nodes in elements (such as paragraphs and shit like that...)
|
27
|
-
# ---------------------------------------------------------------------------
|
28
|
-
|
29
19
|
private
|
30
20
|
def gemoji
|
31
21
|
@str = @str.to_nokogiri_fragment
|
@@ -36,10 +26,6 @@ class Content::Pipeline::Filters::Gemoji < Content::Pipeline::Filter
|
|
36
26
|
end
|
37
27
|
end
|
38
28
|
|
39
|
-
# ---------------------------------------------------------------------------
|
40
|
-
# @arg Nokogiri::XML::Text: The Text node you wish to parse.
|
41
|
-
# ---------------------------------------------------------------------------
|
42
|
-
|
43
29
|
def parse_node(node)
|
44
30
|
return node if node.ancestors.any? do |n|
|
45
31
|
n.node_name == "code" || n.node_name == "pre"
|
@@ -20,11 +20,14 @@ class Content::Pipeline::Filters::Markdown < Content::Pipeline::Filter
|
|
20
20
|
@type = @opts.fetch(:type, default)
|
21
21
|
@str = backtick(@str)
|
22
22
|
@str = case
|
23
|
+
when @type =~ /\Akramdown\Z/ then parse_kramdown
|
23
24
|
when @type =~ /\Agithub|gfm\Z/ then parse_github
|
24
|
-
when @type =~ /\
|
25
|
+
when @type =~ /\Aredcarpet\Z/ then parse_redcarpet
|
25
26
|
when @type =~ /\Amarkdown|md\Z/
|
26
|
-
begin
|
27
|
-
parse_kramdown
|
27
|
+
begin parse_redcarpet; rescue LoadError
|
28
|
+
begin parse_kramdown; rescue LoadError
|
29
|
+
parse_github
|
30
|
+
end
|
28
31
|
end
|
29
32
|
else
|
30
33
|
# Actually needed now days.
|
@@ -32,6 +35,19 @@ class Content::Pipeline::Filters::Markdown < Content::Pipeline::Filter
|
|
32
35
|
end
|
33
36
|
end
|
34
37
|
|
38
|
+
private
|
39
|
+
def parse_redcarpet
|
40
|
+
require "redcarpet"
|
41
|
+
with = Redcarpet::Render::HTML
|
42
|
+
(@opts[:parser_opts] ||= {}).merge!({
|
43
|
+
:fenced_code_blocks => true
|
44
|
+
})
|
45
|
+
|
46
|
+
Redcarpet::Markdown.new(with, @opts[:parser_opts]).render(
|
47
|
+
@str
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
35
51
|
private
|
36
52
|
def parse_github
|
37
53
|
require "github/markdown"
|
@@ -40,8 +56,12 @@ class Content::Pipeline::Filters::Markdown < Content::Pipeline::Filter
|
|
40
56
|
|
41
57
|
private
|
42
58
|
def parse_kramdown
|
59
|
+
(@opts[:parser_opts] ||= {}).merge!({
|
60
|
+
:enable_coderay => false
|
61
|
+
})
|
62
|
+
|
43
63
|
require "kramdown"
|
44
|
-
str = Kramdown::Document.new(@str, :
|
64
|
+
str = Kramdown::Document.new(@str, @opts[:parser_opts])
|
45
65
|
normalize_kramdown(str.to_html).strip
|
46
66
|
end
|
47
67
|
|
@@ -2,26 +2,18 @@ require "content/pipeline"
|
|
2
2
|
|
3
3
|
module Content::Pipeline::Jekyll
|
4
4
|
class Converter < Jekyll::Converter
|
5
|
-
|
5
|
+
ContentPipeline = Content::Pipeline.new
|
6
6
|
|
7
7
|
def matches(ext)
|
8
8
|
ext =~ /\.(md|markdown)\Z/
|
9
9
|
end
|
10
10
|
|
11
|
-
# -------------------------------------------------------------------------
|
12
|
-
|
13
11
|
def output_ext(ext)
|
14
12
|
".html"
|
15
13
|
end
|
16
14
|
|
17
|
-
# -------------------------------------------------------------------------
|
18
|
-
# It should be noted that MARKDOWN_CONVERTOR uses the default options
|
19
|
-
# provided by Content::Pipeline at:
|
20
|
-
# https://github.com/envygeeks/content-pipeline
|
21
|
-
# -------------------------------------------------------------------------
|
22
|
-
|
23
15
|
def convert(data)
|
24
|
-
|
16
|
+
ContentPipeline.filter(data)
|
25
17
|
end
|
26
18
|
end
|
27
19
|
end
|
metadata
CHANGED
@@ -1,126 +1,126 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: content-pipeline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordon Bedwell
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
15
|
-
version_requirements: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ~>
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.6'
|
20
15
|
requirement: !ruby/object:Gem::Requirement
|
21
16
|
requirements:
|
22
|
-
- - ~>
|
17
|
+
- - "~>"
|
23
18
|
- !ruby/object:Gem::Version
|
24
19
|
version: '1.6'
|
25
|
-
prerelease: false
|
26
20
|
type: :runtime
|
27
|
-
|
28
|
-
name: rspec
|
21
|
+
prerelease: false
|
29
22
|
version_requirements: !ruby/object:Gem::Requirement
|
30
23
|
requirements:
|
31
|
-
- - ~>
|
24
|
+
- - "~>"
|
32
25
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
34
29
|
requirement: !ruby/object:Gem::Requirement
|
35
30
|
requirements:
|
36
|
-
- - ~>
|
31
|
+
- - "~>"
|
37
32
|
- !ruby/object:Gem::Version
|
38
33
|
version: '3.0'
|
39
|
-
prerelease: false
|
40
34
|
type: :development
|
41
|
-
|
42
|
-
name: envygeeks-coveralls
|
35
|
+
prerelease: false
|
43
36
|
version_requirements: !ruby/object:Gem::Requirement
|
44
37
|
requirements:
|
45
|
-
- - ~>
|
38
|
+
- - "~>"
|
46
39
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0
|
40
|
+
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: envygeeks-coveralls
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
44
|
requirements:
|
50
|
-
- - ~>
|
45
|
+
- - "~>"
|
51
46
|
- !ruby/object:Gem::Version
|
52
47
|
version: '0.2'
|
53
|
-
prerelease: false
|
54
48
|
type: :development
|
55
|
-
|
56
|
-
name: rspec-collection_matchers
|
49
|
+
prerelease: false
|
57
50
|
version_requirements: !ruby/object:Gem::Requirement
|
58
51
|
requirements:
|
59
|
-
- - ~>
|
52
|
+
- - "~>"
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
54
|
+
version: '0.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-collection_matchers
|
62
57
|
requirement: !ruby/object:Gem::Requirement
|
63
58
|
requirements:
|
64
|
-
- - ~>
|
59
|
+
- - "~>"
|
65
60
|
- !ruby/object:Gem::Version
|
66
|
-
version: 1.0
|
67
|
-
prerelease: false
|
61
|
+
version: '1.0'
|
68
62
|
type: :development
|
69
|
-
|
70
|
-
name: luna-rspec-formatters
|
63
|
+
prerelease: false
|
71
64
|
version_requirements: !ruby/object:Gem::Requirement
|
72
65
|
requirements:
|
73
|
-
- - ~>
|
66
|
+
- - "~>"
|
74
67
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1'
|
68
|
+
version: '1.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: luna-rspec-formatters
|
76
71
|
requirement: !ruby/object:Gem::Requirement
|
77
72
|
requirements:
|
78
|
-
- - ~>
|
73
|
+
- - "~>"
|
79
74
|
- !ruby/object:Gem::Version
|
80
75
|
version: '1'
|
81
|
-
prerelease: false
|
82
76
|
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1'
|
83
83
|
description: A less restrictive version of html-pipeline for content.
|
84
84
|
email: envygeeks@gmail.com
|
85
85
|
executables: []
|
86
86
|
extensions: []
|
87
87
|
extra_rdoc_files: []
|
88
88
|
files:
|
89
|
-
-
|
89
|
+
- Gemfile
|
90
90
|
- License
|
91
91
|
- Rakefile
|
92
|
-
-
|
92
|
+
- Readme.md
|
93
93
|
- lib/content/pipeline.rb
|
94
|
-
- lib/content/pipeline/filters.rb
|
95
|
-
- lib/content/pipeline/version.rb
|
96
|
-
- lib/content/pipeline/core_extensions/object_ext.rb
|
97
94
|
- lib/content/pipeline/core_extensions/hash_ext.rb
|
98
|
-
- lib/content/pipeline/
|
95
|
+
- lib/content/pipeline/core_extensions/object_ext.rb
|
96
|
+
- lib/content/pipeline/filters.rb
|
99
97
|
- lib/content/pipeline/filters/code_highlight.rb
|
100
98
|
- lib/content/pipeline/filters/gemoji.rb
|
101
99
|
- lib/content/pipeline/filters/markdown.rb
|
100
|
+
- lib/content/pipeline/jekyll/converter.rb
|
101
|
+
- lib/content/pipeline/version.rb
|
102
102
|
homepage: https://github.com/envygeeks/content-pipeline
|
103
103
|
licenses:
|
104
104
|
- Apache 2.0
|
105
105
|
metadata: {}
|
106
|
-
post_install_message:
|
106
|
+
post_install_message:
|
107
107
|
rdoc_options: []
|
108
108
|
require_paths:
|
109
109
|
- lib
|
110
110
|
required_ruby_version: !ruby/object:Gem::Requirement
|
111
111
|
requirements:
|
112
|
-
- -
|
112
|
+
- - ">="
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
|
-
- -
|
117
|
+
- - ">="
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: '0'
|
120
120
|
requirements: []
|
121
|
-
rubyforge_project:
|
122
|
-
rubygems_version: 2.1
|
123
|
-
signing_key:
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.4.1
|
123
|
+
signing_key:
|
124
124
|
specification_version: 4
|
125
125
|
summary: Adds a pipeline for your content.
|
126
126
|
test_files: []
|