kramdown-plantuml 1.0.1 → 1.1.2
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/build-gem.sh +6 -0
- data/.github/scripts/inspect-gem.sh +72 -0
- data/.github/scripts/publish-gem.sh +121 -0
- data/.github/scripts/test-gem.sh +170 -0
- data/.github/scripts/variables.sh +72 -0
- data/.github/workflows/amend.yml +19 -0
- data/.github/workflows/no-java.yml +3 -6
- data/.github/workflows/no-plantuml.yml +6 -9
- data/.github/workflows/ruby.yml +139 -86
- data/.github/workflows/shell.yml +11 -0
- data/.gitignore +9 -0
- data/.rubocop.yml +18 -0
- data/CODE_OF_CONDUCT.md +11 -9
- data/Gemfile +4 -8
- data/GitVersion.yml +5 -0
- data/LICENSE +201 -21
- data/README.md +143 -35
- data/Rakefile +33 -3
- data/bin/{plantuml.1.2020.5.jar → net/sourceforge/plantuml/plantuml/1.2021.8/plantuml-1.2021.8.jar} +0 -0
- data/kramdown-plantuml.gemspec +32 -17
- data/lib/kramdown-plantuml.rb +4 -6
- data/lib/kramdown-plantuml/bool_env.rb +24 -0
- data/lib/kramdown-plantuml/console_logger.rb +56 -0
- data/lib/kramdown-plantuml/converter.rb +39 -21
- data/lib/kramdown-plantuml/executor.rb +48 -0
- data/lib/kramdown-plantuml/hash.rb +14 -0
- data/lib/kramdown-plantuml/logger.rb +77 -0
- data/lib/kramdown-plantuml/plantuml_error.rb +33 -0
- data/lib/kramdown-plantuml/plantuml_result.rb +50 -0
- data/lib/kramdown-plantuml/themer.rb +64 -0
- data/lib/kramdown-plantuml/version.rb +3 -2
- data/lib/kramdown_html.rb +21 -9
- data/lib/which.rb +3 -0
- data/pom.xml +16 -0
- metadata +131 -12
- data/bin/console +0 -14
- data/bin/setup +0 -8
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'logger'
|
4
|
+
require_relative 'plantuml_error'
|
5
|
+
|
6
|
+
module Kramdown
|
7
|
+
module PlantUml
|
8
|
+
# Executes the PlantUML Java application.
|
9
|
+
class PlantUmlResult
|
10
|
+
attr_reader :stdout, :stderr, :exitcode
|
11
|
+
|
12
|
+
def initialize(stdout, stderr, status)
|
13
|
+
@stdout = stdout
|
14
|
+
@stderr = stderr
|
15
|
+
@exitcode = status.exitstatus
|
16
|
+
@logger = Logger.init
|
17
|
+
end
|
18
|
+
|
19
|
+
def without_xml_prologue
|
20
|
+
return @stdout if @stdout.nil? || @stdout.empty?
|
21
|
+
|
22
|
+
xml_prologue_start = '<?xml'
|
23
|
+
xml_prologue_end = '?>'
|
24
|
+
|
25
|
+
start_index = @stdout.index(xml_prologue_start)
|
26
|
+
|
27
|
+
return @stdout if start_index.nil?
|
28
|
+
|
29
|
+
end_index = @stdout.index(xml_prologue_end, xml_prologue_start.length)
|
30
|
+
|
31
|
+
return @stdout if end_index.nil?
|
32
|
+
|
33
|
+
end_index += xml_prologue_end.length
|
34
|
+
|
35
|
+
@stdout.slice! start_index, end_index
|
36
|
+
|
37
|
+
@stdout
|
38
|
+
end
|
39
|
+
|
40
|
+
def validate(plantuml)
|
41
|
+
raise PlantUmlError.new(plantuml, @stderr, @exitcode) if PlantUmlError.should_raise?(@exitcode, @stderr)
|
42
|
+
|
43
|
+
return if @stderr.nil? || @stderr.empty?
|
44
|
+
|
45
|
+
@logger.debug 'kramdown-plantuml: PlantUML log:'
|
46
|
+
@logger.debug_with_prefix 'kramdown-plantuml: ', @stderr
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
|
3
|
+
require_relative 'hash'
|
4
|
+
require_relative 'logger'
|
5
|
+
|
6
|
+
module Kramdown
|
7
|
+
module PlantUml
|
8
|
+
# Provides theming support for PlantUML
|
9
|
+
class Themer
|
10
|
+
attr_reader :theme_name, :theme_directory
|
11
|
+
|
12
|
+
def initialize(options = {})
|
13
|
+
options = options.symbolize_keys unless options.nil?
|
14
|
+
@logger = Logger.init
|
15
|
+
@logger.debug "kramdown-plantuml: Options: #{options}"
|
16
|
+
@theme_name, @theme_directory = theme_options(options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def apply_theme(plantuml)
|
20
|
+
if plantuml.nil? || plantuml.empty?
|
21
|
+
@logger.debug 'kramdown-plantuml: Empty diagram.'
|
22
|
+
return plantuml
|
23
|
+
end
|
24
|
+
|
25
|
+
if @theme_name.nil? || @theme_name.empty?
|
26
|
+
@logger.debug 'kramdown-plantuml: No theme to apply.'
|
27
|
+
return plantuml
|
28
|
+
end
|
29
|
+
|
30
|
+
theme(plantuml)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def theme_options(options)
|
36
|
+
return nil if options.nil? || !options.key?(:theme)
|
37
|
+
|
38
|
+
theme = options[:theme] || {}
|
39
|
+
theme_name = theme.key?(:name) ? theme[:name] : nil
|
40
|
+
theme_directory = theme.key?(:directory) ? theme[:directory] : nil
|
41
|
+
|
42
|
+
[theme_name, theme_directory]
|
43
|
+
end
|
44
|
+
|
45
|
+
def theme(plantuml)
|
46
|
+
startuml = '@startuml'
|
47
|
+
startuml_index = plantuml.index(startuml) + startuml.length
|
48
|
+
|
49
|
+
return plantuml if startuml_index.nil?
|
50
|
+
|
51
|
+
theme_string = "\n!theme #{@theme_name}"
|
52
|
+
theme_string << " from #{@theme_directory}" unless @theme_directory.nil?
|
53
|
+
|
54
|
+
@logger.debug "kramdown-plantuml: Applying #{theme_string}"
|
55
|
+
|
56
|
+
/@startuml.*/.match(plantuml) do |match|
|
57
|
+
return plantuml.insert match.end(0), theme_string
|
58
|
+
end
|
59
|
+
|
60
|
+
plantuml
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/kramdown_html.rb
CHANGED
@@ -1,15 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'kramdown'
|
2
|
-
require
|
4
|
+
require 'kramdown-parser-gfm'
|
5
|
+
require_relative 'kramdown-plantuml/converter'
|
6
|
+
require_relative 'kramdown-plantuml/logger'
|
7
|
+
require_relative 'kramdown-plantuml/plantuml_error'
|
8
|
+
|
9
|
+
module Kramdown
|
10
|
+
module Converter
|
11
|
+
# Plugs into Kramdown::Converter::Html to provide conversion of PlantUML markup
|
12
|
+
# into beautiful SVG.
|
13
|
+
class Html
|
14
|
+
alias super_convert_codeblock convert_codeblock
|
3
15
|
|
4
|
-
|
5
|
-
|
16
|
+
def convert_codeblock(element, indent)
|
17
|
+
return super_convert_codeblock(element, indent) if element.attr['class'] != 'language-plantuml'
|
6
18
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
19
|
+
plantuml = element.value
|
20
|
+
plantuml_options = @options.key?(:plantuml) ? @options[:plantuml] : {}
|
21
|
+
converter = ::Kramdown::PlantUml::Converter.new(plantuml_options || {})
|
11
22
|
|
12
|
-
converter
|
13
|
-
|
23
|
+
converter.convert_plantuml_to_svg(plantuml)
|
24
|
+
end
|
14
25
|
end
|
26
|
+
end
|
15
27
|
end
|
data/lib/which.rb
CHANGED
data/pom.xml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
2
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
3
|
+
http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
4
|
+
<modelVersion>4.0.0</modelVersion>
|
5
|
+
<groupId>com.swedbankpay</groupId>
|
6
|
+
<artifactId>kramdown-plantuml</artifactId>
|
7
|
+
<version>INVALID</version>
|
8
|
+
<name>Kramdown::PlantUml</name>
|
9
|
+
<dependencies>
|
10
|
+
<dependency>
|
11
|
+
<groupId>net.sourceforge.plantuml</groupId>
|
12
|
+
<artifactId>plantuml</artifactId>
|
13
|
+
<version>1.2021.9</version>
|
14
|
+
</dependency>
|
15
|
+
</dependencies>
|
16
|
+
</project>
|
metadata
CHANGED
@@ -1,29 +1,71 @@
|
|
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.2
|
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-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: kramdown
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
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'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: open3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.1'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.1'
|
13
55
|
- !ruby/object:Gem::Dependency
|
14
56
|
name: rake
|
15
57
|
requirement: !ruby/object:Gem::Requirement
|
16
58
|
requirements:
|
17
59
|
- - "~>"
|
18
60
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
61
|
+
version: '13.0'
|
20
62
|
type: :development
|
21
63
|
prerelease: false
|
22
64
|
version_requirements: !ruby/object:Gem::Requirement
|
23
65
|
requirements:
|
24
66
|
- - "~>"
|
25
67
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
68
|
+
version: '13.0'
|
27
69
|
- !ruby/object:Gem::Dependency
|
28
70
|
name: rspec
|
29
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,32 +80,108 @@ dependencies:
|
|
38
80
|
- - "~>"
|
39
81
|
- !ruby/object:Gem::Version
|
40
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'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::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'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '2.4'
|
41
139
|
description:
|
42
140
|
email:
|
43
|
-
-
|
141
|
+
- opensource@swedbankpay.com
|
44
142
|
executables: []
|
45
143
|
extensions: []
|
46
144
|
extra_rdoc_files: []
|
47
145
|
files:
|
146
|
+
- ".github/codecov.yml"
|
147
|
+
- ".github/dependabot.yml"
|
148
|
+
- ".github/mergify.yml"
|
149
|
+
- ".github/scripts/amend.sh"
|
150
|
+
- ".github/scripts/build-gem.sh"
|
151
|
+
- ".github/scripts/inspect-gem.sh"
|
152
|
+
- ".github/scripts/publish-gem.sh"
|
153
|
+
- ".github/scripts/test-gem.sh"
|
154
|
+
- ".github/scripts/variables.sh"
|
155
|
+
- ".github/workflows/amend.yml"
|
48
156
|
- ".github/workflows/no-java.yml"
|
49
157
|
- ".github/workflows/no-plantuml.yml"
|
50
158
|
- ".github/workflows/ruby.yml"
|
159
|
+
- ".github/workflows/shell.yml"
|
51
160
|
- ".gitignore"
|
52
161
|
- ".rspec"
|
162
|
+
- ".rubocop.yml"
|
53
163
|
- CODE_OF_CONDUCT.md
|
54
164
|
- Gemfile
|
165
|
+
- GitVersion.yml
|
55
166
|
- LICENSE
|
56
167
|
- README.md
|
57
168
|
- Rakefile
|
58
|
-
- bin/
|
59
|
-
- bin/plantuml.1.2020.5.jar
|
60
|
-
- bin/setup
|
169
|
+
- bin/net/sourceforge/plantuml/plantuml/1.2021.8/plantuml-1.2021.8.jar
|
61
170
|
- kramdown-plantuml.gemspec
|
62
171
|
- lib/kramdown-plantuml.rb
|
172
|
+
- lib/kramdown-plantuml/bool_env.rb
|
173
|
+
- lib/kramdown-plantuml/console_logger.rb
|
63
174
|
- lib/kramdown-plantuml/converter.rb
|
175
|
+
- lib/kramdown-plantuml/executor.rb
|
176
|
+
- lib/kramdown-plantuml/hash.rb
|
177
|
+
- lib/kramdown-plantuml/logger.rb
|
178
|
+
- lib/kramdown-plantuml/plantuml_error.rb
|
179
|
+
- lib/kramdown-plantuml/plantuml_result.rb
|
180
|
+
- lib/kramdown-plantuml/themer.rb
|
64
181
|
- lib/kramdown-plantuml/version.rb
|
65
182
|
- lib/kramdown_html.rb
|
66
183
|
- lib/which.rb
|
184
|
+
- pom.xml
|
67
185
|
homepage: https://github.com/SwedbankPay/kramdown-plantuml
|
68
186
|
licenses:
|
69
187
|
- MIT
|
@@ -78,15 +196,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
196
|
requirements:
|
79
197
|
- - ">="
|
80
198
|
- !ruby/object:Gem::Version
|
81
|
-
version: 2.
|
199
|
+
version: 2.5.0
|
82
200
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
201
|
requirements:
|
84
202
|
- - ">="
|
85
203
|
- !ruby/object:Gem::Version
|
86
204
|
version: '0'
|
87
205
|
requirements: []
|
88
|
-
rubygems_version: 3.
|
206
|
+
rubygems_version: 3.1.6
|
89
207
|
signing_key:
|
90
208
|
specification_version: 4
|
91
|
-
summary:
|
209
|
+
summary: kramdown-plantuml allows you to use PlantUML syntax within fenced code blocks
|
210
|
+
with Kramdown (Jekyll's default Markdown parser).
|
92
211
|
test_files: []
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "kramdown-plantuml"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|