jekyll-inline-svg 1.0.0 → 1.0.1
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.lock +1 -1
- data/jekyll-inline-svg.gemspec +1 -1
- data/lib/jekyll-inline-svg.rb +11 -1
- data/spec/fixtures/index.html +3 -1
- data/spec/jekyll-inline-svg_spec.rb +8 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9bf9be464ebca5b3baa4e81c3b7d1a13d5d7742
|
4
|
+
data.tar.gz: 78f54ea9f7fb75ea242b4e2a564215047e1c0ca8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72c858a2f7341528df0df482d0397c2ee7f03cf2e7494bbda9ff5d0197ae282bea8d22f1de486b7322f4258f06be08fb1a571331f4d251e39afc869522c020d0
|
7
|
+
data.tar.gz: 5201dab3105efaf21387ce87c78f38aa133cb6bcc4e81225185218140814ab6c1f63e80e51e29314d7e16036d4230cb9cc06cbcbe62bec0ac5f8dd3d62735da6
|
data/Gemfile.lock
CHANGED
data/jekyll-inline-svg.gemspec
CHANGED
@@ -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.
|
10
|
+
spec.version = "1.0.1"
|
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"
|
data/lib/jekyll-inline-svg.rb
CHANGED
@@ -26,9 +26,19 @@ module Jekyll
|
|
26
26
|
^(?<path>[^\s"']+|"[^"]*"|'[^']*')
|
27
27
|
(?<params>.*)
|
28
28
|
!x
|
29
|
+
|
30
|
+
# parse the first parameter in a string, giving :
|
31
|
+
# [full_match, param_name, double_quoted_val, single_quoted_val, unquoted_val]
|
32
|
+
# The Regex works like :
|
33
|
+
# - first group
|
34
|
+
# - match a group of characters that is alphanumeric, _ or -.
|
35
|
+
# - second group (non-capturing OR)
|
36
|
+
# - match a double-quoted string
|
37
|
+
# - match a single-quoted string
|
38
|
+
# - match an unquoted string matching the set : [\w\.\-#]
|
29
39
|
PARAM_SYNTAX= %r!
|
30
40
|
([\w-]+)\s*=\s*
|
31
|
-
(?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|([\w
|
41
|
+
(?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|([\w\.\-#]+))
|
32
42
|
!x
|
33
43
|
|
34
44
|
def initialize(tag_name, input, tokens)
|
data/spec/fixtures/index.html
CHANGED
@@ -12,7 +12,9 @@ Hello world
|
|
12
12
|
{% svg files/square.svg width=24 height=48 %}
|
13
13
|
{% svg files/square.svg width=24 height="" %}
|
14
14
|
</div>
|
15
|
-
|
15
|
+
<div id="attributes">
|
16
|
+
{% svg files/square.svg role="navigation" data-foo="bar" fill="#ffffff" stroke=#000000 %}
|
17
|
+
</div>
|
16
18
|
<div id="path">
|
17
19
|
<label>Resolve relative and absolute paths to site's source</label>
|
18
20
|
{% svg files/square.svg %}
|
@@ -89,6 +89,14 @@ describe(Jekyll::Tags::JekyllInlineSvg) do
|
|
89
89
|
|
90
90
|
expect(data[2].get_attribute("width")).to eql("24")
|
91
91
|
end
|
92
|
+
it "keep attributes" do
|
93
|
+
data = @data.css("#attributes").css("svg")
|
94
|
+
expect(data).to be_truthy
|
95
|
+
expect(data[0].get_attribute("role")).to eql("navigation")
|
96
|
+
expect(data[0].get_attribute("data-foo")).to eql("bar")
|
97
|
+
expect(data[0].get_attribute("fill")).to eql("#ffffff")
|
98
|
+
expect(data[0].get_attribute("stroke")).to eql("#000000")
|
99
|
+
end
|
92
100
|
it "parse relative paths" do
|
93
101
|
data = @data.css("#path").css("svg")
|
94
102
|
expect(data.size).to eq(2)
|