kramdown-plantuml 1.0.5 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/codecov.yml +2 -0
- data/.github/dependabot.yml +23 -0
- data/.github/mergify.yml +22 -0
- data/.github/scripts/amend.sh +176 -0
- data/.github/scripts/publish-gem.sh +24 -6
- data/.github/scripts/test-gem.sh +69 -41
- data/.github/scripts/variables.sh +4 -2
- data/.github/workflows/amend.yml +19 -0
- data/.github/workflows/no-java.yml +1 -2
- data/.github/workflows/no-plantuml.yml +4 -7
- data/.github/workflows/ruby.yml +45 -29
- data/.github/workflows/shell.yml +1 -5
- data/.gitignore +4 -0
- data/.rubocop.yml +1 -0
- data/GitVersion.yml +5 -0
- data/README.md +106 -18
- data/Rakefile +18 -1
- data/bin/net/sourceforge/plantuml/plantuml/{1.2020.18/plantuml-1.2020.18.jar → 1.2021.9/plantuml-1.2021.9.jar} +0 -0
- data/kramdown-plantuml.gemspec +10 -3
- data/lib/kramdown-plantuml/bool_env.rb +24 -0
- data/lib/kramdown-plantuml/console_logger.rb +56 -0
- data/lib/kramdown-plantuml/diagram.rb +57 -0
- data/lib/kramdown-plantuml/executor.rb +52 -0
- data/lib/kramdown-plantuml/logger.rb +89 -0
- data/lib/kramdown-plantuml/plantuml_error.rb +70 -0
- data/lib/kramdown-plantuml/plantuml_result.rb +66 -0
- data/lib/kramdown-plantuml/theme.rb +76 -0
- data/lib/kramdown-plantuml/version.rb +1 -1
- data/lib/kramdown-plantuml.rb +0 -8
- data/lib/kramdown_html.rb +8 -5
- data/pom.xml +1 -1
- metadata +78 -10
- data/.github/scripts/bundle-install.sh +0 -6
- data/lib/kramdown-plantuml/converter.rb +0 -44
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
3
|
+
require_relative 'logger'
|
4
|
+
|
5
|
+
module Kramdown
|
6
|
+
module PlantUml
|
7
|
+
# Provides theming support for PlantUML
|
8
|
+
class Theme
|
9
|
+
attr_reader :name, :directory
|
10
|
+
|
11
|
+
def initialize(options = {})
|
12
|
+
@logger = Logger.init
|
13
|
+
@name, @directory = theme_options(options)
|
14
|
+
end
|
15
|
+
|
16
|
+
def apply(plantuml)
|
17
|
+
if plantuml.nil? || !plantuml.is_a?(String) || plantuml.empty?
|
18
|
+
@logger.debug ' kramdown-plantuml: Empty diagram or not a String.'
|
19
|
+
return plantuml
|
20
|
+
end
|
21
|
+
|
22
|
+
if @name.nil? || @name.empty?
|
23
|
+
@logger.debug ' kramdown-plantuml: No theme to apply.'
|
24
|
+
return plantuml
|
25
|
+
end
|
26
|
+
|
27
|
+
theme(plantuml)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def theme_options(options)
|
33
|
+
options = symbolize_keys(options)
|
34
|
+
|
35
|
+
@logger.debug " kramdown-plantuml: Options: #{options}"
|
36
|
+
|
37
|
+
return nil if options.nil? || !options.key?(:theme)
|
38
|
+
|
39
|
+
theme = options[:theme] || {}
|
40
|
+
name = theme.key?(:name) ? theme[:name] : nil
|
41
|
+
directory = theme.key?(:directory) ? theme[:directory] : nil
|
42
|
+
|
43
|
+
[name, directory]
|
44
|
+
end
|
45
|
+
|
46
|
+
def symbolize_keys(options)
|
47
|
+
return options if options.nil?
|
48
|
+
|
49
|
+
array = options.map do |key, value|
|
50
|
+
value = value.is_a?(Hash) ? symbolize_keys(value) : value
|
51
|
+
[key.to_sym, value]
|
52
|
+
end
|
53
|
+
|
54
|
+
array.to_h
|
55
|
+
end
|
56
|
+
|
57
|
+
def theme(plantuml)
|
58
|
+
startuml = '@startuml'
|
59
|
+
startuml_index = plantuml.index(startuml) + startuml.length
|
60
|
+
|
61
|
+
return plantuml if startuml_index.nil?
|
62
|
+
|
63
|
+
theme_string = "\n!theme #{@name}"
|
64
|
+
theme_string << " from #{@directory}" unless @directory.nil?
|
65
|
+
|
66
|
+
@logger.debug " kramdown-plantuml: Applying #{theme_string.strip}"
|
67
|
+
|
68
|
+
/@startuml.*/.match(plantuml) do |match|
|
69
|
+
return plantuml.insert match.end(0), theme_string
|
70
|
+
end
|
71
|
+
|
72
|
+
plantuml
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/lib/kramdown-plantuml.rb
CHANGED
data/lib/kramdown_html.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'kramdown'
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
require 'kramdown-parser-gfm'
|
5
|
+
require_relative 'kramdown-plantuml/logger'
|
6
|
+
require_relative 'kramdown-plantuml/plantuml_error'
|
7
|
+
require_relative 'kramdown-plantuml/diagram'
|
7
8
|
|
8
9
|
module Kramdown
|
9
10
|
module Converter
|
@@ -15,8 +16,10 @@ module Kramdown
|
|
15
16
|
def convert_codeblock(element, indent)
|
16
17
|
return super_convert_codeblock(element, indent) if element.attr['class'] != 'language-plantuml'
|
17
18
|
|
18
|
-
|
19
|
-
|
19
|
+
plantuml = element.value
|
20
|
+
plantuml_options = @options.key?(:plantuml) ? @options[:plantuml] : {}
|
21
|
+
diagram = ::Kramdown::PlantUml::Diagram.new(plantuml, plantuml_options)
|
22
|
+
diagram.convert_to_svg
|
20
23
|
end
|
21
24
|
end
|
22
25
|
end
|
data/pom.xml
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kramdown-plantuml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Swedbank Pay
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: kramdown-parser-gfm
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: open3
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,20 +80,62 @@ dependencies:
|
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '3.2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec-its
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.3'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.3'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: rubocop
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
72
100
|
requirements:
|
73
101
|
- - "~>"
|
74
102
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
103
|
+
version: '1.12'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.12'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop-rake
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.6'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.6'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop-rspec
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '2.4'
|
76
132
|
type: :development
|
77
133
|
prerelease: false
|
78
134
|
version_requirements: !ruby/object:Gem::Requirement
|
79
135
|
requirements:
|
80
136
|
- - "~>"
|
81
137
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
138
|
+
version: '2.4'
|
83
139
|
description:
|
84
140
|
email:
|
85
141
|
- opensource@swedbankpay.com
|
@@ -87,12 +143,16 @@ executables: []
|
|
87
143
|
extensions: []
|
88
144
|
extra_rdoc_files: []
|
89
145
|
files:
|
146
|
+
- ".github/codecov.yml"
|
147
|
+
- ".github/dependabot.yml"
|
148
|
+
- ".github/mergify.yml"
|
149
|
+
- ".github/scripts/amend.sh"
|
90
150
|
- ".github/scripts/build-gem.sh"
|
91
|
-
- ".github/scripts/bundle-install.sh"
|
92
151
|
- ".github/scripts/inspect-gem.sh"
|
93
152
|
- ".github/scripts/publish-gem.sh"
|
94
153
|
- ".github/scripts/test-gem.sh"
|
95
154
|
- ".github/scripts/variables.sh"
|
155
|
+
- ".github/workflows/amend.yml"
|
96
156
|
- ".github/workflows/no-java.yml"
|
97
157
|
- ".github/workflows/no-plantuml.yml"
|
98
158
|
- ".github/workflows/ruby.yml"
|
@@ -102,13 +162,21 @@ files:
|
|
102
162
|
- ".rubocop.yml"
|
103
163
|
- CODE_OF_CONDUCT.md
|
104
164
|
- Gemfile
|
165
|
+
- GitVersion.yml
|
105
166
|
- LICENSE
|
106
167
|
- README.md
|
107
168
|
- Rakefile
|
108
|
-
- bin/net/sourceforge/plantuml/plantuml/1.
|
169
|
+
- bin/net/sourceforge/plantuml/plantuml/1.2021.9/plantuml-1.2021.9.jar
|
109
170
|
- kramdown-plantuml.gemspec
|
110
171
|
- lib/kramdown-plantuml.rb
|
111
|
-
- lib/kramdown-plantuml/
|
172
|
+
- lib/kramdown-plantuml/bool_env.rb
|
173
|
+
- lib/kramdown-plantuml/console_logger.rb
|
174
|
+
- lib/kramdown-plantuml/diagram.rb
|
175
|
+
- lib/kramdown-plantuml/executor.rb
|
176
|
+
- lib/kramdown-plantuml/logger.rb
|
177
|
+
- lib/kramdown-plantuml/plantuml_error.rb
|
178
|
+
- lib/kramdown-plantuml/plantuml_result.rb
|
179
|
+
- lib/kramdown-plantuml/theme.rb
|
112
180
|
- lib/kramdown-plantuml/version.rb
|
113
181
|
- lib/kramdown_html.rb
|
114
182
|
- lib/which.rb
|
@@ -127,16 +195,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
195
|
requirements:
|
128
196
|
- - ">="
|
129
197
|
- !ruby/object:Gem::Version
|
130
|
-
version: 2.
|
198
|
+
version: 2.5.0
|
131
199
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
200
|
requirements:
|
133
201
|
- - ">="
|
134
202
|
- !ruby/object:Gem::Version
|
135
203
|
version: '0'
|
136
204
|
requirements: []
|
137
|
-
rubygems_version: 3.1.
|
205
|
+
rubygems_version: 3.1.6
|
138
206
|
signing_key:
|
139
207
|
specification_version: 4
|
140
208
|
summary: kramdown-plantuml allows you to use PlantUML syntax within fenced code blocks
|
141
|
-
with Kramdown (Jekyll's default Markdown parser)
|
209
|
+
with Kramdown (Jekyll's default Markdown parser).
|
142
210
|
test_files: []
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'open3'
|
4
|
-
require_relative '../which'
|
5
|
-
require_relative 'version'
|
6
|
-
|
7
|
-
module Kramdown
|
8
|
-
module PlantUml
|
9
|
-
# Converts PlantUML markup to SVG
|
10
|
-
class Converter
|
11
|
-
def initialize
|
12
|
-
dir = File.dirname __dir__
|
13
|
-
jar_glob = File.join dir, '../bin/**/plantuml*.jar'
|
14
|
-
@plant_uml_jar_file = Dir[jar_glob].first
|
15
|
-
|
16
|
-
raise IOError, 'Java can not be found' unless Which.which('java')
|
17
|
-
raise IOError, "No 'plantuml.jar' file could be found" if @plant_uml_jar_file.nil?
|
18
|
-
raise IOError, "'#{@plant_uml_jar_file}' does not exist" unless File.exist? @plant_uml_jar_file
|
19
|
-
end
|
20
|
-
|
21
|
-
def convert_plantuml_to_svg(content)
|
22
|
-
cmd = "java -jar #{@plant_uml_jar_file} -tsvg -pipe"
|
23
|
-
|
24
|
-
stdout, stderr, = Open3.capture3(cmd, stdin_data: content)
|
25
|
-
|
26
|
-
# Circumvention of https://bugs.openjdk.java.net/browse/JDK-8244621
|
27
|
-
raise stderr unless stderr.empty? || stderr.include?('CoreText note:')
|
28
|
-
|
29
|
-
xml_prologue_start = '<?xml'
|
30
|
-
xml_prologue_end = '?>'
|
31
|
-
|
32
|
-
start_index = stdout.index(xml_prologue_start)
|
33
|
-
end_index = stdout.index(xml_prologue_end, xml_prologue_start.length) + xml_prologue_end.length
|
34
|
-
|
35
|
-
stdout.slice! start_index, end_index
|
36
|
-
|
37
|
-
wrapper_element_start = '<div class="plantuml">'
|
38
|
-
wrapper_element_end = '</div>'
|
39
|
-
|
40
|
-
"#{wrapper_element_start}#{stdout}#{wrapper_element_end}"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|