kramdown-plantuml 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +1 -1
- data/README.md +1 -1
- data/bin/net/sourceforge/plantuml/plantuml/{1.2021.12/plantuml-1.2021.12.jar → 1.2021.16/plantuml-1.2021.16.jar} +0 -0
- data/lib/kramdown-plantuml/jekyll_provider.rb +6 -50
- data/lib/kramdown-plantuml/plantuml_diagram.rb +1 -1
- data/lib/kramdown-plantuml/theme.rb +3 -3
- data/lib/kramdown-plantuml/version.rb +1 -1
- data/lib/kramdown-plantuml.rb +0 -3
- data/lib/kramdown_html.rb +7 -17
- data/pom.xml +1 -1
- metadata +3 -4
- data/lib/kramdown-plantuml/jekyll_page_processor.rb +0 -103
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 716bd98dfc84efc97e64f12e8c1f68c1ee7a982e1d1ea33eabdf0f74b4560c04
|
4
|
+
data.tar.gz: 56254a3d065d7c69f2744cca59d32974e37f3e773bceccc2c63ab8dc151a5ace
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e19ff0d0e8b1b90f5a5e19595c95982c9e6c126b1b54b5238c0ee1ac81463aaf63350be0ea90c04844cbc7fca5c126cadd86fec50073ed9af0bf83b9800a706
|
7
|
+
data.tar.gz: c0dea81be5cd8bbf9c9541b4941cfd4c0ab05700a092a6b4672ec7adfe96f5e2212c22861dfcd0e86d1e90611b8bf2734da12d12b05853239ffa582b3b67bcc5
|
data/.github/workflows/ruby.yml
CHANGED
data/README.md
CHANGED
Binary file
|
@@ -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 :
|
10
|
+
attr_reader :site_source_dir
|
12
11
|
|
13
12
|
def jekyll
|
14
13
|
return @jekyll if defined? @jekyll
|
@@ -16,60 +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
|
20
|
+
def find_site_source_dir
|
38
21
|
if jekyll.sites.nil? || jekyll.sites.empty?
|
39
|
-
logger.
|
22
|
+
logger.warn 'Jekyll detected, but no sites found.'
|
40
23
|
return nil
|
41
24
|
end
|
42
25
|
|
43
|
-
@
|
44
|
-
logger.debug "Jekyll detected,
|
45
|
-
@
|
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
|
65
|
-
|
66
|
-
site.posts.each do |post|
|
67
|
-
processor = JekyllPageProcessor.new(post)
|
68
|
-
|
69
|
-
next unless processor.should_process?
|
70
|
-
|
71
|
-
processor.process(site.dest)
|
72
|
-
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
|
73
29
|
end
|
74
30
|
|
75
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?
|
38
|
+
return directory if directory.nil? || directory.empty?
|
39
39
|
|
40
|
-
directory = File.absolute_path(directory, jekyll.
|
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)
|
data/lib/kramdown-plantuml.rb
CHANGED
data/lib/kramdown_html.rb
CHANGED
@@ -6,7 +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'
|
10
9
|
|
11
10
|
module Kramdown
|
12
11
|
module Converter
|
@@ -16,19 +15,9 @@ module Kramdown
|
|
16
15
|
alias super_convert_codeblock convert_codeblock
|
17
16
|
|
18
17
|
def convert_codeblock(element, indent)
|
19
|
-
return super_convert_codeblock(element, indent) unless plantuml?
|
18
|
+
return super_convert_codeblock(element, indent) unless plantuml? element
|
20
19
|
|
21
|
-
|
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)
|
20
|
+
convert_plantuml(element.value)
|
32
21
|
end
|
33
22
|
|
34
23
|
private
|
@@ -37,14 +26,15 @@ module Kramdown
|
|
37
26
|
element.attr['class'] == 'language-plantuml'
|
38
27
|
end
|
39
28
|
|
40
|
-
def convert_plantuml(plantuml
|
41
|
-
|
29
|
+
def convert_plantuml(plantuml)
|
30
|
+
puml_opts = ::Kramdown::PlantUml::Options.new(@options)
|
31
|
+
diagram = ::Kramdown::PlantUml::PlantUmlDiagram.new(plantuml, puml_opts)
|
42
32
|
diagram.svg.to_s
|
43
33
|
rescue StandardError => e
|
44
|
-
raise e if
|
34
|
+
raise e if puml_opts.nil? || puml_opts.raise_errors?
|
45
35
|
|
46
36
|
logger = ::Kramdown::PlantUml::LogWrapper.init
|
47
|
-
logger.error "Error while
|
37
|
+
logger.error "Error while converting diagram: #{e.inspect}"
|
48
38
|
end
|
49
39
|
end
|
50
40
|
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.3.
|
4
|
+
version: 1.3.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: 2021-
|
11
|
+
date: 2021-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: htmlentities
|
@@ -194,13 +194,12 @@ files:
|
|
194
194
|
- LICENSE
|
195
195
|
- README.md
|
196
196
|
- Rakefile
|
197
|
-
- bin/net/sourceforge/plantuml/plantuml/1.2021.
|
197
|
+
- bin/net/sourceforge/plantuml/plantuml/1.2021.16/plantuml-1.2021.16.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
202
|
- lib/kramdown-plantuml/executor.rb
|
203
|
-
- lib/kramdown-plantuml/jekyll_page_processor.rb
|
204
203
|
- lib/kramdown-plantuml/jekyll_provider.rb
|
205
204
|
- lib/kramdown-plantuml/log_wrapper.rb
|
206
205
|
- 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
|