content-pipeline 1.1.1 → 1.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: 6e8d01d2a0077eab819a5a5d23b10aa315c35c28
4
- data.tar.gz: f544793fc69174401d4070175e51fa49e6d1d7f9
3
+ metadata.gz: 55c0d469321e4e6b79286994aa83543cd22a1240
4
+ data.tar.gz: 179a18c1fd8cc5768391d76e2f63533cf8da504c
5
5
  SHA512:
6
- metadata.gz: 5c569c0797ac0bbabd6b4af52ea31a7687771e9c7430f51ba1c54acb184b24502e6d445ed2e3b7892c996a2d3663641982649a45802ffff4cbef036b6b813b68
7
- data.tar.gz: 6a3fc738d3175e06eef6c6a5e6c4da8f0a57504f1d2fe3ae44f46f88bbbfb0192cf23f6ed7d359c7b776b584b5e3daa83e18344d7cfbea1989e62ebb711be9eb
6
+ metadata.gz: 4fa0edd425a2aba990865bbd7756af610e8ae64f777d757bb0a24f6c361ed5ee7520c0dcb3c263c83a0baf61be9125dd41eb0acbc5e0561aee1636eb3849882b
7
+ data.tar.gz: 08ebb13c9783c5b3f75c16541388d7238423a417f45e631eb7b53ceb71bd2180940a5bd0cadce0eebc5e72d66d8603e4eb7a577e1d1a0f97119752d174b66385
@@ -72,10 +72,7 @@ class Content::Pipeline
72
72
  # ---------------------------------------------------------------------------
73
73
 
74
74
  module Filters
75
- require_relative "filters/code_highlight"
76
75
  require_relative "filters/markdown"
77
- require_relative "filters/gemoji"
78
- # The filters I prefer to use by default are here.
79
- DEFAULT_FILTERS = [ Markdown, CodeHighlight, Gemoji ].freeze
76
+ DEFAULT_FILTERS = [ Markdown ].freeze
80
77
  end
81
78
  end
@@ -1,8 +1,9 @@
1
1
  require "gemoji"
2
+ require "pry"
2
3
 
3
4
  class Content::Pipeline::Filters::Gemoji < Content::Pipeline::Filter
4
- EmojiPattern = /(?:^\s*|\s+):(#{Emoji.names.map { |n| Regexp.escape(n) }.join("|")}):(?:\s+|\s*$)/m
5
5
  EmojiTag = %Q{<img class="emoji" src="%s" alt=":%s:" height="20" width="20">}
6
+ EmojiPattern = /(?:^\s*|\s+):(#{Emoji.all.map { |n| Regexp.escape(n.name) }.join("|")}):(?:\s+|\s*$)/m
6
7
  EmojiLiquidTag = %Q{{%%img "%s" ":%s:" %%}}
7
8
 
8
9
  add_filter({
@@ -44,20 +45,14 @@ class Content::Pipeline::Filters::Gemoji < Content::Pipeline::Filter
44
45
  n.node_name == "code" || n.node_name == "pre"
45
46
  end
46
47
 
47
- # Because it's no more performant than 40 objs.
48
48
  node.replace(node.to_html.gsub(EmojiPattern) do
49
49
  ep = "#{@opts[:asset_path].chomp("/")}/#{$1}.png"
50
50
  en = $1
51
51
 
52
52
  if ! @opts[:tag] && ! @opts[:tag].is_a?(Proc)
53
53
  if @opts[:as_liquid_asset]
54
- EmojiLiquidTag % [
55
- ep, en
56
- ]
57
- else
58
- EmojiTag % [
59
- ep, en
60
- ]
54
+ then EmojiLiquidTag % [ep, en]
55
+ else EmojiTag % [ep, en]
61
56
  end
62
57
  else
63
58
  @opts[:tag].call(ep, en)
@@ -1,52 +1,50 @@
1
1
  class Content::Pipeline::Filters::Markdown < Content::Pipeline::Filter
2
+ class UnknownParserError < StandardError
3
+ def initialize(type)
4
+ super "Unknown parser #{type} provided"
5
+ end
6
+ end
7
+
2
8
  add_filter({
3
9
  :markdown => :str,
4
10
  :strip_html => :nokogiri
5
11
  })
6
12
 
7
- # ---------------------------------------------------------------------------
8
-
9
13
  private
10
14
  def default
11
15
  jruby? ? :kramdown : :gfm
12
16
  end
13
17
 
14
- # ---------------------------------------------------------------------------
15
-
16
18
  private
17
19
  def markdown
18
20
  @type = @opts.fetch(:type, default)
19
- @str = backtick(@str)
20
- @str = case
21
- when @type =~ /\Amd|markdown|gfm\Z/ then parse_github
21
+ @str = backtick(@str)
22
+ @str = case
23
+ when @type =~ /\Agithub|gfm\Z/ then parse_github
24
+ when @type =~ /\Akramdown\Z/ then parse_kramdown
25
+ when @type =~ /\Amarkdown|md\Z/
26
+ begin parse_github; rescue LoadError
27
+ parse_kramdown
28
+ end
22
29
  else
23
- parse_kramdown
30
+ # Actually needed now days.
31
+ raise UnknownParserError, @type
24
32
  end
25
33
  end
26
34
 
27
- # ---------------------------------------------------------------------------
28
-
29
35
  private
30
36
  def parse_github
31
37
  require "github/markdown"
32
38
  GitHub::Markdown.to_html(@str, @type).strip
33
39
  end
34
40
 
35
- # ---------------------------------------------------------------------------
36
-
37
41
  private
38
42
  def parse_kramdown
39
43
  require "kramdown"
40
- str = Kramdown::Document.new(@str, {
41
- :enable_coderay => false
42
- })
43
-
44
- # For consistent output, like it ok?!
44
+ str = Kramdown::Document.new(@str, :enable_coderay => false)
45
45
  normalize_kramdown(str.to_html).strip
46
46
  end
47
47
 
48
- # ---------------------------------------------------------------------------
49
-
50
48
  private
51
49
  def strip_html
52
50
  if @opts[:safe]
@@ -59,8 +57,6 @@ class Content::Pipeline::Filters::Markdown < Content::Pipeline::Filter
59
57
  end
60
58
  end
61
59
 
62
- # ---------------------------------------------------------------------------
63
-
64
60
  private
65
61
  def strip_links
66
62
  @str.search("a").each do |n|
@@ -68,8 +64,6 @@ class Content::Pipeline::Filters::Markdown < Content::Pipeline::Filter
68
64
  end
69
65
  end
70
66
 
71
- # ---------------------------------------------------------------------------
72
-
73
67
  private
74
68
  def strip_image
75
69
  @str.search("img").each do |n|
@@ -77,21 +71,14 @@ class Content::Pipeline::Filters::Markdown < Content::Pipeline::Filter
77
71
  end
78
72
  end
79
73
 
80
- # ---------------------------------------------------------------------------
81
- # @arg String: The Markdown string, convert `` to ~~~.
82
- # ---------------------------------------------------------------------------
83
-
84
74
  private
85
75
  def backtick(str)
86
76
  str.gsub(/^`{3}(\s?[a-zA-Z0-9]+)?$/, "~~~\\1")
87
77
  end
88
78
 
89
- # ---------------------------------------------------------------------------
90
- # @arg String: The converted Markdown string, from Kramdown.
91
- # ---------------------------------------------------------------------------
92
-
93
79
  private
94
80
  def normalize_kramdown(str)
95
- str.gsub(/<pre><code class="language-([A-Za-z0-9]+)">/, '<pre lang="\\1"><code>')
81
+ str.gsub(/<pre><code class="language-([A-Za-z0-9]+)">/, \
82
+ '<pre lang="\\1"><code>')
96
83
  end
97
84
  end
@@ -1,5 +1,5 @@
1
1
  module Content
2
2
  class Pipeline
3
- VERSION = "1.1.1"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  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.1.1
4
+ version: 1.2.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-06-03 00:00:00.000000000 Z
11
+ date: 2014-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
15
- requirement: !ruby/object:Gem::Requirement
15
+ version_requirements: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.6'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
20
+ requirement: !ruby/object:Gem::Requirement
23
21
  requirements:
24
- - - "~>"
22
+ - - ~>
25
23
  - !ruby/object:Gem::Version
26
24
  version: '1.6'
25
+ prerelease: false
26
+ type: :runtime
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
- requirement: !ruby/object:Gem::Requirement
29
+ version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '3.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
34
+ requirement: !ruby/object:Gem::Requirement
37
35
  requirements:
38
- - - "~>"
36
+ - - ~>
39
37
  - !ruby/object:Gem::Version
40
38
  version: '3.0'
39
+ prerelease: false
40
+ type: :development
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: envygeeks-coveralls
43
- requirement: !ruby/object:Gem::Requirement
43
+ version_requirements: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0.2'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
51
49
  requirements:
52
- - - "~>"
50
+ - - ~>
53
51
  - !ruby/object:Gem::Version
54
52
  version: '0.2'
53
+ prerelease: false
54
+ type: :development
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec-collection_matchers
57
- requirement: !ruby/object:Gem::Requirement
57
+ version_requirements: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '0.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
61
+ version: 1.0.0
62
+ requirement: !ruby/object:Gem::Requirement
65
63
  requirements:
66
- - - "~>"
64
+ - - ~>
67
65
  - !ruby/object:Gem::Version
68
- version: '0.0'
66
+ version: 1.0.0
67
+ prerelease: false
68
+ type: :development
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: luna-rspec-formatters
71
- requirement: !ruby/object:Gem::Requirement
71
+ version_requirements: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: '1'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
76
+ requirement: !ruby/object:Gem::Requirement
79
77
  requirements:
80
- - - "~>"
78
+ - - ~>
81
79
  - !ruby/object:Gem::Version
82
80
  version: '1'
81
+ prerelease: false
82
+ type: :development
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
- - Gemfile
89
+ - Readme.md
90
90
  - License
91
91
  - Rakefile
92
- - Readme.md
92
+ - Gemfile
93
93
  - lib/content/pipeline.rb
94
- - lib/content/pipeline/core_extensions/hash_ext.rb
95
- - lib/content/pipeline/core_extensions/object_ext.rb
96
94
  - lib/content/pipeline/filters.rb
95
+ - lib/content/pipeline/version.rb
96
+ - lib/content/pipeline/core_extensions/object_ext.rb
97
+ - lib/content/pipeline/core_extensions/hash_ext.rb
98
+ - lib/content/pipeline/jekyll/converter.rb
97
99
  - lib/content/pipeline/filters/code_highlight.rb
98
100
  - lib/content/pipeline/filters/gemoji.rb
99
101
  - 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.2.2
123
- signing_key:
121
+ rubyforge_project:
122
+ rubygems_version: 2.1.9
123
+ signing_key:
124
124
  specification_version: 4
125
125
  summary: Adds a pipeline for your content.
126
126
  test_files: []