jekyll-img-converter 0.1.4 → 0.1.5
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/lib/jekyll-img-converter.rb +34 -52
- 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: 03ec833f5b958643b44263c5fd9a78d84ca3c0e6
|
4
|
+
data.tar.gz: 06420a618107b4af009a2d5154717b72ae8645d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fef2f870d3d9e3b41f7e4bf5e652e95400cde698606c2a82f7fb4ad3913a9932ee9626fd1fe28efe59ca456a459ae28090425d86113e93863687561c26a7b74
|
7
|
+
data.tar.gz: 1e0445157827591eab014eea690ce152f64cd090062f689bfb9180f18d440879dfb577de6df89d821bf4414b8fc6ce5a2b076ed8a5b20b816294123094594a46
|
data/lib/jekyll-img-converter.rb
CHANGED
@@ -1,61 +1,43 @@
|
|
1
1
|
require 'jekyll'
|
2
|
-
require 'redcarpet'
|
3
2
|
|
4
3
|
module Jekyll
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
module Converters
|
5
|
+
class Markdown < Converter
|
6
|
+
|
7
|
+
class RedcarpetParser
|
8
|
+
module CommonMethods
|
9
|
+
# def postprocess(full_document)
|
10
|
+
# Regexp.new(/\A<p>(.*)<\/p>\Z/m).match(full_document)[1] rescue full_document
|
11
|
+
# end
|
12
|
+
# def postprocess(document)
|
13
|
+
# document.gsub("\n", '').strip
|
14
|
+
# end
|
15
|
+
|
16
|
+
def image(link, title, content)
|
17
|
+
pattern = /({)(.+)(})/
|
18
|
+
matchData = pattern.match(content)
|
19
|
+
|
20
|
+
imgTag = "<img src=\"#{link}\""
|
21
|
+
|
22
|
+
if (matchData)
|
23
|
+
style = matchData[2]
|
24
|
+
stripContent = content.gsub(matchData.to_s,'').rstrip
|
25
|
+
|
26
|
+
imgTag += " alt=\"#{stripContent}\" style=\"#{style}\""
|
27
|
+
else
|
28
|
+
imgTag += " alt=\"#{content}\""
|
29
|
+
end
|
12
30
|
|
13
|
-
|
31
|
+
if(title)
|
32
|
+
imgTag += " title=\"#{title}\""
|
33
|
+
end
|
14
34
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
imgTag += " alt=\"#{stripContent}\" style=\"#{style}\""
|
20
|
-
else
|
21
|
-
imgTag += " alt=\"#{content}\""
|
22
|
-
end
|
23
|
-
|
24
|
-
if(title)
|
25
|
-
imgTag += " title=\"#{title}\""
|
26
|
-
end
|
27
|
-
|
28
|
-
imgTag = imgTag + "/>"
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
class SFMarkdownConverter < Converter
|
34
|
-
safe true
|
35
|
-
priority :high
|
36
|
-
|
37
|
-
def matches(ext)
|
38
|
-
ext =~ /^.md(own)?$/i
|
39
|
-
end
|
40
|
-
|
41
|
-
def output_ext(ext)
|
42
|
-
".html"
|
43
|
-
end
|
44
|
-
|
45
|
-
def convert(content)
|
46
|
-
# @renderer.send :include, Redcarpet::Render::SmartyPants if @redcarpet_extensions[:smart]
|
47
|
-
# markdown = Redcarpet::Markdown.new(@renderer.new(@extensions), @extensions)
|
48
|
-
markdown = Redcarpet::Markdown.new(ImgConverter.new(@extensions), @extensions)
|
49
|
-
markdown.render(content)
|
50
|
-
end
|
51
|
-
|
52
|
-
def initialize(config)
|
53
|
-
super
|
54
|
-
@extensions = {}
|
55
|
-
@config['redcarpet']['extensions'].each { |e| @extensions[e.to_sym] = true}
|
56
|
-
@extensions = @config['redcarpet']['extensions'].each_with_object({}) do |e, hash|
|
57
|
-
hash[e.to_sym] = true
|
35
|
+
imgTag += "/>"
|
36
|
+
end
|
37
|
+
end
|
58
38
|
end
|
39
|
+
|
59
40
|
end
|
60
41
|
end
|
61
42
|
end
|
43
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-img-converter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SungKwang Song
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|