jekyll-drawio 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/diagram_extractor.rb +18 -0
- data/lib/jekyll-drawio/version.rb +1 -1
- data/lib/jekyll-drawio.rb +41 -20
- metadata +12 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77b54ec04817d915d1751c45b42c95c0966a42c9d4bc49db0942a34755a49cc5
|
4
|
+
data.tar.gz: 82a4263627eb1df5cd9f9c94502dc6dc3fb7d468a0d5b2b75ad408e15bd4ab19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb92b079556c1bde06902b2e550c47151ae2cdbdaa8cd239bbf601a62aac3312776d81939ecd0c81d653000d5a2015cfefaa7d70bb711fbbd01fa484138370c3
|
7
|
+
data.tar.gz: 3acea9b0f8d1adf3a94ef49c02710a97213441bc9a0f66f66458959e0276c259b1c0ae9cfddde77bd13270a9b80bbf94d4886629167020e2249ae5ac91fd000d
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class DiagramExtractor
|
2
|
+
def initialize
|
3
|
+
end
|
4
|
+
|
5
|
+
def extract_diagram(path, diagram_num)
|
6
|
+
doc = File.open(path) { |f| Nokogiri::XML(f) }
|
7
|
+
diagrams = doc.xpath("//mxfile//diagram")
|
8
|
+
puts "Diagrams found at \"#{path}\": #{diagrams.length}. " \
|
9
|
+
"Selected: #{diagram_num}. "
|
10
|
+
|
11
|
+
diagram = diagrams[diagram_num]
|
12
|
+
|
13
|
+
diagram_name = diagram["name"]
|
14
|
+
diagram_content = diagram.to_html
|
15
|
+
|
16
|
+
return diagram_name, diagram_content
|
17
|
+
end
|
18
|
+
end
|
data/lib/jekyll-drawio.rb
CHANGED
@@ -1,21 +1,51 @@
|
|
1
1
|
require "jekyll"
|
2
2
|
require "jekyll-drawio/version"
|
3
|
+
require "diagram_extractor"
|
3
4
|
require "nokogiri"
|
4
5
|
require "erb"
|
5
6
|
|
6
7
|
MODULE_TAG_NAME = "drawio"
|
7
8
|
|
9
|
+
def split_parameters_line(parameters_line)
|
10
|
+
params = []
|
11
|
+
tmp = ""
|
12
|
+
|
13
|
+
parameters_line.each_char do |symbol|
|
14
|
+
if symbol == " "
|
15
|
+
params.push tmp
|
16
|
+
tmp = ""
|
17
|
+
else
|
18
|
+
tmp += symbol
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
params.push tmp
|
23
|
+
params
|
24
|
+
end
|
25
|
+
|
8
26
|
class DrawIOConverter < Liquid::Tag
|
9
|
-
attr_accessor :path_to_diagram,
|
27
|
+
attr_accessor :path_to_diagram,
|
28
|
+
:selected_diagram_num,
|
29
|
+
:diagram_height,
|
30
|
+
:markup,
|
31
|
+
:diagram_extractor
|
10
32
|
|
11
|
-
def initialize(tagName,
|
33
|
+
def initialize(tagName, markup, tokens)
|
12
34
|
super
|
13
35
|
@path_to_diagram = ""
|
14
|
-
@selected_diagram_num =
|
36
|
+
@selected_diagram_num = 0
|
15
37
|
@diagram_height = 200
|
38
|
+
@markup = markup
|
39
|
+
@diagram_extractor = DiagramExtractor.new()
|
40
|
+
end
|
41
|
+
|
42
|
+
def parse_content(context)
|
43
|
+
parameters_line = Liquid::Template.parse(@markup).render context
|
44
|
+
parameters_line.strip!
|
45
|
+
parameters = split_parameters_line(parameters_line)
|
16
46
|
|
17
|
-
|
18
|
-
param_value_pair =
|
47
|
+
parameters.each do |param|
|
48
|
+
param_value_pair = param.split "="
|
19
49
|
if param_value_pair[0] == "path"
|
20
50
|
# TODO: find appropriate method to trim the string
|
21
51
|
@path_to_diagram = param_value_pair[1].tr('\"', "")
|
@@ -29,22 +59,13 @@ class DrawIOConverter < Liquid::Tag
|
|
29
59
|
puts "path=\"#{@path_to_diagram}\" page_num=#{@selected_diagram_num}"
|
30
60
|
end
|
31
61
|
|
32
|
-
def extract_diagram(path)
|
33
|
-
doc = File.open(path) { |f| Nokogiri::XML(f) }
|
34
|
-
diagrams = doc.xpath("//mxfile//diagram")
|
35
|
-
puts "Diagrams found at \"#{path}\": #{diagrams.length}. " \
|
36
|
-
"Selected: #{@selected_diagram_num}. "
|
37
|
-
|
38
|
-
diagram = diagrams[@selected_diagram_num]
|
39
|
-
|
40
|
-
diagram_name = diagram["name"]
|
41
|
-
diagram_content = diagram.to_html
|
42
|
-
|
43
|
-
return diagram_name, diagram_content
|
44
|
-
end
|
45
|
-
|
46
62
|
def render(context)
|
47
|
-
|
63
|
+
if @markup.empty?
|
64
|
+
return "Error processing input, incorrect syntax"
|
65
|
+
end
|
66
|
+
parse_content context
|
67
|
+
|
68
|
+
diagram_name, diagram_content = self.diagram_extractor.extract_diagram @path_to_diagram, @selected_diagram_num
|
48
69
|
encoded_diagram = ERB::Util.url_encode diagram_content
|
49
70
|
encoded_diagram_name = ERB::Util.url_encode diagram_name
|
50
71
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-drawio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Illia Gorbatiuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -42,16 +42,22 @@ dependencies:
|
|
42
42
|
name: erb
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '2.2'
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '5.0'
|
48
51
|
type: :runtime
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
52
|
-
- - "
|
55
|
+
- - ">="
|
53
56
|
- !ruby/object:Gem::Version
|
54
57
|
version: '2.2'
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '5.0'
|
55
61
|
description:
|
56
62
|
email:
|
57
63
|
- ilya.gorbatiuk@gmail.com
|
@@ -59,6 +65,7 @@ executables: []
|
|
59
65
|
extensions: []
|
60
66
|
extra_rdoc_files: []
|
61
67
|
files:
|
68
|
+
- lib/diagram_extractor.rb
|
62
69
|
- lib/jekyll-drawio.rb
|
63
70
|
- lib/jekyll-drawio/version.rb
|
64
71
|
homepage: https://github.com/mutcher/jekyll-drawio
|
@@ -82,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
89
|
- !ruby/object:Gem::Version
|
83
90
|
version: '0'
|
84
91
|
requirements: []
|
85
|
-
rubygems_version: 3.
|
92
|
+
rubygems_version: 3.2.3
|
86
93
|
signing_key:
|
87
94
|
specification_version: 4
|
88
95
|
summary: Jekyll plugin to generate HTML snippets for embedding draw.io diagrams
|