kramdown-plantuml 1.3.0 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc1234f77cba369797da8b8efd79b0a1913e65cd07f14ab26189c0acb2fa4900
4
- data.tar.gz: 445fea556a2c3f248a3158e3f8fd9383624a1aceefb1e03e549e48ce87a6a4de
3
+ metadata.gz: 1b755b8fc90e54aada29c40ce3b4391858d2b978487a82a9965bef5da8084b08
4
+ data.tar.gz: 0afb90a2bc66c705f7efb6e5c48d26c3e7e3ab83f1fd4ba2300090121b844958
5
5
  SHA512:
6
- metadata.gz: 62dea36dfd6f811cb0861db862a938ae6e10f4d36fa1783ef33ec2338355710cfe8c718fcaf246cc73974d652729ea99560220997ef12c44174a8b6b1adbab1b
7
- data.tar.gz: b9b72275e8eec577c9a249802191f8e9a457b1dfdb4e83328e2e4a942f43077ab39c08fbff2790af23f7c1c3c6d451250bfab7effa7b47455d994472bea1c439
6
+ metadata.gz: fc479376cac81326afd561679f65d84ae110a762cf85ecd6936713f7dcaf019dbb7031890ea038dd4874955ffcdf7ca71fdca3ad30756d7526579cde89385d87
7
+ data.tar.gz: 605bcc56726601a048cc69599c0b8a72f6845cb1145af7549d35cb832b3aff515aae6dbf560294145509897b86ca698fde5848d21f34cc9230360a0f01517b9a
data/.github/mergify.yml CHANGED
@@ -9,10 +9,15 @@ pull_request_rules:
9
9
  - name: Automatic merge on approval
10
10
  conditions:
11
11
  - author~=^dependabot(|-preview)\[bot\]$
12
+ - '#commits-behind=0' # Only merge up to date pull requests
13
+ - check-success=test
14
+ - check-success=version
15
+ - check-success=plantuml
16
+ - check-success=gem
17
+ - check-success=shellcheck
18
+ - check-success=license/cla
12
19
  actions:
13
20
  merge:
14
- method: merge
15
- strict: smart
16
21
 
17
22
  - name: Thank contributor
18
23
  conditions:
@@ -9,7 +9,7 @@ jobs:
9
9
  if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/amend')
10
10
  runs-on: ubuntu-latest
11
11
  steps:
12
- - uses: actions/checkout@v2
12
+ - uses: actions/checkout@v3
13
13
  with:
14
14
  persist-credentials: false
15
15
  - name: amend
@@ -13,7 +13,7 @@ jobs:
13
13
  image: ruby:2.7.2
14
14
 
15
15
  steps:
16
- - uses: actions/checkout@v2
16
+ - uses: actions/checkout@v3
17
17
 
18
18
  - name: Bundle install
19
19
  run: bundle install --jobs 4 --retry 3
@@ -11,7 +11,7 @@ jobs:
11
11
  runs-on: ubuntu-latest
12
12
 
13
13
  steps:
14
- - uses: actions/checkout@v2
14
+ - uses: actions/checkout@v3
15
15
 
16
16
  - name: Set up Ruby 2.7
17
17
  uses: ruby/setup-ruby@v1
@@ -10,18 +10,18 @@ jobs:
10
10
  version: ${{ steps.variables.outputs.version }}
11
11
 
12
12
  steps:
13
- - uses: actions/checkout@v2
13
+ - uses: actions/checkout@v3
14
14
  with:
15
15
  fetch-depth: 0
16
16
 
17
17
  - name: Setup GitVersion
18
- uses: gittools/actions/gitversion/setup@v0.9.11
18
+ uses: gittools/actions/gitversion/setup@v0.9.13
19
19
  with:
20
20
  versionSpec: '5.x.x'
21
21
 
22
22
  - name: Execute GitVersion
23
23
  id: gitversion
24
- uses: gittools/actions/gitversion/execute@v0.9.11
24
+ uses: gittools/actions/gitversion/execute@v0.9.13
25
25
 
26
26
  - name: Create variables
27
27
  id: variables
@@ -34,16 +34,16 @@ jobs:
34
34
  runs-on: ubuntu-latest
35
35
 
36
36
  steps:
37
- - uses: actions/checkout@v2
37
+ - uses: actions/checkout@v3
38
38
 
39
39
  - name: Setup Java
40
- uses: actions/setup-java@v2
40
+ uses: actions/setup-java@v3
41
41
  with:
42
42
  distribution: adopt
43
43
  java-version: 14
44
44
 
45
45
  - name: Cache Maven dependencies
46
- uses: actions/cache@v2.1.6
46
+ uses: actions/cache@v3
47
47
  with:
48
48
  path: ~/.m2/repository
49
49
  key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
@@ -56,7 +56,7 @@ jobs:
56
56
  run: mvn install
57
57
 
58
58
  - name: Upload plantuml.jar artifact
59
- uses: actions/upload-artifact@v2
59
+ uses: actions/upload-artifact@v3
60
60
  with:
61
61
  name: plantuml.jar
62
62
  path: ~/.m2/repository/**/plantuml*.jar
@@ -69,9 +69,9 @@ jobs:
69
69
  name: ${{ steps.gem.outputs.name }}
70
70
 
71
71
  steps:
72
- - uses: actions/checkout@v2
72
+ - uses: actions/checkout@v3
73
73
 
74
- - uses: actions/download-artifact@v2
74
+ - uses: actions/download-artifact@v3
75
75
  with:
76
76
  name: plantuml.jar
77
77
  path: bin/
@@ -97,7 +97,7 @@ jobs:
97
97
  run: bundle exec rspec --format documentation --tag debug
98
98
 
99
99
  - name: Upload code coverage (debug)
100
- uses: actions/upload-artifact@v2
100
+ uses: actions/upload-artifact@v3
101
101
  with:
102
102
  name: rspec-debug-coverage
103
103
  path: ./coverage
@@ -109,7 +109,7 @@ jobs:
109
109
  run: bundle exec rake
110
110
 
111
111
  - name: Upload code coverage
112
- uses: actions/upload-artifact@v2
112
+ uses: actions/upload-artifact@v3
113
113
  with:
114
114
  name: rspec-coverage
115
115
  path: ./coverage
@@ -125,7 +125,7 @@ jobs:
125
125
  git checkout HEAD -- Gemfile
126
126
 
127
127
  - name: Upload code coverage (Jekyll)
128
- uses: actions/upload-artifact@v2
128
+ uses: actions/upload-artifact@v3
129
129
  with:
130
130
  name: rspec-jekyll-coverage
131
131
  path: ./coverage
@@ -138,7 +138,7 @@ jobs:
138
138
  run: .github/scripts/build-gem.sh --ref ${{ github.ref }} --verbose
139
139
 
140
140
  - name: Upload gem
141
- uses: actions/upload-artifact@v2-preview
141
+ uses: actions/upload-artifact@v3
142
142
  with:
143
143
  name: ${{ steps.gem.outputs.name }}
144
144
  path: ${{ steps.gem.outputs.name }}
@@ -150,7 +150,7 @@ jobs:
150
150
  run: .github/scripts/test-gem.sh --workdir "${{ github.workspace }}/spec/examples" --gemdir "${{ github.workspace }}" --verbose
151
151
 
152
152
  - name: Upload code coverage (gem)
153
- uses: actions/upload-artifact@v2
153
+ uses: actions/upload-artifact@v3
154
154
  with:
155
155
  name: gem-coverage
156
156
  path: ./coverage
@@ -166,15 +166,15 @@ jobs:
166
166
  (github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]')
167
167
 
168
168
  steps:
169
- - uses: actions/checkout@v2
169
+ - uses: actions/checkout@v3
170
170
  if: ${{ github.event_name != 'pull_request_target' }}
171
171
 
172
- - uses: actions/checkout@v2
172
+ - uses: actions/checkout@v3
173
173
  if: ${{ github.event_name == 'pull_request_target' }}
174
174
  with:
175
175
  ref: ${{ github.event.pull_request.head.sha }}
176
176
 
177
- - uses: actions/download-artifact@v2
177
+ - uses: actions/download-artifact@v3
178
178
  with:
179
179
  name: ${{ needs.gem.outputs.name }}
180
180
 
@@ -200,7 +200,7 @@ jobs:
200
200
  run: .github/scripts/test-gem.sh --workdir "${{ github.workspace }}/spec/examples" --version ${{ needs.version.outputs.version }} --token "${{ secrets.GPR_TOKEN }}" --verbose --theme-name c2a3b0 --theme-directory "${{ github.workspace }}/spec/examples"
201
201
 
202
202
  - name: Upload Jekyll site
203
- uses: actions/upload-artifact@v2-preview
203
+ uses: actions/upload-artifact@v3
204
204
  if: always()
205
205
  with:
206
206
  name: site
@@ -212,9 +212,9 @@ jobs:
212
212
  if: startsWith(github.ref, 'refs/tags/') # Only publish tagged commits
213
213
 
214
214
  steps:
215
- - uses: actions/checkout@v2
215
+ - uses: actions/checkout@v3
216
216
 
217
- - uses: actions/download-artifact@v2
217
+ - uses: actions/download-artifact@v3
218
218
  with:
219
219
  name: ${{ needs.gem.outputs.name }}
220
220
 
data/README.md CHANGED
@@ -127,7 +127,7 @@ kramdown:
127
127
  plantuml:
128
128
  theme:
129
129
  name: my-custom-theme
130
- directory: path/to/themes
130
+ directory: spec/examples
131
131
  ```
132
132
 
133
133
  ### Dimensions and Styling
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kramdown
4
+ module PlantUml
5
+ # Plugs into Kramdown::Converter::Html to provide conversion of PlantUML markup
6
+ # into beautiful SVG.
7
+ module ConverterExtension
8
+ def convert_codeblock(element, indent)
9
+ return super(element, indent) unless plantuml? element
10
+
11
+ convert_plantuml(element.value)
12
+ end
13
+
14
+ private
15
+
16
+ def plantuml?(element)
17
+ element.attr['class'] == 'language-plantuml'
18
+ end
19
+
20
+ def convert_plantuml(plantuml)
21
+ puml_opts = PlantUml::Options.new(@options)
22
+ diagram = PlantUml::PlantUmlDiagram.new(plantuml, puml_opts)
23
+ diagram.svg.to_s
24
+ rescue StandardError => e
25
+ raise e if puml_opts.nil? || puml_opts.raise_errors?
26
+
27
+ logger = PlantUml::LogWrapper.init
28
+ logger.error "Error while converting diagram: #{e.inspect}"
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,14 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'log_wrapper'
4
- require_relative 'jekyll_page_processor'
5
4
 
6
5
  module Kramdown
7
6
  module PlantUml
8
7
  # Provides an instance of Jekyll if available.
9
8
  module JekyllProvider
10
9
  class << self
11
- attr_reader :site_destination_dir
10
+ attr_reader :site_source_dir
12
11
 
13
12
  def jekyll
14
13
  return @jekyll if defined? @jekyll
@@ -16,52 +15,17 @@ module Kramdown
16
15
  @jekyll = load_jekyll
17
16
  end
18
17
 
19
- def install
20
- return @installed = false if jekyll.nil?
21
-
22
- find_site_destination_dir
23
- register_hook
24
- @installed = true
25
- end
26
-
27
- def installed?
28
- @installed
29
- end
30
-
31
- def needle(plantuml, options)
32
- JekyllPageProcessor.needle(plantuml, options)
33
- end
34
-
35
18
  private
36
19
 
37
- def find_site_destination_dir
20
+ def find_site_source_dir
38
21
  if jekyll.sites.nil? || jekyll.sites.empty?
39
- logger.debug 'Jekyll detected, hooking into :site:post_write.'
22
+ logger.warn 'Jekyll detected, but no sites found.'
40
23
  return nil
41
24
  end
42
25
 
43
- @site_destination_dir = jekyll.sites.first.dest
44
- logger.debug "Jekyll detected, hooking into :site:post_write of '#{@site_destination_dir}'."
45
- @site_destination_dir
46
- end
47
-
48
- def register_hook
49
- Jekyll::Hooks.register :site, :post_write do |site|
50
- site_post_write(site)
51
- end
52
- end
53
-
54
- def site_post_write(site)
55
- logger.debug 'Jekyll:site:post_write triggered.'
56
- @site_destination_dir ||= site.dest
57
-
58
- site.pages.each do |page|
59
- processor = JekyllPageProcessor.new(page)
60
-
61
- next unless processor.should_process?
62
-
63
- processor.process(site.dest)
64
- end
26
+ @site_source_dir = jekyll.sites.first.source
27
+ logger.debug "Jekyll detected, using '#{@site_source_dir}' as base directory."
28
+ @site_source_dir
65
29
  end
66
30
 
67
31
  def load_jekyll
@@ -18,7 +18,7 @@ module Kramdown
18
18
  raise ArgumentError, 'options cannot be nil' if options.nil?
19
19
  raise ArgumentError, "options must be a '#{Options}'." unless options.is_a?(Options)
20
20
 
21
- @plantuml = plantuml
21
+ @plantuml = plantuml.strip unless plantuml.nil?
22
22
  @options = options
23
23
  @theme = Theme.new(options)
24
24
  @logger = LogWrapper.init
@@ -35,9 +35,9 @@ module Kramdown
35
35
  def resolve(directory)
36
36
  jekyll = JekyllProvider
37
37
 
38
- return directory if directory.nil? || directory.empty? || !jekyll.installed?
38
+ return directory if directory.nil? || directory.empty?
39
39
 
40
- directory = File.absolute_path(directory, jekyll.site_destination_dir)
40
+ directory = File.absolute_path(directory, jekyll.site_source_dir)
41
41
 
42
42
  log_or_raise "The theme directory '#{directory}' cannot be found" unless Dir.exist?(directory)
43
43
 
@@ -51,7 +51,7 @@ module Kramdown
51
51
  def log_or_raise(message)
52
52
  raise IOError, message if @raise_errors
53
53
 
54
- logger.warn message
54
+ @logger.warn message
55
55
  end
56
56
 
57
57
  def theme(plantuml)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kramdown
4
4
  module PlantUml
5
- VERSION = '1.3.0'
5
+ VERSION = '1.3.3'
6
6
  end
7
7
  end
@@ -1,6 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'kramdown_html'
4
- require_relative 'kramdown-plantuml/jekyll_provider'
5
-
6
- ::Kramdown::PlantUml::JekyllProvider.install
data/lib/kramdown_html.rb CHANGED
@@ -6,46 +6,6 @@ require_relative 'kramdown-plantuml/log_wrapper'
6
6
  require_relative 'kramdown-plantuml/plantuml_error'
7
7
  require_relative 'kramdown-plantuml/options'
8
8
  require_relative 'kramdown-plantuml/plantuml_diagram'
9
- require_relative 'kramdown-plantuml/jekyll_provider'
9
+ require_relative 'kramdown-plantuml/converter_extension'
10
10
 
11
- module Kramdown
12
- module Converter
13
- # Plugs into Kramdown::Converter::Html to provide conversion of PlantUML markup
14
- # into beautiful SVG.
15
- class Html
16
- alias super_convert_codeblock convert_codeblock
17
-
18
- def convert_codeblock(element, indent)
19
- return super_convert_codeblock(element, indent) unless plantuml?(element)
20
-
21
- jekyll = ::Kramdown::PlantUml::JekyllProvider
22
-
23
- # If Jekyll is successfully loaded, we'll wait with converting the
24
- # PlantUML diagram to SVG since a theme may be configured that needs to
25
- # be copied to the assets directory before the PlantUML conversion can
26
- # be performed. We therefore place a needle in the haystack that we will
27
- # convert in the :site:pre_render hook.
28
- options = ::Kramdown::PlantUml::Options.new(@options)
29
- return jekyll.needle(element.value, options) if jekyll.installed?
30
-
31
- convert_plantuml(element.value, options)
32
- end
33
-
34
- private
35
-
36
- def plantuml?(element)
37
- element.attr['class'] == 'language-plantuml'
38
- end
39
-
40
- def convert_plantuml(plantuml, options)
41
- diagram = ::Kramdown::PlantUml::PlantUmlDiagram.new(plantuml, options)
42
- diagram.svg.to_s
43
- rescue StandardError => e
44
- raise e if options.raise_errors?
45
-
46
- logger = ::Kramdown::PlantUml::LogWrapper.init
47
- logger.error "Error while replacing needle: #{e.inspect}"
48
- end
49
- end
50
- end
51
- end
11
+ Kramdown::Converter::Html.prepend Kramdown::PlantUml::ConverterExtension
data/pom.xml CHANGED
@@ -10,7 +10,7 @@
10
10
  <dependency>
11
11
  <groupId>net.sourceforge.plantuml</groupId>
12
12
  <artifactId>plantuml</artifactId>
13
- <version>1.2021.14</version>
13
+ <version>1.2022.6</version>
14
14
  </dependency>
15
15
  </dependencies>
16
16
  </project>
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.3.0
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Swedbank Pay
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-18 00:00:00.000000000 Z
11
+ date: 2022-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -194,13 +194,13 @@ files:
194
194
  - LICENSE
195
195
  - README.md
196
196
  - Rakefile
197
- - bin/net/sourceforge/plantuml/plantuml/1.2021.12/plantuml-1.2021.12.jar
197
+ - bin/net/sourceforge/plantuml/plantuml/1.2022.6/plantuml-1.2022.6.jar
198
198
  - kramdown-plantuml.gemspec
199
199
  - lib/kramdown-plantuml.rb
200
200
  - lib/kramdown-plantuml/bool_env.rb
201
201
  - lib/kramdown-plantuml/console_logger.rb
202
+ - lib/kramdown-plantuml/converter_extension.rb
202
203
  - lib/kramdown-plantuml/executor.rb
203
- - lib/kramdown-plantuml/jekyll_page_processor.rb
204
204
  - lib/kramdown-plantuml/jekyll_provider.rb
205
205
  - lib/kramdown-plantuml/log_wrapper.rb
206
206
  - lib/kramdown-plantuml/none_s.rb
@@ -1,103 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'htmlentities'
4
- require 'json'
5
- require_relative 'log_wrapper'
6
-
7
- module Kramdown
8
- module PlantUml
9
- # Processes Jekyll pages.
10
- class JekyllPageProcessor
11
- PROCESSED_KEY = :kramdown_plantuml_processed
12
-
13
- def initialize(page)
14
- raise ArgumentError, 'page cannot be nil' if page.nil?
15
-
16
- @page = page
17
- end
18
-
19
- def process(site_destination_directory)
20
- @page.output = do_process
21
- @page.data[PROCESSED_KEY] = true
22
- @page.write(site_destination_directory)
23
- end
24
-
25
- def should_process?
26
- return false unless @page.output_ext == '.html'
27
-
28
- if !@page.data.nil? && @page.data.key?(PROCESSED_KEY) && @page.data[PROCESSED_KEY]
29
- logger.debug "Skipping #{@page.path} because it has already been processed."
30
- return false
31
- end
32
-
33
- true
34
- end
35
-
36
- class << self
37
- def needle(plantuml, options)
38
- hash = { 'plantuml' => plantuml, 'options' => options.to_h }
39
-
40
- <<~NEEDLE
41
- <!--#kramdown-plantuml.start#-->
42
- #{hash.to_json}
43
- <!--#kramdown-plantuml.end#-->
44
- NEEDLE
45
- rescue StandardError => e
46
- raise e if options.nil? || options.raise_errors?
47
-
48
- logger.error 'Error while placing needle.'
49
- logger.error e.to_s
50
- logger.debug_multiline plantuml
51
- end
52
-
53
- def logger
54
- @logger ||= ::Kramdown::PlantUml::LogWrapper.init
55
- end
56
- end
57
-
58
- private
59
-
60
- def do_process
61
- logger.debug "Replacing Jekyll needles in #{@page.path}"
62
-
63
- html = @page.output
64
-
65
- return html if html.nil? || html.empty? || !html.is_a?(String)
66
-
67
- html.gsub(/<!--#kramdown-plantuml\.start#-->(?<json>.*?)<!--#kramdown-plantuml\.end#-->/m) do
68
- json = $LAST_MATCH_INFO ? $LAST_MATCH_INFO[:json] : nil
69
- replace_needle(json) unless json.nil?
70
- end
71
- end
72
-
73
- def replace_needle(json)
74
- logger.debug 'Replacing Jekyll needle.'
75
-
76
- needle_hash = JSON.parse(json)
77
- options_hash = needle_hash['options']
78
- options = ::Kramdown::PlantUml::Options.new({ plantuml: options_hash })
79
-
80
- begin
81
- decode_and_convert(needle_hash, options)
82
- rescue StandardError => e
83
- raise e if options.raise_errors?
84
-
85
- logger.error 'Error while replacing Jekyll needle.'
86
- logger.error e.to_s
87
- logger.debug_multiline json
88
- end
89
- end
90
-
91
- def decode_and_convert(hash, options)
92
- encoded_plantuml = hash['plantuml']
93
- plantuml = HTMLEntities.new.decode encoded_plantuml
94
- diagram = ::Kramdown::PlantUml::PlantUmlDiagram.new(plantuml, options)
95
- diagram.svg
96
- end
97
-
98
- def logger
99
- @logger ||= ::Kramdown::PlantUml::LogWrapper.init
100
- end
101
- end
102
- end
103
- end