jekyll-inline-svg 1.0.1 → 1.1.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: d9bf9be464ebca5b3baa4e81c3b7d1a13d5d7742
4
- data.tar.gz: 78f54ea9f7fb75ea242b4e2a564215047e1c0ca8
3
+ metadata.gz: 2eb1e13bf0039d420fd5c05e6624cbf3182280be
4
+ data.tar.gz: e81cdccb89d2a003a980ec5ac29edde53bea63d5
5
5
  SHA512:
6
- metadata.gz: 72c858a2f7341528df0df482d0397c2ee7f03cf2e7494bbda9ff5d0197ae282bea8d22f1de486b7322f4258f06be08fb1a571331f4d251e39afc869522c020d0
7
- data.tar.gz: 5201dab3105efaf21387ce87c78f38aa133cb6bcc4e81225185218140814ab6c1f63e80e51e29314d7e16036d4230cb9cc06cbcbe62bec0ac5f8dd3d62735da6
6
+ metadata.gz: e49ad0f22e7fba4f23d79912138923d176da6f0d7cfad4996afe5c18922cd3f958168dbb25bee2bd1b7febab4a8505a20882f165812f9ba3aac079463623572a
7
+ data.tar.gz: f41352fb1f2b80955bf271b6ba989c27b5961f804591163b091151402a5251ef580d84e5211226ad2af47b18a424bacc450968a11a3eaed084fce0afcf70487f
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.3.0
1
+ ruby-2.4
data/Gemfile.lock CHANGED
@@ -1,51 +1,62 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jekyll-inline-svg (1.0.0)
4
+ jekyll-inline-svg (1.0.1)
5
5
  jekyll (~> 3.3)
6
6
  svg_optimizer (= 0.1.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.5.1)
12
- public_suffix (~> 2.0, >= 2.0.2)
11
+ addressable (2.5.2)
12
+ public_suffix (>= 2.0.2, < 4.0)
13
13
  colorator (1.1.0)
14
+ concurrent-ruby (1.0.5)
14
15
  diff-lcs (1.3)
15
- ffi (1.9.18)
16
+ em-websocket (0.5.1)
17
+ eventmachine (>= 0.12.9)
18
+ http_parser.rb (~> 0.6.0)
19
+ eventmachine (1.2.7)
20
+ ffi (1.9.25)
16
21
  forwardable-extended (2.6.0)
17
- jekyll (3.5.2)
22
+ http_parser.rb (0.6.0)
23
+ i18n (0.9.5)
24
+ concurrent-ruby (~> 1.0)
25
+ jekyll (3.8.3)
18
26
  addressable (~> 2.4)
19
27
  colorator (~> 1.0)
28
+ em-websocket (~> 0.5)
29
+ i18n (~> 0.7)
20
30
  jekyll-sass-converter (~> 1.0)
21
- jekyll-watch (~> 1.1)
22
- kramdown (~> 1.3)
31
+ jekyll-watch (~> 2.0)
32
+ kramdown (~> 1.14)
23
33
  liquid (~> 4.0)
24
34
  mercenary (~> 0.3.3)
25
35
  pathutil (~> 0.9)
26
- rouge (~> 1.7)
36
+ rouge (>= 1.7, < 4)
27
37
  safe_yaml (~> 1.0)
28
- jekyll-sass-converter (1.5.0)
38
+ jekyll-sass-converter (1.5.2)
29
39
  sass (~> 3.4)
30
- jekyll-watch (1.5.0)
31
- listen (~> 3.0, < 3.1)
32
- kramdown (1.14.0)
40
+ jekyll-watch (2.0.0)
41
+ listen (~> 3.0)
42
+ kramdown (1.17.0)
33
43
  liquid (4.0.0)
34
- listen (3.0.8)
44
+ listen (3.1.5)
35
45
  rb-fsevent (~> 0.9, >= 0.9.4)
36
46
  rb-inotify (~> 0.9, >= 0.9.7)
47
+ ruby_dep (~> 1.2)
37
48
  mercenary (0.3.6)
38
- mini_portile2 (2.2.0)
39
- nokogiri (1.8.0)
40
- mini_portile2 (~> 2.2.0)
41
- pathutil (0.14.0)
49
+ mini_portile2 (2.3.0)
50
+ nokogiri (1.8.4)
51
+ mini_portile2 (~> 2.3.0)
52
+ pathutil (0.16.1)
42
53
  forwardable-extended (~> 2.6)
43
- public_suffix (2.0.5)
54
+ public_suffix (3.0.2)
44
55
  rake (12.0.0)
45
- rb-fsevent (0.10.2)
56
+ rb-fsevent (0.10.3)
46
57
  rb-inotify (0.9.10)
47
58
  ffi (>= 0.5.0, < 2)
48
- rouge (1.11.1)
59
+ rouge (3.1.1)
49
60
  rspec (3.6.0)
50
61
  rspec-core (~> 3.6.0)
51
62
  rspec-expectations (~> 3.6.0)
@@ -59,8 +70,9 @@ GEM
59
70
  diff-lcs (>= 1.2.0, < 2.0)
60
71
  rspec-support (~> 3.6.0)
61
72
  rspec-support (3.6.0)
73
+ ruby_dep (1.5.0)
62
74
  safe_yaml (1.0.4)
63
- sass (3.5.1)
75
+ sass (3.5.6)
64
76
  sass-listen (~> 4.0.0)
65
77
  sass-listen (4.0.0)
66
78
  rb-fsevent (~> 0.9, >= 0.9.4)
@@ -78,4 +90,4 @@ DEPENDENCIES
78
90
  rspec (~> 3.6)
79
91
 
80
92
  BUNDLED WITH
81
- 1.15.4
93
+ 1.16.2
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  A Liquid tag to inline and optimize SVG images in your HTML
8
8
  Supports custom DOM Attributes parameters and variables interpretation.
9
9
  EOF
10
- spec.version = "1.0.1"
10
+ spec.version = "1.1.0"
11
11
  spec.authors = ["Sebastien DUMETZ"]
12
12
  spec.email = "s.dumetz@holusion.com"
13
13
  spec.homepage = "https://github.com/sdumetz/jekyll-inline-svg"
@@ -23,7 +23,7 @@ module Jekyll
23
23
 
24
24
  #Separate file path from other attributes
25
25
  PATH_SYNTAX = %r!
26
- ^(?<path>[^\s"']+|"[^"]*"|'[^']*')
26
+ ^(?<path>[^\s"']+|"[^"]+"|'[^']+')
27
27
  (?<params>.*)
28
28
  !x
29
29
 
@@ -41,9 +41,9 @@ module Jekyll
41
41
  (?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|([\w\.\-#]+))
42
42
  !x
43
43
 
44
- def initialize(tag_name, input, tokens)
44
+ def initialize(tag_name, markup, tokens)
45
45
  super
46
- @svg, @params = JekyllInlineSvg.parse_params(input)
46
+ @svg, @params = JekyllInlineSvg.parse_params(markup)
47
47
  end
48
48
 
49
49
  #lookup Liquid variables from markup in context
@@ -70,11 +70,18 @@ module Jekyll
70
70
  end
71
71
  #Parse parameters. Returns : [svg_path, parameters]
72
72
  # Does not interpret variables as it's done at render time
73
- def self.parse_params(input)
74
- matched = input.strip.match(PATH_SYNTAX)
75
- path = matched["path"].gsub("\"","").gsub("'","").strip
76
- markup = matched["params"].strip
77
- return path, markup
73
+ def self.parse_params(markup)
74
+ matched = markup.strip.match(PATH_SYNTAX)
75
+ if !matched
76
+ raise SyntaxError, <<~END
77
+ Syntax Error in tag 'highlight' while parsing the following markup:
78
+ #{markup}
79
+ Valid syntax: svg <path> [property=value]
80
+ END
81
+ end
82
+ path = matched["path"].sub(%r!^["']!,"").sub(%r!["']$!,"").strip
83
+ params = matched["params"].strip
84
+ return path, params
78
85
  end
79
86
  def fmt(params)
80
87
  r = params.to_a.select{|v| v[1] != ""}.map {|v| %!#{v[0]}="#{v[1]}"!}
@@ -93,11 +100,22 @@ module Jekyll
93
100
  mod.set(params)
94
101
  return mod
95
102
  end
103
+ def add_file_to_dependency(site, path, context)
104
+ if context.registers[:page] && context.registers[:page].key("path")
105
+ site.regenerator.add_dependency(
106
+ site.in_source_dir(context.registers[:page]["path"]),
107
+ path
108
+ )
109
+ end
110
+ end
111
+
96
112
  def render(context)
97
113
  #global site variable
98
114
  site = context.registers[:site]
99
115
  #check if given name is a variable. Otherwise use it as a file name
100
116
  svg_file = Jekyll.sanitized_path(site.source, interpolate(@svg,context))
117
+ return unless svg_file
118
+ add_file_to_dependency(site,svg_file, context)
101
119
  #replace variables with their current value
102
120
  params = split_params(@params,context)
103
121
  #because ie11 require to have a height AND a width
@@ -13,7 +13,7 @@ describe(Jekyll::Tags::JekyllInlineSvg) do
13
13
  Nokogiri::HTML(read(f))
14
14
  end
15
15
 
16
- describe "Parse parameters" do
16
+ describe "#parse_params" do
17
17
  it "parse XML root parameters" do
18
18
  svg, params = Jekyll::Tags::JekyllInlineSvg.parse_params("/path/to/foo size=40 style=\"hello\"")
19
19
  expect(svg).to eq("/path/to/foo")
@@ -44,6 +44,9 @@ describe(Jekyll::Tags::JekyllInlineSvg) do
44
44
  svg, params = Jekyll::Tags::JekyllInlineSvg.parse_params("'/path/to/foo space' id='bar' style=\"hello\"")
45
45
  expect(params).to eq("id='bar' style=\"hello\"")
46
46
  end
47
+ it "raise error on invalid syntax" do
48
+ expect {Jekyll::Tags::JekyllInlineSvg.parse_params("")}.to raise_error (SyntaxError)
49
+ end
47
50
  end
48
51
  [
49
52
  Jekyll.configuration({
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-inline-svg
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastien DUMETZ
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-31 00:00:00.000000000 Z
11
+ date: 2018-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  version: '0'
125
125
  requirements: []
126
126
  rubyforge_project:
127
- rubygems_version: 2.5.1
127
+ rubygems_version: 2.6.14
128
128
  signing_key:
129
129
  specification_version: 4
130
130
  summary: A SVG Inliner for Jekyll