kramdown-plantuml 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/scripts/build-gem.sh +6 -0
- data/.github/scripts/bundle-install.sh +6 -0
- data/.github/scripts/inspect-gem.sh +72 -0
- data/.github/scripts/publish-gem.sh +103 -0
- data/.github/scripts/test-gem.sh +140 -0
- data/.github/scripts/variables.sh +70 -0
- data/.github/workflows/no-java.yml +2 -4
- data/.github/workflows/no-plantuml.yml +5 -5
- data/.github/workflows/ruby.yml +113 -69
- data/.github/workflows/shell.yml +15 -0
- data/.gitignore +5 -0
- data/.rubocop.yml +17 -0
- data/Gemfile +4 -8
- data/LICENSE +201 -21
- data/README.md +31 -31
- data/Rakefile +16 -3
- data/kramdown-plantuml.gemspec +25 -17
- data/lib/kramdown-plantuml.rb +8 -4
- data/lib/kramdown-plantuml/converter.rb +29 -30
- data/lib/kramdown-plantuml/version.rb +3 -2
- data/lib/kramdown_html.rb +17 -9
- data/lib/which.rb +3 -0
- data/pom.xml +16 -0
- metadata +59 -9
- data/bin/console +0 -14
- data/bin/plantuml.1.2020.5.jar +0 -0
- data/bin/setup +0 -8
data/README.md
CHANGED
@@ -4,13 +4,14 @@
|
|
4
4
|
![Build][build-badge]
|
5
5
|
![No Java][no-java-build-badge]
|
6
6
|
![No PlantUML][no-plantuml-badge]
|
7
|
-
[![
|
7
|
+
[![License][license-badge]][license]
|
8
|
+
[![Dependabot Status][dependabot-badge]][dependabot]
|
8
9
|
[![CLA assistant][cla-badge]][cla]
|
9
10
|
[![Contributor Covenant][coc-badge]][coc]
|
10
11
|
|
11
12
|
`kramdown-plantuml` allows you to use [PlantUML][plantuml] syntax within [fenced
|
12
|
-
code blocks][fenced] in [
|
13
|
-
parser:
|
13
|
+
code blocks][fenced] in [Kramdown][kramdown] ([Jekyll][jekyll]'s default
|
14
|
+
Markdown parser):
|
14
15
|
|
15
16
|
````md
|
16
17
|
```plantuml
|
@@ -87,34 +88,33 @@ git commits and tags, and push the `.gem` file to [rubygems.org][gems].
|
|
87
88
|
|
88
89
|
Bug reports and pull requests are welcome on [GitHub][github]. This project is
|
89
90
|
intended to be a safe, welcoming space for collaboration, and contributors are
|
90
|
-
expected to adhere to the [code of conduct][coc] and sign the
|
91
|
-
license agreement][cla].
|
91
|
+
expected to adhere to the [code of conduct][coc] and sign the
|
92
|
+
[contributor's license agreement][cla].
|
92
93
|
|
93
94
|
## License
|
94
95
|
|
95
|
-
The
|
96
|
-
License][license]
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
[
|
103
|
-
[
|
104
|
-
[
|
105
|
-
[
|
106
|
-
[
|
107
|
-
[
|
108
|
-
[
|
109
|
-
[
|
110
|
-
[
|
111
|
-
[
|
112
|
-
[
|
113
|
-
[
|
114
|
-
[
|
115
|
-
[
|
116
|
-
[
|
117
|
-
[
|
118
|
-
[
|
119
|
-
[
|
120
|
-
[no-plantuml-badge]: https://github.com/SwedbankPay/kramdown-plantuml/workflows/No%20PlantUML/badge.svg?branch=master
|
96
|
+
The code within this repository is available as open source under the terms of
|
97
|
+
the [Apache 2.0 License][license] and the [contributor's license
|
98
|
+
agreement][cla].
|
99
|
+
|
100
|
+
[build-badge]: https://github.com/SwedbankPay/kramdown-plantuml/workflows/Ruby%20Gem/badge.svg?branch=master
|
101
|
+
[cla-badge]: https://cla-assistant.io/readme/badge/SwedbankPay/kramdown-plantuml
|
102
|
+
[cla]: https://cla-assistant.io/SwedbankPay/kramdown-plantuml
|
103
|
+
[coc-badge]: https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg
|
104
|
+
[coc]: ./CODE_OF_CONDUCT.md
|
105
|
+
[dependabot-badge]: https://api.dependabot.com/badges/status?host=github&repo=SwedbankPay/kramdown-plantuml
|
106
|
+
[dependabot]: https://dependabot.com
|
107
|
+
[diagram-svg]: ./spec/diagram.svg
|
108
|
+
[fenced]: https://www.markdownguide.org/extended-syntax/#syntax-highlighting
|
109
|
+
[gem-badge]: https://badge.fury.io/rb/kramdown-plantuml.svg
|
110
|
+
[gem-url]: https://rubygems.org/gems/kramdown-plantuml
|
111
|
+
[gems]: https://rubygems.org
|
112
|
+
[github]: https://github.com/SwedbankPay/kramdown-plantuml/
|
113
|
+
[jekyll]: https://jekyllrb.com/
|
114
|
+
[kramdown]: https://kramdown.gettalong.org/
|
115
|
+
[license-badge]: https://img.shields.io/github/license/SwedbankPay/kramdown-plantuml
|
116
|
+
[license]: https://opensource.org/licenses/Apache-2.0
|
117
|
+
[no-java-build-badge]: https://github.com/SwedbankPay/kramdown-plantuml/workflows/No%20Java/badge.svg?branch=master
|
118
|
+
[no-plantuml-badge]: https://github.com/SwedbankPay/kramdown-plantuml/workflows/No%20PlantUML/badge.svg?branch=master
|
119
|
+
[plantuml]: https://plantuml.com/
|
120
|
+
[svg]: https://developer.mozilla.org/en-US/docs/Web/SVG
|
data/Rakefile
CHANGED
@@ -1,10 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rake'
|
2
4
|
require 'bundler/gem_tasks'
|
3
5
|
require 'rspec/core/rake_task'
|
4
6
|
|
5
7
|
RSpec::Core::RakeTask.new(:spec) do |t|
|
6
|
-
|
7
|
-
|
8
|
+
t.pattern = Dir.glob('spec/**/*_spec.rb')
|
9
|
+
t.rspec_opts = '--format documentation --tag ~no_plantuml --tag ~no_java'
|
10
|
+
end
|
11
|
+
|
12
|
+
namespace :codecov do
|
13
|
+
desc 'Uploads the latest SimpleCov result set to codecov.io'
|
14
|
+
task :upload do
|
15
|
+
require 'simplecov'
|
16
|
+
require 'codecov'
|
17
|
+
|
18
|
+
formatter = SimpleCov::Formatter::Codecov.new
|
19
|
+
formatter.format(SimpleCov::ResultMerger.merged_result)
|
20
|
+
end
|
8
21
|
end
|
9
22
|
|
10
|
-
task :
|
23
|
+
task default: :spec
|
data/kramdown-plantuml.gemspec
CHANGED
@@ -1,33 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'lib/which'
|
2
4
|
require_relative 'lib/kramdown-plantuml/version'
|
3
5
|
|
4
6
|
Gem::Specification.new do |spec|
|
5
|
-
spec.name =
|
7
|
+
spec.name = 'kramdown-plantuml'
|
6
8
|
spec.version = Kramdown::PlantUml::VERSION
|
7
|
-
spec.authors = [
|
8
|
-
spec.email = [
|
9
|
+
spec.authors = ['Swedbank Pay']
|
10
|
+
spec.email = ['opensource@swedbankpay.com']
|
9
11
|
|
10
|
-
spec.summary = "
|
11
|
-
spec.homepage =
|
12
|
-
spec.license =
|
13
|
-
spec.required_ruby_version = Gem::Requirement.new(
|
12
|
+
spec.summary = "kramdown-plantuml allows you to use PlantUML syntax within fenced code blocks with Kramdown (Jekyll's default Markdown parser)"
|
13
|
+
spec.homepage = 'https://github.com/SwedbankPay/kramdown-plantuml'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
14
16
|
|
15
|
-
spec.metadata[
|
16
|
-
spec.metadata[
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
18
|
+
spec.metadata['source_code_uri'] = 'https://github.com/SwedbankPay/kramdown-plantuml'
|
17
19
|
|
18
20
|
# Specify which files should be added to the gem when it is released.
|
19
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into
|
20
|
-
spec.files
|
21
|
-
if Which
|
22
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into Git.
|
22
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
23
|
+
if Which.which('git')
|
24
|
+
files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
# Explicitly add plantuml.jar to the list of files as it is not committed to Git.
|
26
|
+
files.append(Dir['bin/**/plantuml*.jar'].first)
|
23
27
|
else
|
24
28
|
puts "Git not found, no files added to #{spec.name}."
|
25
29
|
end
|
26
30
|
end
|
27
|
-
spec.bindir =
|
31
|
+
spec.bindir = 'exe'
|
28
32
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
-
spec.require_paths = [
|
33
|
+
spec.require_paths = ['lib']
|
34
|
+
|
35
|
+
spec.add_dependency 'kramdown', '~> 2.3'
|
36
|
+
spec.add_dependency 'open3', '~> 0.1'
|
30
37
|
|
31
|
-
spec.add_development_dependency
|
32
|
-
spec.add_development_dependency
|
38
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
39
|
+
spec.add_development_dependency 'rspec', '~> 3.2'
|
40
|
+
spec.add_development_dependency 'rubocop', '~> 0.92'
|
33
41
|
end
|
data/lib/kramdown-plantuml.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
-
|
2
|
-
require 'kramdown-plantuml/converter'
|
3
|
-
require 'kramdown_html'
|
1
|
+
# frozen_string_literal: true
|
4
2
|
|
5
|
-
|
3
|
+
require_relative 'kramdown-plantuml/version'
|
4
|
+
require_relative 'kramdown-plantuml/converter'
|
5
|
+
require_relative 'kramdown_html'
|
6
|
+
|
7
|
+
module Kramdown
|
8
|
+
module PlantUml
|
6
9
|
class Error < StandardError; end
|
10
|
+
end
|
7
11
|
end
|
@@ -1,45 +1,44 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'open3'
|
4
|
+
require_relative '../which'
|
3
5
|
require_relative 'version'
|
4
6
|
|
5
|
-
module Kramdown
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
raise IOError
|
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
|
15
19
|
end
|
16
20
|
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
+
def convert_plantuml_to_svg(content)
|
22
|
+
cmd = "java -jar #{@plant_uml_jar_file} -tsvg -pipe"
|
21
23
|
|
22
|
-
|
23
|
-
cmd = "java -jar #{@plant_uml_jar_file} -tsvg -pipe"
|
24
|
+
stdout, stderr, = Open3.capture3(cmd, stdin_data: content)
|
24
25
|
|
25
|
-
|
26
|
+
# Circumvention of https://bugs.openjdk.java.net/browse/JDK-8244621
|
27
|
+
raise stderr unless stderr.empty? || stderr.include?('CoreText note:')
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
xml_prologue_start = "<?xml"
|
32
|
-
xml_prologue_end = "?>"
|
29
|
+
xml_prologue_start = '<?xml'
|
30
|
+
xml_prologue_end = '?>'
|
33
31
|
|
34
|
-
|
35
|
-
|
32
|
+
start_index = stdout.index(xml_prologue_start)
|
33
|
+
end_index = stdout.index(xml_prologue_end, xml_prologue_start.length) + xml_prologue_end.length
|
36
34
|
|
37
|
-
|
35
|
+
stdout.slice! start_index, end_index
|
38
36
|
|
39
|
-
|
40
|
-
|
37
|
+
wrapper_element_start = '<div class="plantuml">'
|
38
|
+
wrapper_element_end = '</div>'
|
41
39
|
|
42
|
-
|
40
|
+
"#{wrapper_element_start}#{stdout}#{wrapper_element_end}"
|
41
|
+
end
|
43
42
|
end
|
44
43
|
end
|
45
44
|
end
|
data/lib/kramdown_html.rb
CHANGED
@@ -1,15 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'kramdown'
|
2
|
-
|
4
|
+
require_relative 'kramdown-plantuml/converter'
|
5
|
+
|
6
|
+
PlantUmlConverter = Kramdown::PlantUml::Converter
|
3
7
|
|
4
|
-
|
5
|
-
|
8
|
+
module Kramdown
|
9
|
+
module Converter
|
10
|
+
# Plugs into Kramdown::Converter::Html to provide conversion of PlantUML markup
|
11
|
+
# into beautiful SVG.
|
12
|
+
class Html
|
13
|
+
alias super_convert_codeblock convert_codeblock
|
6
14
|
|
7
|
-
|
8
|
-
if element.attr[
|
9
|
-
return super_convert_codeblock(element, indent)
|
10
|
-
end
|
15
|
+
def convert_codeblock(element, indent)
|
16
|
+
return super_convert_codeblock(element, indent) if element.attr['class'] != 'language-plantuml'
|
11
17
|
|
12
|
-
converter =
|
13
|
-
|
18
|
+
converter = PlantUmlConverter.new
|
19
|
+
converter.convert_plantuml_to_svg(element.value)
|
20
|
+
end
|
14
21
|
end
|
22
|
+
end
|
15
23
|
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.2020.18</version>
|
14
|
+
</dependency>
|
15
|
+
</dependencies>
|
16
|
+
</project>
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kramdown-plantuml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Swedbank Pay
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-09 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: open3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.1'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: rake
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,32 +66,53 @@ dependencies:
|
|
38
66
|
- - "~>"
|
39
67
|
- !ruby/object:Gem::Version
|
40
68
|
version: '3.2'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.92'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.92'
|
41
83
|
description:
|
42
84
|
email:
|
43
|
-
-
|
85
|
+
- opensource@swedbankpay.com
|
44
86
|
executables: []
|
45
87
|
extensions: []
|
46
88
|
extra_rdoc_files: []
|
47
89
|
files:
|
90
|
+
- ".github/scripts/build-gem.sh"
|
91
|
+
- ".github/scripts/bundle-install.sh"
|
92
|
+
- ".github/scripts/inspect-gem.sh"
|
93
|
+
- ".github/scripts/publish-gem.sh"
|
94
|
+
- ".github/scripts/test-gem.sh"
|
95
|
+
- ".github/scripts/variables.sh"
|
48
96
|
- ".github/workflows/no-java.yml"
|
49
97
|
- ".github/workflows/no-plantuml.yml"
|
50
98
|
- ".github/workflows/ruby.yml"
|
99
|
+
- ".github/workflows/shell.yml"
|
51
100
|
- ".gitignore"
|
52
101
|
- ".rspec"
|
102
|
+
- ".rubocop.yml"
|
53
103
|
- CODE_OF_CONDUCT.md
|
54
104
|
- Gemfile
|
55
105
|
- LICENSE
|
56
106
|
- README.md
|
57
107
|
- Rakefile
|
58
|
-
- bin/
|
59
|
-
- bin/plantuml.1.2020.5.jar
|
60
|
-
- bin/setup
|
108
|
+
- bin/net/sourceforge/plantuml/plantuml/1.2020.18/plantuml-1.2020.18.jar
|
61
109
|
- kramdown-plantuml.gemspec
|
62
110
|
- lib/kramdown-plantuml.rb
|
63
111
|
- lib/kramdown-plantuml/converter.rb
|
64
112
|
- lib/kramdown-plantuml/version.rb
|
65
113
|
- lib/kramdown_html.rb
|
66
114
|
- lib/which.rb
|
115
|
+
- pom.xml
|
67
116
|
homepage: https://github.com/SwedbankPay/kramdown-plantuml
|
68
117
|
licenses:
|
69
118
|
- MIT
|
@@ -85,8 +134,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
134
|
- !ruby/object:Gem::Version
|
86
135
|
version: '0'
|
87
136
|
requirements: []
|
88
|
-
rubygems_version: 3.
|
137
|
+
rubygems_version: 3.1.2
|
89
138
|
signing_key:
|
90
139
|
specification_version: 4
|
91
|
-
summary:
|
140
|
+
summary: kramdown-plantuml allows you to use PlantUML syntax within fenced code blocks
|
141
|
+
with Kramdown (Jekyll's default Markdown parser)
|
92
142
|
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__)
|