jekyll-diagrams 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/jekyll/diagrams/diag.rb +13 -13
- data/lib/jekyll/diagrams/graphviz.rb +16 -16
- data/lib/jekyll/diagrams/version.rb +1 -1
- 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: 4c6675b0ac520e97b2996c72923471a10a1ccfd0
|
4
|
+
data.tar.gz: 762740eac4ecc614179150a95b390b6ff2bf4067
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6621464da76326d77e99ddb3601ade0da273295b5d66cfc87b85d48582ea1c5c2c028e5c1514aff2c0ecc6e43f0d36c7d6e61d6e33e171cfe351514d39912db8
|
7
|
+
data.tar.gz: 66c1a1f58cbd1ad98f876ff0b9d2c274e85082371c5944969d10e309481c2c5d25cd901accb1ac16d9e1a45e89216d5f3279805617e5c4ba13c59c63fa195fc7
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# Jekyll Diagrams
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/jekyll-diagrams.svg)](https://badge.fury.io/rb/jekyll-diagrams)
|
3
4
|
[![Build Status](https://travis-ci.org/farkasity/jekyll-diagrams.svg?branch=master)](https://travis-ci.org/farkasity/jekyll-diagrams.svg)
|
4
5
|
[![Build status](https://ci.appveyor.com/api/projects/status/f5l7k3971pmjbjcq?svg=true)](https://ci.appveyor.com/project/farkasity/jekyll-diagrams)
|
5
6
|
[![Dependency Status](https://gemnasium.com/farkasity/jekyll-diagrams.svg)](https://gemnasium.com/farkasity/jekyll-diagrams)
|
data/lib/jekyll/diagrams/diag.rb
CHANGED
@@ -4,20 +4,20 @@ require 'tempfile'
|
|
4
4
|
module Jekyll
|
5
5
|
module Diagrams
|
6
6
|
class DiagBlock < Liquid::Block
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
def initialize(tag_name, text, tokens)
|
8
|
+
super
|
9
|
+
@tag_name = tag_name
|
10
|
+
end
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
def render(context)
|
13
|
+
config = context.registers[:site].config["diagrams"]
|
14
14
|
|
15
|
-
|
15
|
+
@renderer = DiagRenderer.new(config['diag'])
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
render_diagram(super)
|
18
|
+
end
|
19
19
|
|
20
|
-
|
20
|
+
private
|
21
21
|
|
22
22
|
def render_diagram(code)
|
23
23
|
@renderer.render(code, @tag_name)
|
@@ -36,15 +36,15 @@ module Jekyll
|
|
36
36
|
def render(code, engine)
|
37
37
|
tmp = Temfile.new(engine).path
|
38
38
|
dest = "#{tmp}.svg"
|
39
|
-
|
39
|
+
|
40
40
|
File.write(tmp, code)
|
41
41
|
cmd = "#{engine} #{@config['options']} #{tmp} -o #{dest}"
|
42
42
|
ret, status = Open3.capture2(cmd, binmode: true)
|
43
43
|
|
44
|
-
if !status.success
|
44
|
+
if !status.success
|
45
45
|
raise "Non-zero exit status '#{cmd}': #{status}"
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
svg = File.read(dest).force_encoding 'UTF-8'
|
49
49
|
|
50
50
|
wrap_div(svg, engine)
|
@@ -3,24 +3,24 @@ require 'open3'
|
|
3
3
|
module Jekyll
|
4
4
|
module Diagrams
|
5
5
|
class GraphvizBlock < Liquid::Block
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
def initialize(tag_name, text, tokens)
|
7
|
+
super
|
8
|
+
@tag_name = tag_name
|
9
|
+
@engine = text.strip
|
10
|
+
end
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
def render(context)
|
13
|
+
config = context.registers[:site].config["diagrams"]
|
14
14
|
|
15
|
-
|
15
|
+
@renderer = GraphvizRenderer.new(config["graphviz"])
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
render_diagram(super)
|
18
|
+
end
|
19
19
|
|
20
|
-
|
20
|
+
private
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
def render_diagram(code)
|
23
|
+
code = case @tag_name
|
24
24
|
when 'graphviz'
|
25
25
|
code
|
26
26
|
when 'graph'
|
@@ -32,7 +32,7 @@ module Jekyll
|
|
32
32
|
end
|
33
33
|
|
34
34
|
@renderer.render(code, @engine)
|
35
|
-
|
35
|
+
end
|
36
36
|
end
|
37
37
|
|
38
38
|
class GraphvizRenderer
|
@@ -53,7 +53,7 @@ module Jekyll
|
|
53
53
|
binmode: true
|
54
54
|
)
|
55
55
|
|
56
|
-
if !status.success
|
56
|
+
if !status.success
|
57
57
|
raise "Non-zero exit status '#{cmd}': #{status}"
|
58
58
|
end
|
59
59
|
|
@@ -66,7 +66,7 @@ module Jekyll
|
|
66
66
|
private
|
67
67
|
|
68
68
|
def strip_metainfo(svg)
|
69
|
-
svg.gsub(/(
|
69
|
+
svg.gsub(/( :.*\n){6}/, '')
|
70
70
|
end
|
71
71
|
|
72
72
|
def wrap_div(svg)
|