jekyll-img-converter 0.1.0

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-img-converter.rb +58 -0
  3. metadata +143 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1d49545c175311c1e7e166cd8aee4455d5877a37
4
+ data.tar.gz: 1ea6855fe4f412e7046f89eeb19e50f849525631
5
+ SHA512:
6
+ metadata.gz: e26907b990f9359116fdff02c9ce93ed73ef9470e57a904d11c3626bd41ad823ef24e4de7329364d6b108dd19362bc167969ccf7be36717b6fd768cc7dea450b
7
+ data.tar.gz: 5c9308d2dac4816663030e8b047f666053a36a532c684636f0e2b1f4f1c9e44fd93b9929f4a446e5e26fcc9c5a480940638bef1585cb1dc13b50ec7b09ba7bba
@@ -0,0 +1,58 @@
1
+ require 'jekyll'
2
+ require 'redcarpet'
3
+
4
+ module Jekyll
5
+
6
+ class ImgConverter < Redcarpet::Render::HTML
7
+
8
+ def image(link, title, content)
9
+ # content &&= content
10
+ pattern = /({)(.+)(})/
11
+ matchData = pattern.match(content)
12
+ stripContent = content.gsub(matchData[0],'')
13
+
14
+ imgTag = "<img src=\"#{link}\""
15
+ if (matchData)
16
+ imgTag = imgTag + " alt=\"#{stripContent}\" style=\"#{matchData[0]}\""
17
+ else
18
+ imgTag = imgTag + " alt=\"#{content}\""
19
+ end
20
+
21
+ if(title)
22
+ imgTag = imgTag = " title=\"#{title}\""
23
+ end
24
+
25
+ imgTag = imgTag + "/>"
26
+ end
27
+
28
+ end
29
+
30
+ class SFMarkdownConverter < Converter
31
+ safe true
32
+ priority :high
33
+
34
+ def matches(ext)
35
+ ext =~ /^.md(own)?$/i
36
+ end
37
+
38
+ def output_ext(ext)
39
+ ".html"
40
+ end
41
+
42
+ def convert(content)
43
+ # @renderer.send :include, Redcarpet::Render::SmartyPants if @redcarpet_extensions[:smart]
44
+ # markdown = Redcarpet::Markdown.new(@renderer.new(@extensions), @extensions)
45
+ markdown = Redcarpet::Markdown.new(ImgConverter.new(@extensions), @extensions)
46
+ markdown.render(content)
47
+ end
48
+
49
+ def initialize(config)
50
+ super
51
+ @extensions = {}
52
+ @config['redcarpet']['extensions'].each { |e| @extensions[e.to_sym] = true}
53
+ @extensions = @config['redcarpet']['extensions'].each_with_object({}) do |e, hash|
54
+ hash[e.to_sym] = true
55
+ end
56
+ end
57
+ end
58
+ end
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-img-converter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - SungKwang Song
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: html-pipeline
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.9'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rdoc
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '4.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: shoulda
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.5'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.5'
83
+ - !ruby/object:Gem::Dependency
84
+ name: minitest
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '5.4'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '5.4'
97
+ - !ruby/object:Gem::Dependency
98
+ name: redcarpet
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.2'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.2'
111
+ description: jekyll-img-converter is support to convert IMG tag with inline style
112
+ from markdown using with Redcarpet
113
+ email: saltfactory@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - lib/jekyll-img-converter.rb
119
+ homepage: https://github.com/saltfactory/jekyll-img-converter
120
+ licenses:
121
+ - MIT
122
+ metadata: {}
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 2.4.3
140
+ signing_key:
141
+ specification_version: 4
142
+ summary: Jekyll IMG tag conveter in markdown using with Redcarpet
143
+ test_files: []